use of com.google.api.services.compute.model.NetworkPeering in project cdap by caskdata.
the class DataprocClient method getPeeringState.
private static PeeringState getPeeringState(String systemProjectId, String systemNetwork, Network networkInfo) {
// note: vpc network is a global resource.
// https://cloud.google.com/compute/docs/regions-zones/global-regional-zonal-resources#globalresources
String systemNetworkPath = String.format("https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s", systemProjectId, systemNetwork);
LOG.trace(String.format("Self link for the system network is %s", systemNetworkPath));
List<NetworkPeering> peerings = networkInfo.getPeerings();
// if the customer does not has a peering established at all the peering list is null
if (peerings == null) {
return PeeringState.NONE;
}
for (NetworkPeering peering : peerings) {
if (!systemNetworkPath.equals(peering.getNetwork())) {
continue;
}
return peering.getState().equals("ACTIVE") ? PeeringState.ACTIVE : PeeringState.INACTIVE;
}
return PeeringState.NONE;
}
Aggregations