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>;
Parameter
Name | Description |
records |
Record | Record[]
|
Returns
Type | Description |
Promise<CreateChangeResponse> | |
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
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>;
Parameter
Returns
create(config, callback)
create(config: CreateZoneRequest, callback: CreateZoneCallback): void;
Parameters
Returns
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
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
delete(options, callback)
delete(options: DeleteZoneConfig, callback: DeleteZoneCallback): void;
Parameters
Name | Description |
options |
DeleteZoneConfig
|
callback |
DeleteZoneCallback
|
Returns
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
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
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
empty()
empty(): Promise<CreateChangeResponse | []>;
Returns
Type | Description |
Promise<CreateChangeResponse | []> | |
empty(callback)
empty(callback: CreateChangeCallback): void;
Parameter
Name | Description |
callback |
CreateChangeCallback
|
Returns
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
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
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
Name | Description |
query |
GetChangesRequest
|
Returns
Type | Description |
Promise<GetChangesResponse> | |
getChanges(callback)
getChanges(callback: GetChangesCallback): void;
Parameter
Name | Description |
callback |
GetChangesCallback
|
Returns
getChanges(query, callback)
getChanges(query: GetChangesRequest, callback: GetChangesCallback): void;
Parameters
Name | Description |
query |
GetChangesRequest
|
callback |
GetChangesCallback
|
Returns
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
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
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
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 | {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