in compute/cloud-client/src/main/java/compute/ipaddress/GetVmAddress.java [47:72]
public static List<String> getVmAddress(String projectId, String instanceId, IpType ipType)
throws IOException {
List<String> result = new ArrayList<>();
Instance instance = getInstance(projectId, instanceId);
for (NetworkInterface networkInterface : instance.getNetworkInterfacesList()) {
if (ipType == IpType.EXTERNAL) {
for (AccessConfig accessConfig : networkInterface.getAccessConfigsList()) {
if (accessConfig.getType().equals(Type.ONE_TO_ONE_NAT.name())) {
result.add(accessConfig.getNatIP());
}
}
} else if (ipType == IpType.IP_V6) {
for (AccessConfig accessConfig : networkInterface.getAccessConfigsList()) {
if (accessConfig.hasExternalIpv6()
&& accessConfig.getType().equals(Type.DIRECT_IPV6.name())) {
result.add(accessConfig.getExternalIpv6());
}
}
} else if (ipType == IpType.INTERNAL) {
result.add(networkInterface.getNetworkIP());
}
}
return result;
}