Source:
protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) { String resourceName = namingConvention.create().sharedNameForGroup(groupName); final Network network = api.getNetworkApiForProject(project.get()).get(resourceName); FirewallApi firewallApi = api.getFirewallApiForProject(project.get()); Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() { @Override public boolean apply(Firewall input) { return input != null && input.getNetwork().equals(network.getSelfLink()); } }; Set<AtomicReference<Operation>> operations = Sets.newHashSet(); for (Firewall firewall : firewallApi.list().concat().filter(firewallBelongsToNetwork)) { operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName()))); } for (AtomicReference<Operation> operation : operations) { retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); if (operation.get().getHttpError().isPresent()) { HttpResponse response = operation.get().getHttpError().get(); logger.warn("delete orphaned firewall failed. Http Error Code: " + response.getStatusCode() + " HttpError: " + response.getMessage()); } } AtomicReference<Operation> operation = new AtomicReference<Operation>(api.getNetworkApiForProject(project.get()).delete(resourceName)); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); if (operation.get().getHttpError().isPresent()) { HttpResponse response = operation.get().getHttpError().get(); logger.warn("delete orphaned network failed. Http Error Code: " + response.getStatusCode() + " HttpError: " + response.getMessage()); } }

Target:
protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) { String resourceName = namingConvention.create().sharedNameForGroup(groupName); final Network network = api.getNetworkApiForProject(project.get()).get(resourceName); FirewallApi firewallApi = api.getFirewallApiForProject(project.get()); Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() { @Override public boolean apply(Firewall input) { return input != null && input.getNetwork().equals(network.getSelfLink()); } }; Set<AtomicReference<Operation>> operations = Sets.newHashSet(); for (Firewall firewall : firewallApi.list().concat().filter(firewallBelongsToNetwork)) { operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName()))); } for (AtomicReference<Operation> operation : operations) { retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); if (operation.get().getHttpError().isPresent()) { HttpResponse response = operation.get().getHttpError().get(); logger.warn("delete orphaned firewall %s failed. Http Error Code: %d HttpError: %s", operation.get().getTargetId(), response.getStatusCode(), response.getMessage()); } } AtomicReference<Operation> operation = new AtomicReference<Operation>(api.getNetworkApiForProject(project.get()).delete(resourceName)); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); if (operation.get().getHttpError().isPresent()) { HttpResponse response = operation.get().getHttpError().get(); logger.warn("delete orphaned network failed. Http Error Code: " + response.getStatusCode() + " HttpError: " + response.getMessage()); } }