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 Dns classes to meet proto conventions #1316

Merged
merged 2 commits into from
Oct 20, 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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,19 @@ Dns dns = DnsOptions.defaultInstance().service();
String zoneName = "my-unique-zone";
Zone zone = dns.getZone(zoneName);
String ip = "12.13.14.15";
RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A)
.ttl(24, TimeUnit.HOURS)
RecordSet toCreate = RecordSet.newBuilder("www.someexampledomain.com.", RecordSet.Type.A)
.setTtl(24, TimeUnit.HOURS)
.addRecord(ip)
.build();
ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate);
ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.newBuilder().add(toCreate);

// Verify that the record does not exist yet.
// If it does exist, we will overwrite it with our prepared record.
Iterator<RecordSet> recordSetIterator = zone.listRecordSets().iterateAll();
while (recordSetIterator.hasNext()) {
RecordSet current = recordSetIterator.next();
if (toCreate.name().equals(current.name()) &&
toCreate.type().equals(current.type())) {
if (toCreate.name().equals(current.getName()) &&
toCreate.type().equals(current.getType())) {
changeBuilder.delete(current);
}
}

This comment was marked as spam.

Expand Down
5 changes: 3 additions & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ You can test against an in-memory local DNS by following these steps:
The `delay` parameter determines if change requests should be processed synchronously
(value `0`) or in a separate thread with a minimum of delay of `delay` milliseconds.

2. In your program, create the DNS service by using the helper's `options()` method. For example:
2. In your program, create the DNS service by using the helper's `getOptions()` method.
For example:

```java
Dns dns = LocalDnsHelper.options().service();
Dns dns = LocalDnsHelper.getOptions().service();
```

3. Run your tests.
Expand Down
26 changes: 14 additions & 12 deletions google-cloud-dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description);

// Create zone in Google Cloud DNS
Zone zone = dns.create(zoneInfo);
System.out.printf("Zone was created and assigned ID %s.%n", zone.generatedId());
System.out.printf("Zone was created and assigned ID %s.%n", zone.getGeneratedId());
```

You now have an empty zone hosted in Google Cloud DNS which is ready to be populated with
Expand All @@ -142,7 +142,7 @@ and then add

```java
// Print assigned name servers
List<String> nameServers = zone.nameServers();
List<String> nameServers = zone.getNameServers();
for(String nameServer : nameServers) {
System.out.println(nameServer);
}
Expand Down Expand Up @@ -170,13 +170,13 @@ and proceed with:
```java
// Prepare a www.someexampledomain.com. type A record set with ttl of 24 hours
String ip = "12.13.14.15";
RecordSet toCreate = RecordSet.builder("www." + zone.dnsName(), RecordSet.Type.A)
.ttl(24, TimeUnit.HOURS)
RecordSet toCreate = RecordSet.newBuilder("www." + zone.dnsName(), RecordSet.Type.A)
.setTtl(24, TimeUnit.HOURS)
.addRecord(ip)
.build();

// Make a change
ChangeRequestInfo changeRequest = ChangeRequestInfo.builder().add(toCreate).build();
ChangeRequestInfo changeRequest = ChangeRequestInfo.newBuilder().add(toCreate).build();

// Build and apply the change request to our zone
changeRequest = zone.applyChangeRequest(changeRequest);
Expand Down Expand Up @@ -205,7 +205,8 @@ ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCrea
Iterator<RecordSet> recordSetIterator = zone.listRecordSets().iterateAll();
while (recordSetIterator.hasNext()) {
RecordSet current = recordSetIterator.next();
if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) {
if (toCreate.getName().equals(current.getName())
&& toCreate.getType().equals(current.getType())) {
changeBuilder.delete(current);
}
}
Expand Down Expand Up @@ -255,7 +256,7 @@ while (zoneIterator.hasNext()) {

// List the record sets in a particular zone
recordSetIterator = zone.listRecordSets().iterateAll();
System.out.println(String.format("Record sets inside %s:", zone.name()));
System.out.println(String.format("Record sets inside %s:", zone.getName()));
while (recordSetIterator.hasNext()) {
System.out.println(recordSetIterator.next());
}
Expand All @@ -274,7 +275,7 @@ and then:

// List the change requests applied to a particular zone
Iterator<ChangeRequest> changeIterator = zone.listChangeRequests().iterateAll();
System.out.println(String.format("The history of changes in %s:", zone.name()));
System.out.println(String.format("The history of changes in %s:", zone.getName()));
while (changeIterator.hasNext()) {
System.out.println(changeIterator.next());
}
Expand All @@ -287,18 +288,19 @@ First, you need to empty the zone by deleting all its records except for the def

```java
// Make a change for deleting the record sets
changeBuilder = ChangeRequestInfo.builder();
changeBuilder = ChangeRequestInfo.newBuilder();
while (recordIterator.hasNext()) {
RecordSet current = recordIterator.next();
// SOA and NS records cannot be deleted
if (!RecordSet.Type.SOA.equals(current.type()) && !RecordSet.Type.NS.equals(current.type())) {
if (!RecordSet.Type.SOA.equals(current.getType())
&& !RecordSet.Type.NS.equals(current.getType())) {
changeBuilder.delete(current);
}
}

// Build and apply the change request to our zone if it contains records to delete
ChangeRequestInfo changeRequest = changeBuilder.build();
if (!changeRequest.deletions().isEmpty()) {
if (!changeRequest.getDeletions().isEmpty()) {
ChangeRequest pendingRequest = dns.applyChangeRequest(zoneName, changeRequest);

// Wait for the change request to complete
Expand All @@ -325,7 +327,7 @@ if (result) {
#### Complete Source Code

We composed some of the aforementioned snippets into complete executable code samples. In
[CreateZones.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateZone.java)
[CreateZone.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateZone.java)
we create a zone. In [CreateOrUpdateRecordSets.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateOrUpdateRecordSets.java)
we create a type A record set for a zone, or update an existing type A record set to a new IP address. We
demonstrate how to delete a zone in [DeleteZone.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/DeleteZone.java).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,26 @@ private Builder(ChangeRequest cr) {
}

@Override
@Deprecated
public Builder additions(List<RecordSet> additions) {
infoBuilder.additions(additions);
return setAdditions(additions);
}

@Override
public Builder setAdditions(List<RecordSet> additions) {
infoBuilder.setAdditions(additions);
return this;
}

@Override
@Deprecated
public Builder deletions(List<RecordSet> deletions) {
infoBuilder.deletions(deletions);
return setDeletions(deletions);
}

@Override
public Builder setDeletions(List<RecordSet> deletions) {
infoBuilder.setDeletions(deletions);
return this;
}

Expand Down Expand Up @@ -103,20 +115,20 @@ public Builder removeDeletion(RecordSet recordSet) {
}

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

@Override
Builder startTimeMillis(long startTimeMillis) {
infoBuilder.startTimeMillis(startTimeMillis);
Builder setStartTime(long startTimeMillis) {
infoBuilder.setStartTime(startTimeMillis);
return this;
}

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

Expand All @@ -137,13 +149,27 @@ public ChangeRequest build() {
* Returns the name of the {@link Zone} associated with this change request.
*/
public String zone() {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

return getZone();
}

/**
* Returns the name of the {@link Zone} associated with this change request.
*/
public String getZone() {
return this.zone;
}

/**
* Returns the change request's {@code Dns} object used to issue requests.
*/
public Dns dns() {
return getDns();
}

/**
* Returns the change request's {@code Dns} object used to issue requests.
*/
public Dns getDns() {
return dns;
}

Expand All @@ -168,7 +194,7 @@ public ChangeRequest applyTo(String zoneName, Dns.ChangeRequestOption... options
* @throws DnsException upon failure of the API call or if the associated zone was not found
*/
public ChangeRequest reload(Dns.ChangeRequestOption... options) {
return dns.getChangeRequest(zone, generatedId(), options);
return dns.getChangeRequest(zone, getGeneratedId(), options);
}

/**
Expand Down
Loading