Skip to content

Commit

Permalink
Adds dnsName filter for Zone listing and tests. Fixes googleapis#602.
Browse files Browse the repository at this point in the history
  • Loading branch information
mderka committed Feb 9, 2016
1 parent 647bc6a commit 8d67442
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ public static ZoneListOption pageToken(String pageToken) {
return new ZoneListOption(DnsRpc.Option.PAGE_TOKEN, pageToken);
}

/**
* Restricts the list to only zone with this fully qualified domain name.
*/
public static ZoneListOption dnsName(String dnsName) {
StringBuilder builder = new StringBuilder();
return new ZoneListOption(DnsRpc.Option.DNS_NAME, dnsName);
}

/**
* The maximum number of zones to return per RPC.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public class DnsImplTest {
// Listing options
private static final Dns.ZoneListOption[] ZONE_LIST_OPTIONS = {
Dns.ZoneListOption.pageSize(MAX_SIZE), Dns.ZoneListOption.pageToken(PAGE_TOKEN),
Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)};
Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION),
Dns.ZoneListOption.dnsName(DNS_NAME)};
private static final Dns.ChangeRequestListOption[] CHANGE_LIST_OPTIONS = {
Dns.ChangeRequestListOption.pageSize(MAX_SIZE),
Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN),
Expand Down Expand Up @@ -330,6 +331,8 @@ public void testListZonesWithOptions() {
selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].rpcOption());
assertTrue(selector.contains(Dns.ZoneField.DESCRIPTION.selector()));
assertTrue(selector.contains(Dns.ZoneField.NAME.selector()));
selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[3].rpcOption());
assertEquals(DNS_NAME, selector);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class DnsTest {

private static final Integer PAGE_SIZE = 20;
private static final String PAGE_TOKEN = "page token";
private static final String DNS_NAME = "www.example.com.";

@Test
public void testDnsRecordListOption() {
Expand Down Expand Up @@ -89,6 +90,10 @@ public void testZoneList() {
option = Dns.ZoneListOption.pageSize(PAGE_SIZE);
assertEquals(PAGE_SIZE, option.value());
assertEquals(DnsRpc.Option.PAGE_SIZE, option.rpcOption());
// dnsName filter
option = Dns.ZoneListOption.dnsName(DNS_NAME);
assertEquals(DNS_NAME, option.value());
assertEquals(DnsRpc.Option.DNS_NAME, option.rpcOption());
}

@Test
Expand Down

0 comments on commit 8d67442

Please sign in to comment.