[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.
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
Properties
getZonesStream
getZonesStream: (query: GetZonesRequest) => Stream;
Methods
createZone(name, config)
createZone(name: string, config: CreateZoneRequest): Promise<CreateZoneResponse>;
createZone(name, config, callback)
createZone(name: string, config: CreateZoneRequest, callback: GetZoneCallback): void;
Returns |
---|
Type | Description |
void | |
getZones(query)
getZones(query?: GetZonesRequest): Promise<GetZonesResponse>;
getZones(callback)
getZones(callback: GetZonesCallback): void;
Returns |
---|
Type | Description |
void | |
getZones(query, callback)
getZones(query: GetZonesRequest, callback: GetZonesCallback): void;
Returns |
---|
Type | Description |
void | |
zone(name)
zone(name: string): Zone;
Get a reference to a Zone.
Parameter |
---|
Name | Description |
name |
string
The unique name of the zone.
|
Returns |
---|
Type | Description |
Zone | {Zone}
|
Example
const {DNS} = require('@google-cloud/dns'); const dns = new DNS();
const zone = dns.zone('my-zone');