private ManagedZone buildManagedZone(Dns dns, Stack stack) throws IOException {
MDCBuilder.buildMdcContext(stack);
GccCredential credential = (GccCredential) stack.getCredential();
ManagedZonesListResponse execute1 = dns.managedZones().list(credential.getProjectId()).execute();
ManagedZone original = null;
for (ManagedZone managedZone : execute1.getManagedZones()) {
if (managedZone.getName().equals(credential.getProjectId())) {
original = managedZone;
break;
}
}
if (original == null) {
ManagedZone managedZone = new ManagedZone();
managedZone.setName(credential.getProjectId());
managedZone.setDnsName(String.format("%s.%s", credential.getProjectId(), "com"));
ManagedZone execute = dns.managedZones().create(credential.getProjectId(), managedZone).execute();
return execute;
}
return original;
}