Package com.google.cloud.dns

A client to the Google Cloud DNS.

See: Description

Package com.google.cloud.dns Description

A client to the Google Cloud DNS.

Here are two simple usage examples from within Compute/App Engine. The first snippet shows how to create a zone resource. The complete source code can be found on CreateAndListZones.java. Note that you need to replace the domainName with a domain name that you own and the ownership of which you verified with Google.

 Dns dns = DnsOptions.defaultInstance().service();
 String zoneName = "my-unique-zone";
 String domainName = "someexampledomain.com.";
 String description = "This is a gcloud-java-dns sample zone.";
 ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description);
 Zone createdZone = dns.create(zoneInfo);
  

The second example shows how to create records inside a zone. The complete code can be found on CreateAndListDnsRecords.java.

 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)
   .addRecord(ip)
   .build();
 ChangeRequestInfo changeRequest = ChangeRequestInfo.builder().add(toCreate).build();
 zone.applyChangeRequest(changeRequest);
  

When using gcloud-java from outside of App/Compute Engine, you have to specify a project ID and provide credentials.

See Also:
Google Cloud DNS

Copyright © 2016 Google. All rights reserved.