Constructor

NotificationChannelServiceClient

new NotificationChannelServiceClient(options)

Construct an instance of NotificationChannelServiceClient.

Parameter

options

Optional

object

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

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

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

keyFilename

Optional

string

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

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

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

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

Properties

port

static

The port for this API service.

scopes

static

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

servicePath

static

The DNS address for this API service.

Methods

createNotificationChannel

createNotificationChannel(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing NotificationChannel. The promise has a method named "cancel" which cancels the ongoing API call.

Example

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

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

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

deleteNotificationChannel

deleteNotificationChannel(request, options, callback) returns Promise

Deletes a notification channel.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

force

Optional

boolean

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

Optional

Object

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

callback

Optional

function(nullable Error)

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

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

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

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

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

getNotificationChannel

getNotificationChannel(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing NotificationChannel. The promise has a method named "cancel" which cancels the ongoing API call.

Example

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

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

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

getNotificationChannelDescriptor

getNotificationChannelDescriptor(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing NotificationChannelDescriptor. The promise has a method named "cancel" which cancels the ongoing API call.

Example

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

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

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

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

listNotificationChannelDescriptors

listNotificationChannelDescriptors(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

number

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

Optional

Object

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

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

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.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of NotificationChannelDescriptor.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of NotificationChannelDescriptor in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListNotificationChannelDescriptorsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

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

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

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

client.listNotificationChannelDescriptors({name: formattedName})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

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


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  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

listNotificationChannelDescriptorsStream(request, options) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

number

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

Optional

Object

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

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing NotificationChannelDescriptor on 'data' event.

Example

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

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

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

listNotificationChannels

listNotificationChannels(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

string

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

Optional

string

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

Optional

number

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

Optional

Object

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

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

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.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of NotificationChannel.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of NotificationChannel in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListNotificationChannelsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

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

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

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

client.listNotificationChannels({name: formattedName})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

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


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  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

listNotificationChannelsStream(request, options) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

string

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

Optional

string

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

Optional

number

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

Optional

Object

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

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing NotificationChannel on 'data' event.

Example

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

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

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

matchChannelDescriptorFromNotificationChannelDescriptorName

matchChannelDescriptorFromNotificationChannelDescriptorName(notificationChannelDescriptorName) returns String

Parse the notificationChannelDescriptorName from a notification_channel_descriptor resource.

Parameter

notificationChannelDescriptorName

String

A fully-qualified path representing a notification_channel_descriptor resources.

Returns

String 

  • A string representing the channel_descriptor.

matchNotificationChannelFromNotificationChannelName

matchNotificationChannelFromNotificationChannelName(notificationChannelName) returns String

Parse the notificationChannelName from a notification_channel resource.

Parameter

notificationChannelName

String

A fully-qualified path representing a notification_channel resources.

Returns

String 

  • A string representing the notification_channel.

matchProjectFromNotificationChannelDescriptorName

matchProjectFromNotificationChannelDescriptorName(notificationChannelDescriptorName) returns String

Parse the notificationChannelDescriptorName from a notification_channel_descriptor resource.

Parameter

notificationChannelDescriptorName

String

A fully-qualified path representing a notification_channel_descriptor resources.

Returns

String 

  • A string representing the project.

matchProjectFromNotificationChannelName

matchProjectFromNotificationChannelName(notificationChannelName) returns String

Parse the notificationChannelName from a notification_channel resource.

Parameter

notificationChannelName

String

A fully-qualified path representing a notification_channel resources.

Returns

String 

  • A string representing the project.

matchProjectFromProjectName

matchProjectFromProjectName(projectName) returns String

Parse the projectName from a project resource.

Parameter

projectName

String

A fully-qualified path representing a project resources.

Returns

String 

  • A string representing the project.

notificationChannelDescriptorPath

notificationChannelDescriptorPath(project, channelDescriptor) returns String

Return a fully-qualified notification_channel_descriptor resource name string.

Parameter

project

String

channelDescriptor

String

Returns

String 

notificationChannelPath

notificationChannelPath(project, notificationChannel) returns String

Return a fully-qualified notification_channel resource name string.

Parameter

project

String

notificationChannel

String

Returns

String 

projectPath

projectPath(project) returns String

Return a fully-qualified project resource name string.

Parameter

project

String

Returns

String 

updateNotificationChannel

updateNotificationChannel(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

Object

The fields to update.

This object should have the same structure as FieldMask

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing NotificationChannel. The promise has a method named "cancel" which cancels the ongoing API call.

Example

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

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

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