use of com.google.api.services.compute.model.FirewallList in project cloudbreak by hortonworks.
the class GcpPlatformResources method securityGroups.
@Override
public CloudSecurityGroups securityGroups(CloudCredential cloudCredential, Region region, Map<String, String> filters) throws IOException {
Compute compute = GcpStackUtil.buildCompute(cloudCredential);
String projectId = GcpStackUtil.getProjectId(cloudCredential);
Map<String, Set<CloudSecurityGroup>> result = new HashMap<>();
if (compute != null) {
FirewallList firewallList = compute.firewalls().list(projectId).execute();
for (Firewall firewall : firewallList.getItems()) {
Map<String, Object> properties = new HashMap<>();
properties.put("network", getNetworkName(firewall));
CloudSecurityGroup cloudSecurityGroup = new CloudSecurityGroup(firewall.getName(), firewall.getName(), properties);
result.computeIfAbsent(region.value(), k -> new HashSet<>()).add(cloudSecurityGroup);
}
}
return new CloudSecurityGroups(result);
}
use of com.google.api.services.compute.model.FirewallList in project platformlayer by platformlayer.
the class GoogleComputeClient method getInstanceFirewallRules.
public List<Firewall> getInstanceFirewallRules(String instanceUrl) throws OpsException {
List<Firewall> ret = Lists.newArrayList();
FirewallList firewalls;
try {
log.debug("Listing firewall rules");
firewalls = compute.firewalls().list(projectId).execute();
} catch (IOException e) {
throw new OpsException("Error listing firewalls", e);
}
if (firewalls.getItems() != null) {
for (Firewall firewall : firewalls.getItems()) {
if (firewall.getTargetTags() != null && firewall.getTargetTags().contains(instanceUrl)) {
ret.add(firewall);
}
}
}
return ret;
}
Aggregations