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 > ZonePackage
@google-cloud/dnsExample
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
Properties
getChangesStream
getChangesStream
:
(
query
?:
GetChangesRequest
)
=
>
Readable
;
getRecordsStream
getRecordsStream
:
(
query
?:
GetRecordsRequest
|
string
|
string
[])
=
>
Readable
;
name
name
:
string
;
Methods
addRecords(records)
addRecords
(
records
:
Record
|
Record
[])
:
Promise<CreateChangeResponse>
;
Promise
< CreateChangeResponse
>
addRecords(records, callback)
addRecords
(
records
:
Record
|
Record
[],
callback
:
CreateChangeCallback
)
:
void
;
void
change(id)
change
(
id
?:
string
)
:
Change
;
Create a reference to a object in this zone.
id
string
The change id.
Change
{Change}
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
;
void
createChange(config)
createChange
(
config
:
CreateChangeRequest
)
:
Promise<CreateChangeResponse>
;
config
CreateChangeRequest
Promise
< CreateChangeResponse
>
createChange(config, callback)
createChange
(
config
:
CreateChangeRequest
,
callback
:
CreateChangeCallback
)
:
void
;
config
CreateChangeRequest
callback
CreateChangeCallback
void
delete(options)
delete
(
options
?:
DeleteZoneConfig
)
:
Promise<DeleteZoneResponse>
;
options
DeleteZoneConfig
Promise
< DeleteZoneResponse
>
delete(callback)
delete
(
callback
:
DeleteZoneCallback
)
:
void
;
callback
DeleteZoneCallback
void
delete(options, callback)
delete
(
options
:
DeleteZoneConfig
,
callback
:
DeleteZoneCallback
)
:
void
;
options
DeleteZoneConfig
callback
DeleteZoneCallback
void
deleteRecords(records)
deleteRecords
(
records
?:
Record
|
Record
[]
|
string
)
:
Promise<CreateChangeResponse>
;
Promise
< CreateChangeResponse
>
deleteRecords(callback)
deleteRecords
(
callback
:
CreateChangeCallback
)
:
void
;
callback
CreateChangeCallback
void
deleteRecords(records, callback)
deleteRecords
(
records
:
Record
|
Record
[]
|
string
,
callback
:
CreateChangeCallback
)
:
void
;
void
deleteRecordsByType_(recordTypes)
deleteRecordsByType_
(
recordTypes
:
string
[])
:
Promise<CreateChangeResponse>
;
recordTypes
string[]
Promise
< CreateChangeResponse
>
deleteRecordsByType_(recordTypes, callback)
deleteRecordsByType_
(
recordTypes
:
string
[],
callback
:
CreateChangeCallback
)
:
void
;
recordTypes
string[]
callback
CreateChangeCallback
void
empty()
empty
()
:
Promise<CreateChangeResponse
|
[]>;
Promise
< CreateChangeResponse
| []>
empty(callback)
empty
(
callback
:
CreateChangeCallback
)
:
void
;
callback
CreateChangeCallback
void
export(localPath)
export
(
localPath
:
string
)
:
Promise<ZoneExportResponse>
;
localPath
string
Promise
< ZoneExportResponse
>
export(localPath, callback)
export
(
localPath
:
string
,
callback
:
ZoneExportCallback
)
:
void
;
localPath
string
callback
ZoneExportCallback
void
get(config)
get
(
config
?:
GetZoneRequest
)
:
Promise<GetResponse<Zone>
> ;
config
GetZoneRequest
get(callback)
get
(
callback
:
InstanceResponseCallback<Zone>
)
:
void
;
void
get(config, callback)
get
(
config
:
GetZoneRequest
,
callback
:
InstanceResponseCallback<Zone>
)
:
void
;
void
getChanges(query)
getChanges
(
query
?:
GetChangesRequest
)
:
Promise<GetChangesResponse>
;
query
GetChangesRequest
Promise
< GetChangesResponse
>
getChanges(callback)
getChanges
(
callback
:
GetChangesCallback
)
:
void
;
callback
GetChangesCallback
void
getChanges(query, callback)
getChanges
(
query
:
GetChangesRequest
,
callback
:
GetChangesCallback
)
:
void
;
query
GetChangesRequest
callback
GetChangesCallback
void
getRecords(query)
getRecords
(
query
?:
GetRecordsRequest
|
string
|
string
[])
:
Promise<GetRecordsResponse>
;
query
GetRecordsRequest
| string | string[]
Promise
< GetRecordsResponse
>
getRecords(callback)
getRecords
(
callback
:
GetRecordsCallback
)
:
void
;
callback
GetRecordsCallback
void
getRecords(query, callback)
getRecords
(
query
:
GetRecordsRequest
|
string
|
string
[],
callback
:
GetRecordsCallback
)
:
void
;
query
GetRecordsRequest
| string | string[]
callback
GetRecordsCallback
void
import(localPath)
import
(
localPath
:
string
)
:
Promise<CreateChangeResponse>
;
localPath
string
Promise
< CreateChangeResponse
>
import(localPath, callback)
import
(
localPath
:
string
,
callback
:
CreateChangeCallback
)
:
void
;
localPath
string
callback
CreateChangeCallback
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.
type
string
The type of record to construct or the type of record you are referencing.
metadata
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>
;
Promise
< CreateChangeResponse
>
replaceRecords(recordType, newRecords, callback)
replaceRecords
(
recordType
:
string
|
string
[],
newRecords
:
Record
|
Record
[],
callback
:
CreateChangeCallback
)
:
void
;
void

