Change

Change

new Change(zone, id)

Parameters:
Name Type Description
zone Zone

The parent zone object.

id string

ID of the change.

Example
const {DNS} = require('@google-cloud/dns');
const dns = new DNS();
const zone = dns.zone('zone-id');
const change = zone.change('change-id');

Members

id :string

metadata :object

Methods

create(config, callbackopt) → {Promise.<CreateChangeResponse>}

Create a change.

Parameters:
Name Type Attributes Description
config CreateChangeRequest

The configuration object.

callback CreateChangeCallback <optional>

Callback function.

Example
const {DNS} = require('@google-cloud/dns');
const dns = new DNS();
const zone = dns.zone('zone-id');
const change = zone.change('change-id');

const config = {
  add: {
    // ...
  }
};

change.create(config, (err, change, apiResponse) => {
  if (!err) {
    // The change was created successfully.
  }
});

//-
// If the callback is omitted, we'll return a Promise.
//-
change.create(config).then((data) => {
  const change = data[0];
  const apiResponse = data[1];
});

exists(callbackopt) → {Promise.<ChangeExistsResponse>}

Check if the change exists.

Parameters:
Name Type Attributes Description
callback ChangeExistsCallback <optional>

Callback function.

Example
const {DNS} = require('@google-cloud/dns');
const dns = new DNS();
const zone = dns.zone('zone-id');
const change = zone.change('change-id');

change.exists((err, exists) => {});

//-
// If the callback is omitted, we'll return a Promise.
//-
change.exists().then((data) => {
  const exists = data[0];
});

get(optionsopt, callbackopt) → {Promise.<GetChangeResponse>}

Get a change if it exists.

You may optionally use this to "get or create" an object by providing an object with autoCreate set to true. Any extra configuration that is normally required for the create method must be contained within this object as well.

Parameters:
Name Type Attributes Description
options options <optional>

Configuration object.

Properties
Name Type Attributes Default Description
autoCreate boolean <optional>
false

Automatically create the object if it does not exist.

callback GetChangeCallback <optional>

Callback function.

Example
const {DNS} = require('@google-cloud/dns');
const dns = new DNS();
const zone = dns.zone('zone-id');
const change = zone.change('change-id');

change.get((err, change, apiResponse) => {
  // `change.metadata` has been populated.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
change.get().then((data) => {
  const change = data[0];
  const apiResponse = data[1];
});

getMetadata(callbackopt) → {Promise.<GetChangeMetadataResponse>}

Get the metadata for the change in the zone.

Parameters:
Name Type Attributes Description
callback GetChangeMetadataCallback <optional>

Callback function.

See:
Example
const {DNS} = require('@google-cloud/dns');
const dns = new DNS();
const zone = dns.zone('zone-id');
const change = zone.change('change-id');

change.getMetadata((err, metadata, apiResponse) => {
  if (!err) {
    // metadata = {
    //   kind: 'dns#change',
    //   additions: [{...}],
    //   deletions: [{...}],
    //   startTime: '2015-07-21T14:40:06.056Z',
    //   id: '1',
    //   status: 'done'
    // }
  }
});


//-
// If the callback is omitted, we'll return a Promise.
//-
change.getMetadata().then((data) => {
  const metadata = data[0];
  const apiResponse = data[1];
});