NotificationChannelServiceClient

NotificationChannelServiceClient

The Notification Channel API provides access to configuration that controls how messages related to incidents are sent.

Constructor

new NotificationChannelServiceClient(optionsopt)

Construct an instance of NotificationChannelServiceClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

promise function <optional>

Custom promise module to use instead of native Promises.

apiEndpoint string <optional>

The domain name of the API remote host.

Source:

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

Source:

(static) port

The port for this API service.

Source:

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

Source:

(static) servicePath

The DNS address for this API service.

Source:

Methods

createNotificationChannel(request, optionsopt, callbackopt) → {Promise}

Creates a new notification channel, representing a single notification endpoint such as an email address, SMS number, or PagerDuty service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The project on which to execute the request. The format is:

  projects/[PROJECT_ID]

Note that this names the container into which the channel will be written. This does not name the newly created channel. The resulting channel's name will have a normalized version of this field as a prefix, but will add /notificationChannels/[CHANNEL_ID] to identify the channel.

notificationChannel Object

The definition of the NotificationChannel to create.

This object should have the same structure as NotificationChannel

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing NotificationChannel.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.projectPath('[PROJECT]');
const notificationChannel = {};
const request = {
  name: formattedName,
  notificationChannel: notificationChannel,
};
client.createNotificationChannel(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

deleteNotificationChannel(request, optionsopt, callbackopt) → {Promise}

Deletes a notification channel.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The channel for which to execute the request. The format is projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID].

force boolean <optional>

If true, the notification channel will be deleted regardless of its use in alert policies (the policies will be updated to remove the channel). If false, channels that are still referenced by an existing alerting policy will fail to be deleted in a delete operation.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.notificationChannelPath('[PROJECT]', '[NOTIFICATION_CHANNEL]');
client.deleteNotificationChannel({name: formattedName}).catch(err => {
  console.error(err);
});

getNotificationChannel(request, optionsopt, callbackopt) → {Promise}

Gets a single notification channel. The channel includes the relevant configuration details with which the channel was created. However, the response may truncate or omit passwords, API keys, or other private key matter and thus the response may not be 100% identical to the information that was supplied in the call to the create method.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The channel for which to execute the request. The format is projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID].

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing NotificationChannel.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.notificationChannelPath('[PROJECT]', '[NOTIFICATION_CHANNEL]');
client.getNotificationChannel({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getNotificationChannelDescriptor(request, optionsopt, callbackopt) → {Promise}

Gets a single channel descriptor. The descriptor indicates which fields are expected / permitted for a notification channel of the given type.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The channel type for which to execute the request. The format is projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing NotificationChannelDescriptor.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.notificationChannelDescriptorPath('[PROJECT]', '[CHANNEL_DESCRIPTOR]');
client.getNotificationChannelDescriptor({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getNotificationChannelVerificationCode(request, optionsopt, callbackopt) → {Promise}

Requests a verification code for an already verified channel that can then be used in a call to VerifyNotificationChannel() on a different channel with an equivalent identity in the same or in a different project. This makes it possible to copy a channel between projects without requiring manual reverification of the channel. If the channel is not in the verified state, this method will fail (in other words, this may only be used if the SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been used to put the given channel into the verified state).

There is no guarantee that the verification codes returned by this method will be of a similar structure or form as the ones that are delivered to the channel via SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both the codes delivered via SendNotificationChannelVerificationCode() and returned from GetNotificationChannelVerificationCode(), it is typically the case that the verification codes delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return a much longer, websafe base 64 encoded string that has a longer expiration time.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The notification channel for which a verification code is to be generated and retrieved. This must name a channel that is already verified; if the specified channel is not verified, the request will fail.

expireTime Object <optional>

The desired expiration time. If specified, the API will guarantee that the returned code will not be valid after the specified timestamp; however, the API cannot guarantee that the returned code will be valid for at least as long as the requested time (the API puts an upper bound on the amount of time for which a code may be valid). If omitted, a default expiration will be used, which may be less than the max permissible expiration (so specifying an expiration may extend the code's lifetime over omitting an expiration, even though the API does impose an upper limit on the maximum expiration that is permitted).

This object should have the same structure as Timestamp

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing GetNotificationChannelVerificationCodeResponse.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.notificationChannelPath('[PROJECT]', '[NOTIFICATION_CHANNEL]');
client.getNotificationChannelVerificationCode({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

Source:

listNotificationChannelDescriptors(request, optionsopt, callbackopt) → {Promise}

Lists the descriptors for supported channel types. The use of descriptors makes it possible for new channel types to be dynamically added.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The REST resource name of the parent from which to retrieve the notification channel descriptors. The expected syntax is:

  projects/[PROJECT_ID]

Note that this names the parent container in which to look for the descriptors; to retrieve a single descriptor by name, use the GetNotificationChannelDescriptor operation, instead.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is Array of NotificationChannelDescriptor.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListNotificationChannelDescriptorsResponse.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedName = client.projectPath('[PROJECT]');

client.listNotificationChannelDescriptors({name: formattedName})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedName = client.projectPath('[PROJECT]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listNotificationChannelDescriptors(nextRequest, options).then(callback);
  }
}
client.listNotificationChannelDescriptors({name: formattedName}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listNotificationChannelDescriptorsStream(request, optionsopt) → {Stream}

Equivalent to listNotificationChannelDescriptors, but returns a NodeJS Stream object.

This fetches the paged responses for listNotificationChannelDescriptors continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The REST resource name of the parent from which to retrieve the notification channel descriptors. The expected syntax is:

  projects/[PROJECT_ID]

Note that this names the parent container in which to look for the descriptors; to retrieve a single descriptor by name, use the GetNotificationChannelDescriptor operation, instead.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Source:
See:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.projectPath('[PROJECT]');
client.listNotificationChannelDescriptorsStream({name: formattedName})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listNotificationChannels(request, optionsopt, callbackopt) → {Promise}

Lists the notification channels that have been created for the project.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The project on which to execute the request. The format is projects/[PROJECT_ID]. That is, this names the container in which to look for the notification channels; it does not name a specific channel. To query a specific channel by REST resource name, use the GetNotificationChannel operation.

filter string <optional>

If provided, this field specifies the criteria that must be met by notification channels to be included in the response.

For more details, see sorting and filtering.

orderBy string <optional>

A comma-separated list of fields by which to sort the result. Supports the same set of fields as in filter. Entries can be prefixed with a minus sign to sort in descending rather than ascending order.

For more details, see sorting and filtering.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is Array of NotificationChannel.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListNotificationChannelsResponse.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedName = client.projectPath('[PROJECT]');

client.listNotificationChannels({name: formattedName})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedName = client.projectPath('[PROJECT]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listNotificationChannels(nextRequest, options).then(callback);
  }
}
client.listNotificationChannels({name: formattedName}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listNotificationChannelsStream(request, optionsopt) → {Stream}

Equivalent to listNotificationChannels, but returns a NodeJS Stream object.

This fetches the paged responses for listNotificationChannels continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The project on which to execute the request. The format is projects/[PROJECT_ID]. That is, this names the container in which to look for the notification channels; it does not name a specific channel. To query a specific channel by REST resource name, use the GetNotificationChannel operation.

filter string <optional>

If provided, this field specifies the criteria that must be met by notification channels to be included in the response.

For more details, see sorting and filtering.

orderBy string <optional>

A comma-separated list of fields by which to sort the result. Supports the same set of fields as in filter. Entries can be prefixed with a minus sign to sort in descending rather than ascending order.

For more details, see sorting and filtering.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Source:
See:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.projectPath('[PROJECT]');
client.listNotificationChannelsStream({name: formattedName})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

matchChannelDescriptorFromNotificationChannelDescriptorName(notificationChannelDescriptorName) → {String}

Parse the notificationChannelDescriptorName from a notification_channel_descriptor resource.

Parameters:
Name Type Description
notificationChannelDescriptorName String

A fully-qualified path representing a notification_channel_descriptor resources.

Source:

matchNotificationChannelFromNotificationChannelName(notificationChannelName) → {String}

Parse the notificationChannelName from a notification_channel resource.

Parameters:
Name Type Description
notificationChannelName String

A fully-qualified path representing a notification_channel resources.

Source:

matchProjectFromNotificationChannelDescriptorName(notificationChannelDescriptorName) → {String}

Parse the notificationChannelDescriptorName from a notification_channel_descriptor resource.

Parameters:
Name Type Description
notificationChannelDescriptorName String

A fully-qualified path representing a notification_channel_descriptor resources.

Source:

matchProjectFromNotificationChannelName(notificationChannelName) → {String}

Parse the notificationChannelName from a notification_channel resource.

Parameters:
Name Type Description
notificationChannelName String

A fully-qualified path representing a notification_channel resources.

Source:

matchProjectFromProjectName(projectName) → {String}

Parse the projectName from a project resource.

Parameters:
Name Type Description
projectName String

A fully-qualified path representing a project resources.

Source:

notificationChannelDescriptorPath(project, channelDescriptor) → {String}

Return a fully-qualified notification_channel_descriptor resource name string.

Parameters:
Name Type Description
project String
channelDescriptor String
Source:

notificationChannelPath(project, notificationChannel) → {String}

Return a fully-qualified notification_channel resource name string.

Parameters:
Name Type Description
project String
notificationChannel String
Source:

projectPath(project) → {String}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
project String
Source:

sendNotificationChannelVerificationCode(request, optionsopt, callbackopt) → {Promise}

Causes a verification code to be delivered to the channel. The code can then be supplied in VerifyNotificationChannel to verify the channel.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The notification channel to which to send a verification code.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.notificationChannelPath('[PROJECT]', '[NOTIFICATION_CHANNEL]');
client.sendNotificationChannelVerificationCode({name: formattedName}).catch(err => {
  console.error(err);
});

updateNotificationChannel(request, optionsopt, callbackopt) → {Promise}

Updates a notification channel. Fields not specified in the field mask remain unchanged.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
notificationChannel Object

A description of the changes to be applied to the specified notification channel. The description must provide a definition for fields to be updated; the names of these fields should also be included in the update_mask.

This object should have the same structure as NotificationChannel

updateMask Object <optional>

The fields to update.

This object should have the same structure as FieldMask

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing NotificationChannel.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const notificationChannel = {};
client.updateNotificationChannel({notificationChannel: notificationChannel})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

verifyNotificationChannel(request, optionsopt, callbackopt) → {Promise}

Verifies a NotificationChannel by proving receipt of the code delivered to the channel as a result of calling SendNotificationChannelVerificationCode.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The notification channel to verify.

code string

The verification code that was delivered to the channel as a result of invoking the SendNotificationChannelVerificationCode API method or that was retrieved from a verified channel via GetNotificationChannelVerificationCode. For example, one might have "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only guaranteed that the code is valid UTF-8; one should not make any assumptions regarding the structure or format of the code).

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing NotificationChannel.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.NotificationChannelServiceClient({
  // optional auth parameters.
});

const formattedName = client.notificationChannelPath('[PROJECT]', '[NOTIFICATION_CHANNEL]');
const code = '';
const request = {
  name: formattedName,
  code: code,
};
client.verifyNotificationChannel(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });