diff --git a/README.md b/README.md index c2eea2a7da6a..c3d6ef1ba543 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ if (disk != null) { String snapshotName = "disk-name-snapshot"; Operation operation = disk.createSnapshot(snapshotName); operation = operation.waitFor(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { // use snapshot Snapshot snapshot = compute.getSnapshot(snapshotName); } @@ -252,7 +252,7 @@ MachineTypeId machineTypeId = MachineTypeId.of("us-central1-a", "n1-standard-1") Operation operation = compute.create(InstanceInfo.of(instanceId, machineTypeId, attachedDisk, networkInterface)); operation = operation.waitFor(); -if (operation.errors() == null) { +if (operation.getErrors() == null) { // use instance Instance instance = compute.getInstance(instanceId); } diff --git a/google-cloud-compute/README.md b/google-cloud-compute/README.md index 85385f819c8d..395f22936b0c 100644 --- a/google-cloud-compute/README.md +++ b/google-cloud-compute/README.md @@ -119,7 +119,7 @@ operation = operation.waitFor(); if (operation.errors() == null) { System.out.println("Address " + addressId + " was successfully created"); } else { - // inspect operation.errors() + // inspect operation.getErrors() throw new RuntimeException("Address creation failed"); } ``` @@ -150,7 +150,7 @@ DiskInfo disk = DiskInfo.of(diskId, diskConfiguration); Operation operation = compute.create(disk); // Wait for operation to complete operation = operation.waitFor(); -if (operation.errors() == null) { +if (operation.getErrors() == null) { System.out.println("Disk " + diskId + " was successfully created"); } else { // inspect operation.errors() @@ -185,10 +185,10 @@ Address externalIp = compute.getAddress(addressId); InstanceId instanceId = InstanceId.of("us-central1-a", "test-instance"); NetworkId networkId = NetworkId.of("default"); PersistentDiskConfiguration attachConfiguration = - PersistentDiskConfiguration.builder(diskId).boot(true).build(); + PersistentDiskConfiguration.newBuilder(diskId).setBoot(true).build(); AttachedDisk attachedDisk = AttachedDisk.of("dev0", attachConfiguration); -NetworkInterface networkInterface = NetworkInterface.builder(networkId) - .accessConfigurations(AccessConfig.of(externalIp.address())) +NetworkInterface networkInterface = NetworkInterface.newBuilder(networkId) + .setAccessConfigurations(AccessConfig.of(externalIp.getAddress())) .build(); MachineTypeId machineTypeId = MachineTypeId.of("us-central1-a", "n1-standard-1"); InstanceInfo instance = @@ -196,7 +196,7 @@ InstanceInfo instance = Operation operation = compute.create(instance); // Wait for operation to complete operation = operation.waitFor(); -if (operation.errors() == null) { +if (operation.getErrors() == null) { System.out.println("Instance " + instanceId + " was successfully created"); } else { // inspect operation.errors() diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java index 7d8fbd2e228d..bea18bedc3c0 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java @@ -308,7 +308,7 @@ private static class ListDiskTypesAction extends OptionalZoneAction { public void run(Compute compute, ZoneId zone) { Iterator diskTypeIterator; if (zone != null) { - diskTypeIterator = compute.listDiskTypes(zone.zone()).iterateAll(); + diskTypeIterator = compute.listDiskTypes(zone.getZone()).iterateAll(); } else { diskTypeIterator = compute.listDiskTypes().iterateAll(); } @@ -363,7 +363,7 @@ private static class ListMachineTypesAction extends OptionalZoneAction { public void run(Compute compute, ZoneId zone) { Iterator machineTypeIterator; if (zone != null) { - machineTypeIterator = compute.listMachineTypes(zone.zone()).iterateAll(); + machineTypeIterator = compute.listMachineTypes(zone.getZone()).iterateAll(); } else { machineTypeIterator = compute.listMachineTypes().iterateAll(); } @@ -429,7 +429,7 @@ public void run(Compute compute, Void arg) { private static class RegionInfoAction extends ComputeAction { @Override public void run(Compute compute, RegionId region) { - System.out.printf("Region info: %s%n", compute.getRegion(region.region())); + System.out.printf("Region info: %s%n", compute.getRegion(region.getRegion())); } @Override @@ -475,7 +475,7 @@ public void run(Compute compute, Void arg) { private static class ZoneInfoAction extends ComputeAction { @Override public void run(Compute compute, ZoneId zone) { - System.out.printf("Zone info: %s%n", compute.getZone(zone.zone())); + System.out.printf("Zone info: %s%n", compute.getZone(zone.getZone())); } @Override @@ -506,7 +506,7 @@ public String params() { private static class LicenseInfoAction extends ComputeAction { @Override public void run(Compute compute, LicenseId license) { - System.out.printf("License info: %s%n", compute.getLicense(license.license())); + System.out.printf("License info: %s%n", compute.getLicense(license.getLicense())); } @Override @@ -553,7 +553,8 @@ public void run(Compute compute, Void arg) { private static class ListZoneOperationsAction extends ComputeAction { @Override public void run(Compute compute, ZoneId zone) { - Iterator operationIterator = compute.listZoneOperations(zone.zone()).iterateAll(); + Iterator operationIterator = + compute.listZoneOperations(zone.getZone()).iterateAll(); while (operationIterator.hasNext()) { System.out.println(operationIterator.next()); } @@ -588,7 +589,7 @@ private static class ListRegionOperationsAction extends ComputeAction @Override public void run(Compute compute, RegionId region) { Iterator operationIterator = - compute.listRegionOperations(region.region()).iterateAll(); + compute.listRegionOperations(region.getRegion()).iterateAll(); while (operationIterator.hasNext()) { System.out.println(operationIterator.next()); } @@ -776,7 +777,7 @@ private static class ListAddressesAction extends OptionalRegionAction { public void run(Compute compute, RegionId region) { Iterator
addressIterator; if (region != null) { - addressIterator = compute.listRegionAddresses(region.region()).iterateAll(); + addressIterator = compute.listRegionAddresses(region.getRegion()).iterateAll(); } else { addressIterator = compute.listAddresses().iterateAll(); } @@ -841,15 +842,15 @@ public void run(Compute compute, AddressId address) throws InterruptedException } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Address %s was deleted%n", address); } else { System.out.printf("Deletion of address %s failed%n", address); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -868,15 +869,15 @@ public void run(Compute compute, AddressId address) throws InterruptedException Operation operation = compute.create(AddressInfo.of(address)); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Address %s was created%n", address); } else { System.out.printf("Creation of address %s failed%n", address); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -926,7 +927,7 @@ public String params() { private static class SnapshotInfoAction extends SnapshotAction { @Override public void run(Compute compute, SnapshotId snapshot) { - System.out.printf("Snapshot info: %s%n", compute.getSnapshot(snapshot.snapshot())); + System.out.printf("Snapshot info: %s%n", compute.getSnapshot(snapshot.getSnapshot())); } } @@ -939,22 +940,22 @@ public void run(Compute compute, SnapshotId snapshot) { private static class DeleteSnapshotAction extends SnapshotAction { @Override public void run(Compute compute, SnapshotId snapshot) throws InterruptedException { - Operation operation = compute.deleteSnapshot(snapshot.snapshot()); + Operation operation = compute.deleteSnapshot(snapshot.getSnapshot()); if (operation == null) { System.out.printf("Snapshot %s does not exist%n", snapshot); return; } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Snapshot %s was deleted%n", snapshot); } else { System.out.printf("Deletion of snapshot %s failed%n", snapshot); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -971,15 +972,15 @@ public void run(Compute compute, SnapshotInfo snapshot) throws InterruptedExcept Operation operation = compute.create(snapshot); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { - System.out.printf("Snapshot %s was created%n", snapshot.snapshotId()); + if (operation.getErrors() == null) { + System.out.printf("Snapshot %s was created%n", snapshot.getSnapshotId()); } else { - System.out.printf("Creation of snapshot %s failed%n", snapshot.snapshotId()); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Creation of snapshot %s failed%n", snapshot.getSnapshotId()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -1070,15 +1071,15 @@ public void run(Compute compute, ImageId image) throws InterruptedException { } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Image %s was deleted%n", image); } else { System.out.printf("Deletion of image %s failed%n", image); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -1095,15 +1096,15 @@ public void run(Compute compute, ImageInfo image) throws InterruptedException { Operation operation = compute.create(image); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { - System.out.printf("Image %s was created%n", image.imageId()); + if (operation.getErrors() == null) { + System.out.printf("Image %s was created%n", image.getImageId()); } else { - System.out.printf("Creation of image %s failed%n", image.imageId()); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Creation of image %s failed%n", image.getImageId()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -1178,15 +1179,15 @@ public void run(Compute compute, DiskId disk) throws InterruptedException { } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Disk %s was deleted%n", disk); } else { System.out.printf("Deletion of disk %s failed%n", disk); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -1213,15 +1214,15 @@ public void run(Compute compute, DiskInfo disk) throws InterruptedException { Operation operation = compute.create(disk); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { - System.out.printf("Disk %s was created%n", disk.diskId()); + if (operation.getErrors() == null) { + System.out.printf("Disk %s was created%n", disk.getDiskId()); } else { - System.out.printf("Creation of disk %s failed%n", disk.diskId()); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Creation of disk %s failed%n", disk.getDiskId()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -1245,13 +1246,13 @@ DiskInfo parse(String... args) throws Exception { DiskConfiguration configuration; if (args.length == 4) { try { - configuration = StandardDiskConfiguration.of(DiskTypeId.of(diskId.zone(), diskType), + configuration = StandardDiskConfiguration.of(DiskTypeId.of(diskId.getZone(), diskType), Integer.parseInt(args[3])); } catch (NumberFormatException ex) { throw new IllegalArgumentException("Error parsing disk size parameter."); } } else if (args.length == 3) { - configuration = StandardDiskConfiguration.of(DiskTypeId.of(diskId.zone(), diskType)); + configuration = StandardDiskConfiguration.of(DiskTypeId.of(diskId.getZone(), diskType)); } else { throw new IllegalArgumentException("Too many arguments."); } @@ -1365,7 +1366,7 @@ public String params() { private static class NetworkInfoAction extends NetworkAction { @Override public void run(Compute compute, NetworkId network) { - System.out.printf("Network info: %s%n", compute.getNetwork(network.network())); + System.out.printf("Network info: %s%n", compute.getNetwork(network.getNetwork())); } } @@ -1378,22 +1379,22 @@ public void run(Compute compute, NetworkId network) { private static class DeleteNetworkAction extends NetworkAction { @Override public void run(Compute compute, NetworkId network) throws InterruptedException { - Operation operation = compute.deleteNetwork(network.network()); + Operation operation = compute.deleteNetwork(network.getNetwork()); if (operation == null) { System.out.printf("Network %s does not exist%n", network); return; } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Network %s was deleted%n", network); } else { System.out.printf("Deletion of network %s failed%n", network); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -1404,15 +1405,15 @@ public void run(Compute compute, NetworkInfo network) throws InterruptedExceptio Operation operation = compute.create(network); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { - System.out.printf("Network %s was created%n", network.networkId()); + if (operation.getErrors() == null) { + System.out.printf("Network %s was created%n", network.getNetworkId()); } else { - System.out.printf("Creation of network %s failed%n", network.networkId()); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Creation of network %s failed%n", network.getNetworkId()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -1491,7 +1492,7 @@ private static class ListSubnetworksAction extends OptionalRegionAction { public void run(Compute compute, RegionId region) { Iterator subnetworkIterator; if (region != null) { - subnetworkIterator = compute.listSubnetworks(region.region()).iterateAll(); + subnetworkIterator = compute.listSubnetworks(region.getRegion()).iterateAll(); } else { subnetworkIterator = compute.listSubnetworks().iterateAll(); } @@ -1550,15 +1551,15 @@ public void run(Compute compute, SubnetworkId subnetwork) throws InterruptedExce } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Subnetwork %s was deleted%n", subnetwork); } else { System.out.printf("Deletion of subnetwork %s failed%n", subnetwork); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -1575,15 +1576,15 @@ public void run(Compute compute, SubnetworkInfo subnetwork) throws InterruptedEx Operation operation = compute.create(subnetwork); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { - System.out.printf("Subnetwork %s was created%n", subnetwork.subnetworkId()); + if (operation.getErrors() == null) { + System.out.printf("Subnetwork %s was created%n", subnetwork.getSubnetworkId()); } else { - System.out.printf("Creation of subnetwork %s failed%n", subnetwork.subnetworkId()); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Creation of subnetwork %s failed%n", subnetwork.getSubnetworkId()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -1618,7 +1619,7 @@ private static class ListInstancesAction extends OptionalZoneAction { public void run(Compute compute, ZoneId zone) { Iterator instanceIterator; if (zone != null) { - instanceIterator = compute.listInstances(zone.zone()).iterateAll(); + instanceIterator = compute.listInstances(zone.getZone()).iterateAll(); } else { instanceIterator = compute.listInstances().iterateAll(); } @@ -1677,15 +1678,15 @@ public void run(Compute compute, InstanceId instance) throws InterruptedExceptio } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Instance %s was deleted%n", instance); } else { System.out.printf("Deletion of instance %s failed%n", instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -1702,15 +1703,15 @@ public void run(Compute compute, InstanceInfo instance) throws InterruptedExcept Operation operation = compute.create(instance); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { - System.out.printf("Instance %s was created%n", instance.instanceId()); + if (operation.getErrors() == null) { + System.out.printf("Instance %s was created%n", instance.getInstanceId()); } else { - System.out.printf("Creation of instance %s failed%n", instance.instanceId()); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Creation of instance %s failed%n", instance.getInstanceId()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -1724,7 +1725,7 @@ InstanceInfo parse(String... args) throws Exception { MachineTypeId machineTypeId = MachineTypeId.of(zone, args[2]); DiskId diskId = DiskId.of(zone, args[3]); AttachedDisk disk = - AttachedDisk.of(PersistentDiskConfiguration.builder(diskId).boot(true).build()); + AttachedDisk.of(PersistentDiskConfiguration.newBuilder(diskId).setBoot(true).build()); NetworkInterface networkInterface = NetworkInterface.of(args[4]); return InstanceInfo.of(instanceId, machineTypeId, disk, networkInterface); } else if (args.length > 5) { @@ -1813,17 +1814,17 @@ public void run(Compute compute, Triple interf } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Access config added to network interface %s of instance %s%n", networkInterface, instance); } else { System.out.printf("Attempt to add access config to network interface %s of instance %s%n", networkInterface, instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -1836,10 +1837,10 @@ Triple parse(String... args) throws Exception String accessConfig = args[3]; if (args.length == 4) { return Triple.of(instance, networkInterface, - AccessConfig.builder().name(accessConfig).build()); + AccessConfig.newBuilder().setName(accessConfig).build()); } else if (args.length == 5) { return Triple.of(instance, networkInterface, - AccessConfig.builder().name(accessConfig).natIp(args[4]).build()); + AccessConfig.newBuilder().setName(accessConfig).setNatIp(args[4]).build()); } else { message = "Too many arguments."; } @@ -1877,18 +1878,18 @@ public void run(Compute compute, Triple interfaceAnd } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Access config deleted from network interface %s of instance %s%n", networkInterface, instance); } else { System.out.printf( "Attempt to delete access config from network interface %s of instance %s failed%n", networkInterface, instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -1935,15 +1936,15 @@ public void run(Compute compute, Triple instanceAndDevice) } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Disk detached from instance %s%n", instance); } else { System.out.printf("Attempt to detach disk from instance %s failed%n", instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -2046,16 +2047,16 @@ public void run(Compute compute, Triple deviceAndAu } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Auto-delete set for device %s of instance %s%n", deviceName, instance); } else { System.out.printf("Attempt to set auto-delete for device %s of instance %s failed%n", deviceName, instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -2112,15 +2113,15 @@ public void run(Compute compute, Tuple instanceAndTyp } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Machine type set for instance %s%n", instance); } else { System.out.printf("Attempt to set machine type for instance %s failed%n", instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -2166,15 +2167,15 @@ public void run(Compute compute, Tuple> instanceAndTags Operation operation = instance.setTags(tags); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Tags set for instance %s%n", instanceId); } else { System.out.printf("Attempt to set tags for instance %s failed%n", instanceId); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -2217,15 +2218,15 @@ public void run(Compute compute, Tuple> instance Operation operation = instance.setMetadata(metadata); while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Metadata set for instance %s%n", instanceId); } else { System.out.printf("Attempt to set metadata for instance %s failed%n", instanceId); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -2272,16 +2273,16 @@ public void run(Compute compute, Tuple instanceAn } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Scheduling options set for instance %s%n", instanceId); } else { System.out.printf( "Attempt to set scheduling options for instance %s failed%n", instanceId); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } @@ -2338,15 +2339,15 @@ public void run(Compute compute, InstanceId instance) throws InterruptedExceptio } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Instance %s was reset%n", instance); } else { System.out.printf("Attempt to reset instance %s failed%n", instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -2367,15 +2368,15 @@ public void run(Compute compute, InstanceId instance) throws InterruptedExceptio } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Instance %s was stopped%n", instance); } else { System.out.printf("Attempt to stop instance %s failed%n", instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } @@ -2396,15 +2397,15 @@ public void run(Compute compute, InstanceId instance) throws InterruptedExceptio } while (!operation.isDone()) { System.out.printf( - "Waiting for operation %s to complete%n", operation.operationId().operation()); + "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.printf("Instance %s was started%n", instance); } else { System.out.printf("Attempt to start instance %s failed%n", instance); - System.out.printf("Error: %s%n", operation.errors()); + System.out.printf("Error: %s%n", operation.getErrors()); } } } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateAddressDiskAndInstance.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateAddressDiskAndInstance.java index 0a63865904e0..2e0834fa600b 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateAddressDiskAndInstance.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateAddressDiskAndInstance.java @@ -53,7 +53,7 @@ public static void main(String... args) throws InterruptedException, TimeoutExce Operation operation = compute.create(AddressInfo.of(addressId)); // Wait for operation to complete operation = operation.waitFor(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.println("Address " + addressId + " was successfully created"); } else { // inspect operation.errors() @@ -68,7 +68,7 @@ public static void main(String... args) throws InterruptedException, TimeoutExce operation = compute.create(disk); // Wait for operation to complete operation = operation.waitFor(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.println("Disk " + diskId + " was successfully created"); } else { // inspect operation.errors() @@ -80,10 +80,10 @@ public static void main(String... args) throws InterruptedException, TimeoutExce InstanceId instanceId = InstanceId.of("us-central1-a", "test-instance"); NetworkId networkId = NetworkId.of("default"); PersistentDiskConfiguration attachConfiguration = - PersistentDiskConfiguration.builder(diskId).boot(true).build(); + PersistentDiskConfiguration.newBuilder(diskId).setBoot(true).build(); AttachedDisk attachedDisk = AttachedDisk.of("dev0", attachConfiguration); - NetworkInterface networkInterface = NetworkInterface.builder(networkId) - .accessConfigurations(AccessConfig.of(externalIp.address())) + NetworkInterface networkInterface = NetworkInterface.newBuilder(networkId) + .setAccessConfigurations(AccessConfig.of(externalIp.getAddress())) .build(); MachineTypeId machineTypeId = MachineTypeId.of("us-central1-a", "n1-standard-1"); InstanceInfo instance = @@ -91,7 +91,7 @@ public static void main(String... args) throws InterruptedException, TimeoutExce operation = compute.create(instance); // Wait for operation to complete operation = operation.waitFor(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { System.out.println("Instance " + instanceId + " was successfully created"); } else { // inspect operation.errors() diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateInstance.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateInstance.java index 66c10bace269..0d55dfa3e52f 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateInstance.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateInstance.java @@ -46,7 +46,7 @@ public static void main(String... args) throws InterruptedException, TimeoutExce Operation operation = compute.create(InstanceInfo.of(instanceId, machineTypeId, attachedDisk, networkInterface)); operation = operation.waitFor(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { // use instance Instance instance = compute.getInstance(instanceId); } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateSnapshot.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateSnapshot.java index 35d19e38e18e..8c221d6bb5f6 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateSnapshot.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/snippets/CreateSnapshot.java @@ -39,7 +39,7 @@ public static void main(String... args) throws InterruptedException, TimeoutExce String snapshotName = "disk-name-snapshot"; Operation operation = disk.createSnapshot(snapshotName); operation = operation.waitFor(); - if (operation.errors() == null) { + if (operation.getErrors() == null) { // use snapshot Snapshot snapshot = compute.getSnapshot(snapshotName); }