Skip to content

Commit

Permalink
Rename setters/getters/builders for Compute classes to meet proto con…
Browse files Browse the repository at this point in the history
…ventions (#1322)

* Rename setters/getters/builders for Compute classes to meet proto conventions

* Update Compute examples, snippets and READMEs to use renamed getters/setters/builders
  • Loading branch information
mziccard authored Oct 26, 2016
1 parent 82b2951 commit 4142a84
Show file tree
Hide file tree
Showing 122 changed files with 8,166 additions and 3,442 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ enum Type {
/**
* Returns the type of this address identity.
*/
@Deprecated
public abstract Type type();

/**
* Returns the type of this address identity.
*/
public abstract Type getType();

/**
* Returns the name of the address resource. The name must be 1-63 characters long and comply with
* RFC1035. Specifically, the name must match the regular expression
Expand All @@ -65,7 +71,21 @@ enum Type {
*
* @see <a href="https://www.ietf.org/rfc/rfc1035.txt">RFC1035</a>
*/
@Deprecated
public String address() {
return getAddress();
}

/**
* Returns the name of the address resource. The name must be 1-63 characters long and comply with
* RFC1035. Specifically, the name must match the regular expression
* {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a lowercase letter,
* and all following characters must be a dash, lowercase letter, or digit, except the last
* character, which cannot be a dash.
*
* @see <a href="https://www.ietf.org/rfc/rfc1035.txt">RFC1035</a>
*/
public String getAddress() {
return address;
}

Expand Down
Loading

0 comments on commit 4142a84

Please sign in to comment.