Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 26, 2016
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
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