Send feedback Class Zone (4.0.0) Stay organized with collections Save and categorize content based on your preferences. Version latestkeyboard_arrow_down A Zone object is used to interact with your project's managed zone. It will help you add or delete records, delete your zone, and many other convenience methods.
Inheritance ZoneServiceObject > Zone Package @google-cloud/dns Example const {DNS} = require('@google-cloud/dns'); const dns = new DNS();
const zone = dns.zone('zone-id');
Constructors (constructor)(dns, name)
constructor ( dns : DNS , name : string ); Constructs a new instance of the Zone class
Parameters Name Description dns DNS name string
Properties getChangesStream
getChangesStream : ( query ?: GetChangesRequest ) = > Readable ; getRecordsStream
getRecordsStream : ( query ?: GetRecordsRequest | string | string []) = > Readable ; name Methods addRecords(records)
addRecords ( records : Record | Record []) : Promise<CreateChangeResponse> ; Returns Type Description Promise <CreateChangeResponse >
addRecords(records, callback)
addRecords ( records : Record | Record [], callback : CreateChangeCallback ) : void ; Parameters Name Description records Record | Record [] callback CreateChangeCallback
Returns Type Description void
change(id)
change ( id ?: string ) : Change ; Create a reference to a object in this zone.
Parameter Name Description id string The change id.
Returns Type Description Change {Change}
Example const {DNS} = require('@google-cloud/dns'); const dns = new DNS(); const zone = dns.zone('zone-id'); const change = zone.change('change-id');
create(config)
create ( config : CreateZoneRequest ) : Promise<CreateZoneResponse> ; create(config, callback)
create ( config : CreateZoneRequest , callback : CreateZoneCallback ) : void ; Returns Type Description void
createChange(config)
createChange ( config : CreateChangeRequest ) : Promise<CreateChangeResponse> ; Parameter Name Description config CreateChangeRequest
Returns Type Description Promise <CreateChangeResponse >
createChange(config, callback)
createChange ( config : CreateChangeRequest , callback : CreateChangeCallback ) : void ; Parameters Name Description config CreateChangeRequest callback CreateChangeCallback
Returns Type Description void
delete(options)
delete ( options ?: DeleteZoneConfig ) : Promise<DeleteZoneResponse> ; Parameter Name Description options DeleteZoneConfig
Returns Type Description Promise <DeleteZoneResponse >
delete(callback)
delete ( callback : DeleteZoneCallback ) : void ; Parameter Name Description callback DeleteZoneCallback
Returns Type Description void
delete(options, callback)
delete ( options : DeleteZoneConfig , callback : DeleteZoneCallback ) : void ; Parameters Name Description options DeleteZoneConfig callback DeleteZoneCallback
Returns Type Description void
deleteRecords(records)
deleteRecords ( records ?: Record | Record [] | string ) : Promise<CreateChangeResponse> ; Parameter Name Description records Record | Record [] | string
Returns Type Description Promise <CreateChangeResponse >
deleteRecords(callback)
deleteRecords ( callback : CreateChangeCallback ) : void ; Parameter Name Description callback CreateChangeCallback
Returns Type Description void
deleteRecords(records, callback)
deleteRecords ( records : Record | Record [] | string , callback : CreateChangeCallback ) : void ; Parameters Name Description records Record | Record [] | string callback CreateChangeCallback
Returns Type Description void
deleteRecordsByType_(recordTypes)
deleteRecordsByType_ ( recordTypes : string []) : Promise<CreateChangeResponse> ; Parameter Name Description recordTypes string[]
Returns Type Description Promise <CreateChangeResponse >
deleteRecordsByType_(recordTypes, callback)
deleteRecordsByType_ ( recordTypes : string [], callback : CreateChangeCallback ) : void ; Parameters Name Description recordTypes string[] callback CreateChangeCallback
Returns Type Description void
empty()
empty () : Promise<CreateChangeResponse | []>; Returns Type Description Promise <CreateChangeResponse | []>
empty(callback)
empty ( callback : CreateChangeCallback ) : void ; Parameter Name Description callback CreateChangeCallback
Returns Type Description void
export(localPath)
export ( localPath : string ) : Promise<ZoneExportResponse> ; Parameter Name Description localPath string
Returns Type Description Promise <ZoneExportResponse >
export(localPath, callback)
export ( localPath : string , callback : ZoneExportCallback ) : void ; Parameters Name Description localPath string callback ZoneExportCallback
Returns Type Description void
get(config)
get ( config ?: GetZoneRequest ) : Promise<GetResponse<Zone> >; Parameter Name Description config GetZoneRequest
Returns Type Description Promise <GetResponse <Zone >>
get(callback)
get ( callback : InstanceResponseCallback<Zone> ) : void ; Parameter Name Description callback InstanceResponseCallback <Zone >
Returns Type Description void
get(config, callback)
get ( config : GetZoneRequest , callback : InstanceResponseCallback<Zone> ) : void ; Parameters Name Description config GetZoneRequest callback InstanceResponseCallback <Zone >
Returns Type Description void
getChanges(query)
getChanges ( query ?: GetChangesRequest ) : Promise<GetChangesResponse> ; Parameter Name Description query GetChangesRequest
Returns Type Description Promise <GetChangesResponse >
getChanges(callback)
getChanges ( callback : GetChangesCallback ) : void ; Parameter Name Description callback GetChangesCallback
Returns Type Description void
getChanges(query, callback)
getChanges ( query : GetChangesRequest , callback : GetChangesCallback ) : void ; Parameters Name Description query GetChangesRequest callback GetChangesCallback
Returns Type Description void
getRecords(query)
getRecords ( query ?: GetRecordsRequest | string | string []) : Promise<GetRecordsResponse> ; Parameter Name Description query GetRecordsRequest | string | string[]
Returns Type Description Promise <GetRecordsResponse >
getRecords(callback)
getRecords ( callback : GetRecordsCallback ) : void ; Parameter Name Description callback GetRecordsCallback
Returns Type Description void
getRecords(query, callback)
getRecords ( query : GetRecordsRequest | string | string [], callback : GetRecordsCallback ) : void ; Parameters Name Description query GetRecordsRequest | string | string[] callback GetRecordsCallback
Returns Type Description void
import(localPath)
import ( localPath : string ) : Promise<CreateChangeResponse> ; Parameter Name Description localPath string
Returns Type Description Promise <CreateChangeResponse >
import(localPath, callback)
import ( localPath : string , callback : CreateChangeCallback ) : void ; Parameters Name Description localPath string callback CreateChangeCallback
Returns Type Description void
record(type, metadata)
record ( type : string , metadata : RecordMetadata ) : Record ; A object can be used to construct a record you want to add to your zone, or to refer to an existing one.
Note that using this method will not itself make any API requests. You will use the object returned in other API calls, for example to add a record to your zone or to delete an existing one.
Parameters Name Description type string The type of record to construct or the type of record you are referencing.
metadata RecordMetadata The metadata of this record.
Returns Type Description Record_2 {Record}
Example const {DNS} = require('@google-cloud/dns'); const dns = new DNS();
const zone = dns.zone('zone-id');
//- // Reference an existing record to delete from your zone. //- const oldARecord = zone.record('a', { name: 'example.com.', data: '1.2.3.4', ttl: 86400 });
//- // Construct a record to add to your zone. //- const newARecord = zone.record('a', { name: 'example.com.', data: '5.6.7.8', ttl: 86400 });
//- // Use these records together to create a change. //- zone.createChange({ add: newARecord, delete: oldARecord }, (err, change, apiResponse) => {});
replaceRecords(recordType, newRecords)
replaceRecords ( recordType : string | string [], newRecords : Record | Record []) : Promise<CreateChangeResponse> ; Parameters Name Description recordType string | string[] newRecords Record | Record []
Returns Type Description Promise <CreateChangeResponse >
replaceRecords(recordType, newRecords, callback)
replaceRecords ( recordType : string | string [], newRecords : Record | Record [], callback : CreateChangeCallback ) : void ; Parameters Name Description recordType string | string[] newRecords Record | Record [] callback CreateChangeCallback
Returns Type Description void
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 2025-10-30 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 2025-10-30 UTC."],[],[]]