Class NotificationChannelServiceClient (0.32.0)

NotificationChannelServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

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

Methods

NotificationChannelServiceClient

NotificationChannelServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

credentials google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

client_config dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

create_notification_channel

create_notification_channel(name, notification_channel, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.NotificationChannelServiceClient()

name = client.project_path('[PROJECT]')

TODO: Initialize notification_channel:

notification_channel = {}

response = client.create_notification_channel(name, notification_channel)

Parameters
NameDescription
name str

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.

notification_channel Union[dict, NotificationChannel]

The definition of the NotificationChannel to create. If a dict is provided, it must be of the same form as the protobuf message NotificationChannel

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

delete_notification_channel

delete_notification_channel(name, force=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Deletes a notification channel.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.NotificationChannelServiceClient()

name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]')

client.delete_notification_channel(name)

Parameters
NameDescription
name str

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

force bool

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.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

from_service_account_file

from_service_account_file(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
NotificationChannelServiceClientThe constructed client.

from_service_account_json

from_service_account_json(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
NotificationChannelServiceClientThe constructed client.

get_notification_channel

get_notification_channel(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.NotificationChannelServiceClient()

name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]')

response = client.get_notification_channel(name)

Parameters
NameDescription
name str

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

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

get_notification_channel_descriptor

get_notification_channel_descriptor(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.NotificationChannelServiceClient()

name = client.notification_channel_descriptor_path('[PROJECT]', '[CHANNEL_DESCRIPTOR]')

response = client.get_notification_channel_descriptor(name)

Parameters
NameDescription
name str

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

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_notification_channel_descriptors

list_notification_channel_descriptors(name, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.NotificationChannelServiceClient()

name = client.project_path('[PROJECT]')

Iterate over all results

for element in client.list_notification_channel_descriptors(name): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_notification_channel_descriptors(name).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
name str

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.

page_size int

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.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_notification_channels

list_notification_channels(name, filter_=None, order_by=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.NotificationChannelServiceClient()

name = client.project_path('[PROJECT]')

Iterate over all results

for element in client.list_notification_channels(name): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_notification_channels(name).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
name str

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_ str

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 https://cloud.google.com/monitoring/api/v3/sorting-and-filtering__.

order_by str

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 https://cloud.google.com/monitoring/api/v3/sorting-and-filtering__.

page_size int

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.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

notification_channel_descriptor_path

notification_channel_descriptor_path(project, channel_descriptor)

Return a fully-qualified notification_channel_descriptor string.

notification_channel_path

notification_channel_path(project, notification_channel)

Return a fully-qualified notification_channel string.

project_path

project_path(project)

Return a fully-qualified project string.

update_notification_channel

update_notification_channel(notification_channel, update_mask=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.NotificationChannelServiceClient()

TODO: Initialize notification_channel:

notification_channel = {}

response = client.update_notification_channel(notification_channel)

Parameters
NameDescription
notification_channel Union[dict, NotificationChannel]

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. If a dict is provided, it must be of the same form as the protobuf message NotificationChannel

update_mask Union[dict, FieldMask]

The fields to update. If a dict is provided, it must be of the same form as the protobuf message FieldMask

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.