Send feedback
Class Zone (2.2.4) Stay organized with collections
Save and categorize content based on your preferences.
Version 2.2.4 keyboard_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
Properties
getChangesStream
getChangesStream
:
(
query
?:
GetChangesRequest
)
=
>
Readable
;
getRecordsStream
getRecordsStream
:
(
query
?:
GetRecordsRequest
|
string
|
string
[])
=
>
Readable
;
name
Methods
addRecords(records)
addRecords
(
records
:
Record
|
Record
[])
:
Promise<CreateChangeResponse>
;
Parameter Name
Description
records
Record
| Record
[]
Returns
addRecords(records, callback)
addRecords
(
records
:
Record
|
Record
[],
callback
:
CreateChangeCallback
)
:
void
;
Parameters Name
Description
records
Record
| Record
[]
callback
CreateChangeCallback
Returns
change(id)
change
(
id
?:
string
)
:
Change
;
Create a reference to a object in this zone.
Parameter
Returns
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>
;
Parameter
Returns
create(config, callback)
create
(
config
:
CreateZoneRequest
,
callback
:
CreateZoneCallback
)
:
void
;
Parameters
Returns
createChange(config)
createChange
(
config
:
CreateChangeRequest
)
:
Promise<CreateChangeResponse>
;
Parameter
Returns
createChange(config, callback)
createChange
(
config
:
CreateChangeRequest
,
callback
:
CreateChangeCallback
)
:
void
;
Parameters
Returns
delete(options)
delete
(
options
?:
DeleteZoneConfig
)
:
Promise<DeleteZoneResponse>
;
Parameter
Returns
delete(callback)
delete
(
callback
:
DeleteZoneCallback
)
:
void
;
Parameter
Returns
delete(options, callback)
delete
(
options
:
DeleteZoneConfig
,
callback
:
DeleteZoneCallback
)
:
void
;
Parameters
Returns
deleteRecords(records)
deleteRecords
(
records
?:
Record
|
Record
[]
|
string
)
:
Promise<CreateChangeResponse>
;
Parameter Name
Description
records
Record
| Record
[] | string
Returns
deleteRecords(callback)
deleteRecords
(
callback
:
CreateChangeCallback
)
:
void
;
Parameter
Returns
deleteRecords(records, callback)
deleteRecords
(
records
:
Record
|
Record
[]
|
string
,
callback
:
CreateChangeCallback
)
:
void
;
Parameters Name
Description
records
Record
| Record
[] | string
callback
CreateChangeCallback
Returns
deleteRecordsByType_(recordTypes)
deleteRecordsByType_
(
recordTypes
:
string
[])
:
Promise<CreateChangeResponse>
;
Parameter
Returns
deleteRecordsByType_(recordTypes, callback)
deleteRecordsByType_
(
recordTypes
:
string
[],
callback
:
CreateChangeCallback
)
:
void
;
Parameters
Returns
empty()
empty
()
:
Promise<CreateChangeResponse
|
[]>;
Returns
empty(callback)
empty
(
callback
:
CreateChangeCallback
)
:
void
;
Parameter
Returns
export(localPath)
export
(
localPath
:
string
)
:
Promise<ZoneExportResponse>
;
Parameter
Returns
export(localPath, callback)
export
(
localPath
:
string
,
callback
:
ZoneExportCallback
)
:
void
;
Parameters
Returns
get(config)
get
(
config
?:
GetZoneRequest
)
:
Promise<GetResponse<Zone>
> ;
Parameter
Returns
get(callback)
get
(
callback
:
InstanceResponseCallback<Zone>
)
:
void
;
Parameter Name
Description
callback
InstanceResponseCallback
< Zone
>
Returns
get(config, callback)
get
(
config
:
GetZoneRequest
,
callback
:
InstanceResponseCallback<Zone>
)
:
void
;
Parameters Name
Description
config
GetZoneRequest
callback
InstanceResponseCallback
< Zone
>
Returns
getChanges(query)
getChanges
(
query
?:
GetChangesRequest
)
:
Promise<GetChangesResponse>
;
Parameter
Returns
getChanges(callback)
getChanges
(
callback
:
GetChangesCallback
)
:
void
;
Parameter
Returns
getChanges(query, callback)
getChanges
(
query
:
GetChangesRequest
,
callback
:
GetChangesCallback
)
:
void
;
Parameters
Returns
getRecords(query)
getRecords
(
query
?:
GetRecordsRequest
|
string
|
string
[])
:
Promise<GetRecordsResponse>
;
Parameter Name
Description
query
GetRecordsRequest
| string | string[]
Returns
getRecords(callback)
getRecords
(
callback
:
GetRecordsCallback
)
:
void
;
Parameter
Returns
getRecords(query, callback)
getRecords
(
query
:
GetRecordsRequest
|
string
|
string
[],
callback
:
GetRecordsCallback
)
:
void
;
Parameters Name
Description
query
GetRecordsRequest
| string | string[]
callback
GetRecordsCallback
Returns
import(localPath)
import
(
localPath
:
string
)
:
Promise<CreateChangeResponse>
;
Parameter
Returns
import(localPath, callback)
import
(
localPath
:
string
,
callback
:
CreateChangeCallback
)
:
void
;
Parameters
Returns
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
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
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
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."],[],[]]