Rename setters/getters/builders for Compute classes to meet proto conventions by mziccard · Pull Request #1322 · googleapis/google-cloud-java · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
12 changes: 6 additions & 6 deletions google-cloud-compute/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
```
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -185,18 +185,18 @@ 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 =
InstanceInfo.of(instanceId, machineTypeId, attachedDisk, networkInterface);
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static class Builder extends AddressInfo.Builder {
Builder(Compute compute, AddressId addressId) {
this.compute = compute;
this.infoBuilder = new AddressInfo.BuilderImpl();
this.infoBuilder.addressId(addressId);
this.infoBuilder.setAddressId(addressId);
}

Builder(Address address) {
Expand All @@ -65,44 +65,62 @@ public static class Builder extends AddressInfo.Builder {
}

@Override
@Deprecated
public Builder address(String address) {
infoBuilder.address(address);
return setAddress(address);
}

@Override
public Builder setAddress(String address) {
infoBuilder.setAddress(address);
return this;
}

@Override
Builder creationTimestamp(Long creationTimestamp) {
infoBuilder.creationTimestamp(creationTimestamp);
Builder setCreationTimestamp(Long creationTimestamp) {
infoBuilder.setCreationTimestamp(creationTimestamp);
return this;
}

@Override
@Deprecated
public Builder description(String description) {
infoBuilder.description(description);
return setDescription(description);
}

@Override
public Builder setDescription(String description) {
infoBuilder.setDescription(description);
return this;
}

@Override
Builder generatedId(String generatedId) {
infoBuilder.generatedId(generatedId);
Builder setGeneratedId(String generatedId) {
infoBuilder.setGeneratedId(generatedId);
return this;
}

@Override
@Deprecated
public Builder addressId(AddressId addressId) {
infoBuilder.addressId(addressId);
return setAddressId(addressId);
}

@Override
public Builder setAddressId(AddressId addressId) {
infoBuilder.setAddressId(addressId);
return this;
}

@Override
Builder status(Status status) {
infoBuilder.status(status);
Builder setStatus(Status status) {
infoBuilder.setStatus(status);
return this;
}

@Override
Builder usage(Usage usage) {
infoBuilder.usage(usage);
Builder setUsage(Usage usage) {
infoBuilder.setUsage(usage);
return this;
}

Expand Down Expand Up @@ -137,7 +155,7 @@ public boolean exists() {
* @throws ComputeException upon failure
*/
public Address reload(AddressOption... options) {
return compute.getAddress(addressId(), options);
return compute.getAddress(getAddressId(), options);
}

/**
Expand All @@ -148,13 +166,21 @@ public Address reload(AddressOption... options) {
* @throws ComputeException upon failure
*/
public Operation delete(OperationOption... options) {
return compute.deleteAddress(addressId(), options);
return compute.deleteAddress(getAddressId(), options);
}

/**
* Returns the address's {@code Compute} object used to issue requests.
*/
@Deprecated
public Compute compute() {
return getCompute();
}

/**
* Returns the address's {@code Compute} object used to issue requests.
*/
public Compute getCompute() {
return compute;
}

Expand Down
Loading