com.google.cloud.dns.ZoneInfo类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中com.google.cloud.dns.ZoneInfo类的一些代码示例,展示了ZoneInfo类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneInfo类的具体详情如下:
包路径:com.google.cloud.dns.ZoneInfo
类名称:ZoneInfo

ZoneInfo介绍

[英]A Zone represents a DNS zone hosted by the Google Cloud DNS service. A zone is a subtree of the DNS namespace under one administrative responsibility. See Google Cloud DNS documentation for more information.
[中]区域表示由谷歌云DNS服务托管的DNS区域。区域是DNS名称空间的子树,由一个管理职责管理。有关更多信息,请参见{$0$}。

代码示例

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testToAndFromPb() {
 assertEquals(INFO, ZoneInfo.fromPb(INFO.toPb()));
 ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION);
 assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
 partial =
   ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().setGeneratedId(GENERATED_ID).build();
 assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
 partial =
   ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION)
     .toBuilder()
     .setCreationTimeMillis(CREATION_TIME_MILLIS)
     .build();
 assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
 List<String> nameServers = new LinkedList<>();
 nameServers.add(NS1);
 partial =
   ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().setNameServers(nameServers).build();
 assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
 partial =
   ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION)
     .toBuilder()
     .setNameServerSet(NAME_SERVER_SET)
     .build();
 assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
}

代码示例来源:origin: googleapis/google-cloud-java

@Override
 public String toString() {
  return MoreObjects.toStringHelper(this)
    .add("name", getName())
    .add("generatedId", getGeneratedId())
    .add("description", getDescription())
    .add("dnsName", getDnsName())
    .add("nameServerSet", getNameServerSet())
    .add("nameServers", getNameServers())
    .add("creationTimeMillis", getCreationTimeMillis())
    .toString();
 }
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testSameHashCodeOnEquals() {
 int hash = INFO.hashCode();
 ZoneInfo clone = INFO.toBuilder().build();
 assertEquals(clone.hashCode(), hash);
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testEmptyNameServers() {
 ZoneInfo clone = INFO.toBuilder().setNameServers(new LinkedList<String>()).build();
 assertTrue(clone.getNameServers().isEmpty());
 clone.toPb(); // test that this is allowed
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testCreateValidZone() {
 try {
  Zone created = DNS.create(ZONE1);
  assertEquals(ZONE1.getDescription(), created.getDescription());
  assertEquals(ZONE1.getDnsName(), created.getDnsName());
  assertEquals(ZONE1.getName(), created.getName());
  assertNotNull(created.getCreationTimeMillis());
  assertNotNull(created.getNameServers());
  assertNull(created.getNameServerSet());
  assertNotNull(created.getGeneratedId());
  Zone retrieved = DNS.getZone(ZONE1.getName());
  assertEquals(created, retrieved);
  created = DNS.create(ZONE_EMPTY_DESCRIPTION);
  assertEquals(ZONE_EMPTY_DESCRIPTION.getDescription(), created.getDescription());
  assertEquals(ZONE_EMPTY_DESCRIPTION.getDnsName(), created.getDnsName());
  assertEquals(ZONE_EMPTY_DESCRIPTION.getName(), created.getName());
  assertNotNull(created.getCreationTimeMillis());
  assertNotNull(created.getNameServers());
  assertNull(created.getNameServerSet());
  assertNotNull(created.getGeneratedId());
  retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.getName());
  assertEquals(created, retrieved);
 } finally {
  DNS.delete(ZONE1.getName());
  DNS.delete(ZONE_EMPTY_DESCRIPTION.getName());
 }
}

代码示例来源:origin: googleapis/google-cloud-java

String domainName = "someexampledomain.com."; // Change this to a domain which you own
String description = "This is a google-cloud-dns sample zone.";
ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description);
Zone zone = dns.create(zoneInfo);
System.out.printf("Zone was created and assigned ID %s.%n", zone.getGeneratedId());
List<String> nameServers = zone.getNameServers();
for (String nameServer : nameServers) {
 System.out.println(nameServer);
Page<RecordSet> recordSetPage = zone.listRecordSets();
for (RecordSet current : recordSetPage.iterateAll()) {
 if (toCreate.getName().equals(current.getName())
  System.err.println("The thread was interrupted while waiting...");
 changeRequest = dns.getChangeRequest(zone.getName(), changeRequest.getGeneratedId());
for (Zone currentZone : dns.listZones().iterateAll()) {
 System.out.printf("#%d.: %s%n%n", counter, currentZone);
 counter++;

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testCreateChange() {
 try {
  DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME));
  ChangeRequest created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1);
  assertEquals(CHANGE_ADD_ZONE1.getAdditions(), created.getAdditions());
  assertNotNull(created.getStartTimeMillis());
    ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE)
      .contains(created.status()));
  assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.getName(), "1"));
  waitForChangeToComplete(created);
  created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1);
  waitForChangeToComplete(created);
      ZONE1.getName(),
      CHANGE_ADD_ZONE1,
      Dns.ChangeRequestOption.fields(ChangeRequestField.ID));
  assertNull(created.status());
  waitForChangeToComplete(created);
  created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1);
  waitForChangeToComplete(created);
      ZONE1.getName(),
      CHANGE_ADD_ZONE1,
      Dns.ChangeRequestOption.fields(ChangeRequestField.STATUS));
  assertNotNull(created.status());
  waitForChangeToComplete(created);

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testDeleteZone() {
 try {
  Zone created = DNS.create(ZONE1);
  assertEquals(created, DNS.getZone(ZONE1.getName()));
  DNS.delete(ZONE1.getName());
  assertNull(DNS.getZone(ZONE1.getName()));
 } finally {
  DNS.delete(ZONE1.getName());
 }
}

代码示例来源:origin: googleapis/google-cloud-java

ChangeRequest change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1);
 waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId());
       ZONE1.getName(), Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.getName()))
     .iterateAll()
     .iterator();
 waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId());
       ZONE1.getName(),
       Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.getName()),
       Dns.RecordSetListOption.type(A_RECORD_ZONE1.getType()))
  DNS.listRecordSets(ZONE1.getName(), Dns.RecordSetListOption.type(A_RECORD_ZONE1.getType()));
  fail();
 } catch (DnsException ex) {
  DNS.listRecordSets(ZONE1.getName(), Dns.RecordSetListOption.pageSize(0));
  fail();
 } catch (DnsException ex) {
  DNS.listRecordSets(ZONE1.getName(), Dns.RecordSetListOption.pageSize(-1));
  fail();
 } catch (DnsException ex) {
 waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId());
} finally {
 clear();

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetZone() {
 EasyMock.expect(dnsRpcMock.getZone(ZONE_INFO.getName(), EMPTY_RPC_OPTIONS))
   .andReturn(ZONE_INFO.toPb());
 EasyMock.replay(dnsRpcMock);
 dns = options.getService(); // creates DnsImpl
 Zone zone = dns.getZone(ZONE_INFO.getName());
 assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone);
}

代码示例来源:origin: googleapis/google-cloud-java

/** Creates a zone with the provided name, DNS name and description (in this order). */
@Override
public void run(Dns dns, String... args) {
 String zoneName = args[0];
 String dnsName = args[1];
 String description = args[2];
 ZoneInfo zoneInfo = ZoneInfo.of(zoneName, dnsName, description);
 Zone zone = dns.create(zoneInfo);
 System.out.printf(
   "Successfully created zone with name %s which was assigned ID %s.%n",
   zone.getName(), zone.getGeneratedId());
}

代码示例来源:origin: googleapis/google-cloud-java

DNS.listChangeRequests(ZONE1.getName());
 fail();
} catch (DnsException ex) {
DNS.create(ZONE1);
ImmutableList<ChangeRequest> changes =
  ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName()).iterateAll());
assertEquals(1, changes.size()); // default change creating SOA and NS
ChangeRequest change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1);
waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId());
change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId());
change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1);
waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId());
change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId());
changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName()).iterateAll());
assertEquals(5, changes.size());
 DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.pageSize(0));
 fail();
} catch (DnsException ex) {
 DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.pageSize(-1));
 fail();
} catch (DnsException ex) {
        ZONE1.getName(),

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testEqualsAndNotEquals() {
 ZoneInfo clone = INFO.toBuilder().build();
 assertEquals(INFO, clone);
 List<String> moreServers = Lists.newLinkedList(NAME_SERVERS);
 moreServers.add(NS1);
 clone = INFO.toBuilder().setNameServers(moreServers).build();
 assertNotEquals(INFO, clone);
 String differentName = "totally different name";
 clone = INFO.toBuilder().setName(differentName).build();
 assertNotEquals(INFO, clone);
 clone = INFO.toBuilder().setCreationTimeMillis(INFO.getCreationTimeMillis() + 1).build();
 assertNotEquals(INFO, clone);
 clone = INFO.toBuilder().setDescription(INFO.getDescription() + "aaaa").build();
 assertNotEquals(INFO, clone);
 clone = INFO.toBuilder().setDnsName(differentName).build();
 assertNotEquals(INFO, clone);
 clone = INFO.toBuilder().setGeneratedId(INFO.getGeneratedId() + "1111").build();
 assertNotEquals(INFO, clone);
 clone = INFO.toBuilder().setNameServerSet(INFO.getNameServerSet() + "salt").build();
 assertNotEquals(INFO, clone);
}

代码示例来源:origin: googleapis/google-cloud-java

public static void main(String... args) {
  // Create a service object
  // The project ID and credentials will be inferred from the environment.
  Dns dns = DnsOptions.getDefaultInstance().getService();

  // Create a zone metadata object
  String zoneName = "my-unique-zone"; // Change this zone name which is unique within your project
  String domainName = "someexampledomain.com."; // Change this to a domain which you own
  String description = "This is a google-cloud-dns sample zone.";
  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.getGeneratedId());
 }
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testCreateZoneWithErrors() {
 try {
  try {
   DNS.create(ZONE_NAME_ERROR);
   fail("Zone name is too long. The service returns an error.");
  } catch (DnsException ex) {
   // expected
   assertFalse(ex.isRetryable());
  }
  try {
   DNS.create(ZONE_DNS_NO_PERIOD);
   fail("Zone name is missing a period. The service returns an error.");
  } catch (DnsException ex) {
   // expected
   assertFalse(ex.isRetryable());
  }
 } finally {
  DNS.delete(ZONE_NAME_ERROR.getName());
  DNS.delete(ZONE_DNS_NO_PERIOD.getName());
 }
}

代码示例来源:origin: googleapis/google-cloud-java

static Zone fromPb(Dns dns, ManagedZone zone) {
  ZoneInfo info = ZoneInfo.fromPb(zone);
  return new Zone(dns, new ZoneInfo.BuilderImpl(info));
 }
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetChangeRequest() {
 EasyMock.expect(
     dnsRpcMock.getChangeRequest(
       ZONE_INFO.getName(), CHANGE_REQUEST_COMPLETE.getGeneratedId(), EMPTY_RPC_OPTIONS))
   .andReturn(CHANGE_REQUEST_COMPLETE.toPb());
 EasyMock.replay(dnsRpcMock);
 dns = options.getService(); // creates DnsImpl
 ChangeRequest changeRequest =
   dns.getChangeRequest(ZONE_INFO.getName(), CHANGE_REQUEST_COMPLETE.getGeneratedId());
 assertEquals(
   new ChangeRequest(
     dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)),
   changeRequest);
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testApplyChangeRequest() {
 EasyMock.expect(
     dnsRpcMock.applyChangeRequest(
       ZONE_INFO.getName(), CHANGE_REQUEST_PARTIAL.toPb(), EMPTY_RPC_OPTIONS))
   .andReturn(CHANGE_REQUEST_COMPLETE.toPb());
 EasyMock.replay(dnsRpcMock);
 dns = options.getService(); // creates DnsImpl
 ChangeRequest changeRequest =
   dns.applyChangeRequest(ZONE_INFO.getName(), CHANGE_REQUEST_PARTIAL);
 assertEquals(
   new ChangeRequest(
     dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)),
   changeRequest);
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testListChangeRequests() {
 EasyMock.expect(dnsRpcMock.listChangeRequests(ZONE_INFO.getName(), EMPTY_RPC_OPTIONS))
   .andReturn(LIST_RESULT_OF_PB_CHANGES);
 EasyMock.replay(dnsRpcMock);
 dns = options.getService(); // creates DnsImpl
 Page<ChangeRequest> changeRequestPage = dns.listChangeRequests(ZONE_INFO.getName());
 assertTrue(
   Lists.newArrayList(changeRequestPage.getValues())
     .contains(
       new ChangeRequest(
         dns,
         ZONE_INFO.getName(),
         new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE))));
 assertTrue(
   Lists.newArrayList(changeRequestPage.getValues())
     .contains(
       new ChangeRequest(
         dns,
         ZONE_INFO.getName(),
         new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_PARTIAL))));
 assertEquals(2, Lists.newArrayList(changeRequestPage.getValues()).size());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testCreateZoneWithErrorsBatch() {
 try {
  DnsBatch batch = DNS.batch();
  DnsBatchResult<Zone> nameErrorResult = batch.createZone(ZONE_NAME_ERROR);
  DnsBatchResult<Zone> noPeriodResult = batch.createZone(ZONE_DNS_NO_PERIOD);
  batch.submit();
  try {
   nameErrorResult.get();
   fail("Zone name is too long. The service returns an error.");
  } catch (DnsException ex) {
   // expected
   assertFalse(ex.isRetryable());
  }
  try {
   noPeriodResult.get();
   fail("Zone name is missing a period. The service returns an error.");
  } catch (DnsException ex) {
   // expected
   assertFalse(ex.isRetryable());
  }
 } finally {
  DNS.delete(ZONE_NAME_ERROR.getName());
  DNS.delete(ZONE_DNS_NO_PERIOD.getName());
 }
}

相关文章