Class DNS (4.0.0)

[Cloud DNS](https://cloud.google.com/dns/what-is-cloud-dns) is a high-performance, resilient, global DNS service that provides a cost-effective way to make your applications and services available to your users. This programmable, authoritative DNS service can be used to easily publish and manage DNS records using the same infrastructure relied upon by Google.

Inheritance

Service > DNS

Package

@google-cloud/dns

Examples

Import the client library const {DNS} = require('@google-cloud/dns');

Create a client that uses a href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application"Application Default Credentials (ADC): const dns = new DNS();

Create a client with a href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually"explicit credentials: const dns = new DNS({ projectId: 'your-project-id', keyFilename: '/path/to/keyfile.json' });

Full quickstart example:


  // Imports the Google Cloud client library
  const {DNS} = require('@google-cloud/dns');

  // Creates a client
  const dns = new DNS();

  async function quickstart() {
    // Lists all zones in the current project
    const [zones] = await dns.getZones();
    console.log('Zones:');
    zones.forEach(zone => console.log(zone.name));
  }
  quickstart();

Constructors

(constructor)(options)

constructor(options?: DNSOptions);

Constructs a new instance of the DNS class

Parameter
NameDescription
options DNSOptions

Properties

getZonesStream

getZonesStream: (query: GetZonesRequest) => Stream;

Methods

createZone(name, config)

createZone(name: string, config: CreateZoneRequest): Promise<CreateZoneResponse>;
Parameters
NameDescription
name string
config CreateZoneRequest
Returns
TypeDescription
Promise<CreateZoneResponse>

createZone(name, config, callback)

createZone(name: string, config: CreateZoneRequest, callback: GetZoneCallback): void;
Parameters
NameDescription
name string
config CreateZoneRequest
callback GetZoneCallback
Returns
TypeDescription
void

getZones(query)

getZones(query?: GetZonesRequest): Promise<GetZonesResponse>;
Parameter
NameDescription
query GetZonesRequest
Returns
TypeDescription
Promise<GetZonesResponse>

getZones(callback)

getZones(callback: GetZonesCallback): void;
Parameter
NameDescription
callback GetZonesCallback
Returns
TypeDescription
void

getZones(query, callback)

getZones(query: GetZonesRequest, callback: GetZonesCallback): void;
Parameters
NameDescription
query GetZonesRequest
callback GetZonesCallback
Returns
TypeDescription
void

zone(name)

zone(name: string): Zone;

Get a reference to a Zone.

Parameter
NameDescription
name string

The unique name of the zone.

Returns
TypeDescription
Zone

{Zone}

Example

const {DNS} = require('@google-cloud/dns'); const dns = new DNS();

const zone = dns.zone('my-zone');