Send feedback
Class DNS (4.0.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version latestkeyboard_arrow_down
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');
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-03-09 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-03-09 UTC."],[],[]]