Client for Stackdriver Monitoring API#
-
class
google.cloud.monitoring_v3.
AlertPolicyServiceClient
(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]# The AlertPolicyService API is used to manage (list, create, delete, edit) alert policies in Stackdriver Monitoring. An alerting policy is a description of the conditions under which some aspect of your system is considered to be “unhealthy” and the ways to notify people or services about this state. In addition to using this API, alert policies can also be managed through Stackdriver Monitoring, which can be reached by clicking the “Monitoring” tab in Cloud Console.
Constructor.
- Parameters
(Union[AlertPolicyServiceGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.AlertPolicyServiceGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.
channel (grpc.Channel) – DEPRECATED. A
Channel
instance through which to make calls. This argument is mutually exclusive withcredentials
; 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.
-
classmethod
alert_policy_condition_path
(project, alert_policy, condition)[source]# Return a fully-qualified alert_policy_condition string.
-
classmethod
alert_policy_path
(project, alert_policy)[source]# Return a fully-qualified alert_policy string.
-
create_alert_policy
(name, alert_policy, retry=<object object>, timeout=<object object>, metadata=None)[source]# Creates a new alerting policy.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.AlertPolicyServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize `alert_policy`: >>> alert_policy = {} >>> >>> response = client.create_alert_policy(name, alert_policy)
- Parameters
name (str) –
The project in which to create the alerting policy. The format is
projects/[PROJECT_ID]
.Note that this field names the parent container in which the alerting policy will be written, not the name of the created policy. The alerting policy that is returned will have a name that contains a normalized representation of this name as a prefix but adds a suffix of the form
/alertPolicies/[POLICY_ID]
, identifying the policy in the container.alert_policy (Union[dict, AlertPolicy]) –
The requested alerting policy. You should omit the
name
field in this policy. The name will be returned in the new policy, including a new [ALERT_POLICY_ID] value.If a dict is provided, it must be of the same form as the protobuf message
AlertPolicy
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
AlertPolicy
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
delete_alert_policy
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Deletes an alerting policy.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.AlertPolicyServiceClient() >>> >>> name = client.alert_policy_path('[PROJECT]', '[ALERT_POLICY]') >>> >>> client.delete_alert_policy(name)
- Parameters
name (str) –
The alerting policy to delete. The format is:
projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
For more information, see
AlertPolicy
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
enums
= <module 'google.cloud.monitoring_v3.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/monitoring_v3/gapic/enums.py'>#
-
classmethod
from_service_account_file
(filename, *args, **kwargs)[source]# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
classmethod
from_service_account_json
(filename, *args, **kwargs)# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
get_alert_policy
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Gets a single alerting policy.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.AlertPolicyServiceClient() >>> >>> name = client.alert_policy_path('[PROJECT]', '[ALERT_POLICY]') >>> >>> response = client.get_alert_policy(name)
- Parameters
name (str) –
The alerting policy to retrieve. The format is
projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
AlertPolicy
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_alert_policies
(name, filter_=None, order_by=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists the existing alerting policies for the project.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.AlertPolicyServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # Iterate over all results >>> for element in client.list_alert_policies(name): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_alert_policies(name).pages: ... for element in page: ... # process element ... pass
- Parameters
name (str) –
The project whose alert policies are to be listed. The format is
projects/[PROJECT_ID]
Note that this field names the parent container in which the alerting policies to be listed are stored. To retrieve a single alerting policy by name, use the
GetAlertPolicy
operation, instead.filter_ (str) –
If provided, this field specifies the criteria that must be met by alert policies to be included in the response.
For more details, see sorting and filtering.
order_by (str) –
A comma-separated list of fields by which to sort the result. Supports the same set of field references as the
filter
field. Entries can be prefixed with a minus sign to sort by the field in descending order.For more details, see 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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofAlertPolicy
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
update_alert_policy
(alert_policy, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Updates an alerting policy. You can either replace the entire policy with a new one or replace only certain fields in the current alerting policy by specifying the fields to be updated via
updateMask
. Returns the updated alerting policy.Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.AlertPolicyServiceClient() >>> >>> # TODO: Initialize `alert_policy`: >>> alert_policy = {} >>> >>> response = client.update_alert_policy(alert_policy)
- Parameters
alert_policy (Union[dict, AlertPolicy]) –
Required. The updated alerting policy or the updated values for the fields listed in
update_mask
. Ifupdate_mask
is not empty, any fields in this policy that are not inupdate_mask
are ignored.If a dict is provided, it must be of the same form as the protobuf message
AlertPolicy
update_mask (Union[dict, FieldMask]) –
Optional. A list of alerting policy field names. If this field is not empty, each listed field in the existing alerting policy is set to the value of the corresponding field in the supplied policy (
alert_policy
), or to the field’s default value if the field is not in the supplied alerting policy. Fields not listed retain their previous value.Examples of valid field masks include
display_name
,documentation
,documentation.content
,documentation.mime_type
,user_labels
,user_label.nameofkey
,enabled
,conditions
,combiner
, etc.If this field is empty, then the supplied alerting policy replaces the existing policy. It is the same as deleting the existing policy and adding the supplied policy, except for the following:
The new policy will have the same
[ALERT_POLICY_ID]
as the former policy. This gives you continuity with the former policy in your notifications and incidents.Conditions in the new policy will keep their former
[CONDITION_ID]
if the supplied condition includes thename
field with that[CONDITION_ID]
. If the supplied condition omits thename
field, then a new[CONDITION_ID]
is created.
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 be retried using a default configuration.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.
- Returns
A
AlertPolicy
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
class
google.cloud.monitoring_v3.
GroupServiceClient
(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]# The Group API lets you inspect and manage your groups.
A group is a named filter that is used to identify a collection of monitored resources. Groups are typically used to mirror the physical and/or logical topology of the environment. Because group membership is computed dynamically, monitored resources that are started in the future are automatically placed in matching groups. By using a group to name monitored resources in, for example, an alert policy, the target of that alert policy is updated automatically as monitored resources are added and removed from the infrastructure.
Constructor.
- Parameters
(Union[GroupServiceGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.GroupServiceGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.
channel (grpc.Channel) – DEPRECATED. A
Channel
instance through which to make calls. This argument is mutually exclusive withcredentials
; 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_group
(name, group, validate_only=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Creates a new group.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.GroupServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize `group`: >>> group = {} >>> >>> response = client.create_group(name, group)
- Parameters
name (str) – The project in which to create the group. The format is
"projects/{project_id_or_number}"
.A group definition. It is an error to define the
name
field because the system assigns the name.If a dict is provided, it must be of the same form as the protobuf message
Group
validate_only (bool) – If true, validate this request but do not create the group.
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
Group
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
delete_group
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Deletes an existing group.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.GroupServiceClient() >>> >>> name = client.group_path('[PROJECT]', '[GROUP]') >>> >>> client.delete_group(name)
- Parameters
name (str) – The group to delete. The format is
"projects/{project_id_or_number}/groups/{group_id}"
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
enums
= <module 'google.cloud.monitoring_v3.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/monitoring_v3/gapic/enums.py'>#
-
classmethod
from_service_account_file
(filename, *args, **kwargs)[source]# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
classmethod
from_service_account_json
(filename, *args, **kwargs)# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
get_group
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Gets a single group.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.GroupServiceClient() >>> >>> name = client.group_path('[PROJECT]', '[GROUP]') >>> >>> response = client.get_group(name)
- Parameters
name (str) – The group to retrieve. The format is
"projects/{project_id_or_number}/groups/{group_id}"
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
Group
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_group_members
(name, page_size=None, filter_=None, interval=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists the monitored resources that are members of a group.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.GroupServiceClient() >>> >>> name = client.group_path('[PROJECT]', '[GROUP]') >>> >>> # Iterate over all results >>> for element in client.list_group_members(name): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_group_members(name).pages: ... for element in page: ... # process element ... pass
- Parameters
name (str) – The group whose members are listed. The format is
"projects/{project_id_or_number}/groups/{group_id}"
.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.
filter_ (str) –
An optional list filter describing the members to be returned. The filter may reference the type, labels, and metadata of monitored resources that comprise the group. For example, to return only resources representing Compute Engine VM instances, use this filter:
resource.type = "gce_instance"
interval (Union[dict, TimeInterval]) –
An optional time interval for which results should be returned. Only members that were part of the group during the specified interval are included in the response. If no interval is provided then the group membership over the last minute is returned.
If a dict is provided, it must be of the same form as the protobuf message
TimeInterval
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofMonitoredResource
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_groups
(name, children_of_group=None, ancestors_of_group=None, descendants_of_group=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists the existing groups.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.GroupServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # Iterate over all results >>> for element in client.list_groups(name): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_groups(name).pages: ... for element in page: ... # process element ... pass
- Parameters
name (str) – The project whose groups are to be listed. The format is
"projects/{project_id_or_number}"
.children_of_group (str) – A group name:
"projects/{project_id_or_number}/groups/{group_id}"
. Returns groups whoseparentName
field contains the group name. If no groups have this parent, the results are empty.ancestors_of_group (str) – A group name:
"projects/{project_id_or_number}/groups/{group_id}"
. Returns groups that are ancestors of the specified group. The groups are returned in order, starting with the immediate parent and ending with the most distant ancestor. If the specified group has no immediate parent, the results are empty.descendants_of_group (str) – A group name:
"projects/{project_id_or_number}/groups/{group_id}"
. Returns the descendants of the specified group. This is a superset of the results returned by thechildrenOfGroup
filter, and includes children-of-children, and so forth.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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofGroup
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
update_group
(group, validate_only=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Updates an existing group. You can change any group attributes except
name
.Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.GroupServiceClient() >>> >>> # TODO: Initialize `group`: >>> group = {} >>> >>> response = client.update_group(group)
- Parameters
The new definition of the group. All fields of the existing group, excepting
name
, are replaced with the corresponding fields of this group.If a dict is provided, it must be of the same form as the protobuf message
Group
validate_only (bool) – If true, validate this request but do not update the existing group.
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
Group
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
class
google.cloud.monitoring_v3.
MetricServiceClient
(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]# Manages metric descriptors, monitored resource descriptors, and time series data.
Constructor.
- Parameters
(Union[MetricServiceGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.MetricServiceGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.
channel (grpc.Channel) – DEPRECATED. A
Channel
instance through which to make calls. This argument is mutually exclusive withcredentials
; 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_metric_descriptor
(name, metric_descriptor, retry=<object object>, timeout=<object object>, metadata=None)[source]# Creates a new metric descriptor. User-created metric descriptors define custom metrics.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize `metric_descriptor`: >>> metric_descriptor = {} >>> >>> response = client.create_metric_descriptor(name, metric_descriptor)
- Parameters
name (str) – The project on which to execute the request. The format is
"projects/{project_id_or_number}"
.metric_descriptor (Union[dict, MetricDescriptor]) –
The new custom metric descriptor.
If a dict is provided, it must be of the same form as the protobuf message
MetricDescriptor
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
MetricDescriptor
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
create_time_series
(name, time_series, retry=<object object>, timeout=<object object>, metadata=None)[source]# Creates or adds data to one or more time series. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize `time_series`: >>> time_series = [] >>> >>> client.create_time_series(name, time_series)
- Parameters
name (str) – The project on which to execute the request. The format is
"projects/{project_id_or_number}"
.time_series (list[Union[dict, TimeSeries]]) –
The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than any other point in its time series. Each
TimeSeries
value must fully specify a unique time series by supplying all label values for the metric and the monitored resource.If a dict is provided, it must be of the same form as the protobuf message
TimeSeries
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
delete_metric_descriptor
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Deletes a metric descriptor. Only user-created custom metrics can be deleted.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.metric_descriptor_path('[PROJECT]', '[METRIC_DESCRIPTOR]') >>> >>> client.delete_metric_descriptor(name)
- Parameters
name (str) – The metric descriptor on which to execute the request. The format is
"projects/{project_id_or_number}/metricDescriptors/{metric_id}"
. An example of{metric_id}
is:"custom.googleapis.com/my_test_metric"
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
enums
= <module 'google.cloud.monitoring_v3.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/monitoring_v3/gapic/enums.py'>#
-
classmethod
from_service_account_file
(filename, *args, **kwargs)[source]# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
classmethod
from_service_account_json
(filename, *args, **kwargs)# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
get_metric_descriptor
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Gets a single metric descriptor. This method does not require a Stackdriver account.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.metric_descriptor_path('[PROJECT]', '[METRIC_DESCRIPTOR]') >>> >>> response = client.get_metric_descriptor(name)
- Parameters
name (str) – The metric descriptor on which to execute the request. The format is
"projects/{project_id_or_number}/metricDescriptors/{metric_id}"
. An example value of{metric_id}
is"compute.googleapis.com/instance/disk/read_bytes_count"
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
MetricDescriptor
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
get_monitored_resource_descriptor
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Gets a single monitored resource descriptor. This method does not require a Stackdriver account.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.monitored_resource_descriptor_path('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]') >>> >>> response = client.get_monitored_resource_descriptor(name)
- Parameters
name (str) – The monitored resource descriptor to get. The format is
"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"
. The{resource_type}
is a predefined type, such ascloudsql_database
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
MonitoredResourceDescriptor
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_metric_descriptors
(name, filter_=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists metric descriptors that match a filter. This method does not require a Stackdriver account.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # Iterate over all results >>> for element in client.list_metric_descriptors(name): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_metric_descriptors(name).pages: ... for element in page: ... # process element ... pass
- Parameters
name (str) – The project on which to execute the request. The format is
"projects/{project_id_or_number}"
.filter_ (str) –
If this field is empty, all custom and system-defined metric descriptors are returned. Otherwise, the filter specifies which metric descriptors are to be returned. For example, the following filter matches all custom metrics:
metric.type = starts_with("custom.googleapis.com/")
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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofMetricDescriptor
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_monitored_resource_descriptors
(name, filter_=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # Iterate over all results >>> for element in client.list_monitored_resource_descriptors(name): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_monitored_resource_descriptors(name).pages: ... for element in page: ... # process element ... pass
- Parameters
name (str) – The project on which to execute the request. The format is
"projects/{project_id_or_number}"
.filter_ (str) –
An optional filter describing the descriptors to be returned. The filter can reference the descriptor’s type and labels. For example, the following filter returns only Google Compute Engine descriptors that have an
id
label:resource.type = starts_with("gce_") AND resource.label:id
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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofMonitoredResourceDescriptor
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_time_series
(name, filter_, interval, view, aggregation=None, order_by=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists time series that match a filter. This method does not require a Stackdriver account.
Example
>>> from google.cloud import monitoring_v3 >>> from google.cloud.monitoring_v3 import enums >>> >>> client = monitoring_v3.MetricServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize `filter_`: >>> filter_ = '' >>> >>> # TODO: Initialize `interval`: >>> interval = {} >>> >>> # TODO: Initialize `view`: >>> view = enums.ListTimeSeriesRequest.TimeSeriesView.FULL >>> >>> # Iterate over all results >>> for element in client.list_time_series(name, filter_, interval, view): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_time_series(name, filter_, interval, view).pages: ... for element in page: ... # process element ... pass
- Parameters
name (str) – The project on which to execute the request. The format is “projects/{project_id_or_number}”.
filter_ (str) –
A monitoring filter that specifies which time series should be returned. The filter must specify a single metric type, and can additionally specify metric labels and other information. For example:
metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND metric.label.instance_name = "my-instance-name"
interval (Union[dict, TimeInterval]) –
The time interval for which results should be returned. Only time series that contain data points in the specified interval are included in the response.
If a dict is provided, it must be of the same form as the protobuf message
TimeInterval
view (TimeSeriesView) – Specifies which information is returned about the time series.
aggregation (Union[dict, Aggregation]) –
By default, the raw time series data is returned. Use this field to combine multiple time series for different views of the data.
If a dict is provided, it must be of the same form as the protobuf message
Aggregation
order_by (str) – Unsupported: must be left blank. The points in each time series are returned in reverse time order.
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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofTimeSeries
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
classmethod
metric_descriptor_path
(project, metric_descriptor)[source]# Return a fully-qualified metric_descriptor string.
-
class
google.cloud.monitoring_v3.
NotificationChannelServiceClient
(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]# The Notification Channel API provides access to configuration that controls how messages related to incidents are sent.
Constructor.
- Parameters
(Union[NotificationChannelServiceGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.NotificationChannelServiceGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.
channel (grpc.Channel) – DEPRECATED. A
Channel
instance through which to make calls. This argument is mutually exclusive withcredentials
; 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
(name, notification_channel, retry=<object object>, timeout=<object object>, metadata=None)[source]# Creates a new notification channel, representing a single notification endpoint such as an email address, SMS number, or PagerDuty service.
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
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 be retried using a default configuration.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.
- Returns
A
NotificationChannel
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
delete_notification_channel
(name, force=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Deletes a notification channel.
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
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 be retried using a default configuration.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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
enums
= <module 'google.cloud.monitoring_v3.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/monitoring_v3/gapic/enums.py'>#
-
classmethod
from_service_account_file
(filename, *args, **kwargs)[source]# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
classmethod
from_service_account_json
(filename, *args, **kwargs)# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
get_notification_channel
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# 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.
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
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 be retried using a default configuration.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.
- Returns
A
NotificationChannel
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
get_notification_channel_descriptor
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Gets a single channel descriptor. The descriptor indicates which fields are expected / permitted for a notification channel of the given type.
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
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 be retried using a default configuration.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.
- Returns
A
NotificationChannelDescriptor
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
get_notification_channel_verification_code
(name, expire_time=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# 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.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.NotificationChannelServiceClient() >>> >>> name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]') >>> >>> response = client.get_notification_channel_verification_code(name)
- Parameters
name (str) – 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.
expire_time (Union[dict, Timestamp]) –
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).
If a dict is provided, it must be of the same form as the protobuf message
Timestamp
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
GetNotificationChannelVerificationCodeResponse
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_notification_channel_descriptors
(name, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists the descriptors for supported channel types. The use of descriptors makes it possible for new channel types to be dynamically added.
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
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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofNotificationChannelDescriptor
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_notification_channels
(name, filter_=None, order_by=None, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists the notification channels that have been created for the project.
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
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 theGetNotificationChannel
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.
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.
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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofNotificationChannel
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
classmethod
notification_channel_descriptor_path
(project, channel_descriptor)[source]# Return a fully-qualified notification_channel_descriptor string.
-
classmethod
notification_channel_path
(project, notification_channel)[source]# Return a fully-qualified notification_channel string.
-
send_notification_channel_verification_code
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Causes a verification code to be delivered to the channel. The code can then be supplied in
VerifyNotificationChannel
to verify the channel.Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.NotificationChannelServiceClient() >>> >>> name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]') >>> >>> client.send_notification_channel_verification_code(name)
- Parameters
name (str) – The notification channel to which to send a verification code.
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
update_notification_channel
(notification_channel, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Updates a notification channel. Fields not specified in the field mask remain unchanged.
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
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 be retried using a default configuration.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.
- Returns
A
NotificationChannel
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
verify_notification_channel
(name, code, retry=<object object>, timeout=<object object>, metadata=None)[source]# Verifies a
NotificationChannel
by proving receipt of the code delivered to the channel as a result of callingSendNotificationChannelVerificationCode
.Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.NotificationChannelServiceClient() >>> >>> name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]') >>> >>> # TODO: Initialize `code`: >>> code = '' >>> >>> response = client.verify_notification_channel(name, code)
- Parameters
name (str) – The notification channel to verify.
code (str) – 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 viaGetNotificationChannelVerificationCode
. 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).retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
NotificationChannel
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
class
google.cloud.monitoring_v3.
UptimeCheckServiceClient
(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]# The UptimeCheckService API is used to manage (list, create, delete, edit) uptime check configurations in the Stackdriver Monitoring product. An uptime check is a piece of configuration that determines which resources and services to monitor for availability. These configurations can also be configured interactively by navigating to the [Cloud Console] (http://console.cloud.google.com), selecting the appropriate project, clicking on “Monitoring” on the left-hand side to navigate to Stackdriver, and then clicking on “Uptime”.
Constructor.
- Parameters
(Union[UptimeCheckServiceGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.UptimeCheckServiceGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.
channel (grpc.Channel) – DEPRECATED. A
Channel
instance through which to make calls. This argument is mutually exclusive withcredentials
; 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_uptime_check_config
(parent, uptime_check_config, retry=<object object>, timeout=<object object>, metadata=None)[source]# Creates a new uptime check configuration.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.UptimeCheckServiceClient() >>> >>> parent = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize `uptime_check_config`: >>> uptime_check_config = {} >>> >>> response = client.create_uptime_check_config(parent, uptime_check_config)
- Parameters
parent (str) – The project in which to create the uptime check. The format is
projects/[PROJECT_ID]
.uptime_check_config (Union[dict, UptimeCheckConfig]) –
The new uptime check configuration.
If a dict is provided, it must be of the same form as the protobuf message
UptimeCheckConfig
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
UptimeCheckConfig
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
delete_uptime_check_config
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Deletes an uptime check configuration. Note that this method will fail if the uptime check configuration is referenced by an alert policy or other dependent configs that would be rendered invalid by the deletion.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.UptimeCheckServiceClient() >>> >>> name = client.uptime_check_config_path('[PROJECT]', '[UPTIME_CHECK_CONFIG]') >>> >>> client.delete_uptime_check_config(name)
- Parameters
name (str) – The uptime check configuration to delete. The format is
projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
enums
= <module 'google.cloud.monitoring_v3.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/monitoring_v3/gapic/enums.py'>#
-
classmethod
from_service_account_file
(filename, *args, **kwargs)[source]# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
classmethod
from_service_account_json
(filename, *args, **kwargs)# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
get_uptime_check_config
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Gets a single uptime check configuration.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.UptimeCheckServiceClient() >>> >>> name = client.uptime_check_config_path('[PROJECT]', '[UPTIME_CHECK_CONFIG]') >>> >>> response = client.get_uptime_check_config(name)
- Parameters
name (str) – The uptime check configuration to retrieve. The format is
projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
.retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.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.
- Returns
A
UptimeCheckConfig
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_uptime_check_configs
(parent, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Lists the existing valid uptime check configurations for the project, leaving out any invalid configurations.
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.UptimeCheckServiceClient() >>> >>> parent = client.project_path('[PROJECT]') >>> >>> # Iterate over all results >>> for element in client.list_uptime_check_configs(parent): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_uptime_check_configs(parent).pages: ... for element in page: ... # process element ... pass
- Parameters
parent (str) – The project whose uptime check configurations are listed. The format is
projects/[PROJECT_ID]
.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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofUptimeCheckConfig
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
list_uptime_check_ips
(page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Returns the list of IPs that checkers run from
Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.UptimeCheckServiceClient() >>> >>> # Iterate over all results >>> for element in client.list_uptime_check_ips(): ... # process element ... pass >>> >>> >>> # Alternatively: >>> >>> # Iterate over results one page at a time >>> for page in client.list_uptime_check_ips().pages: ... for element in page: ... # process element ... pass
- Parameters
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 be retried using a default configuration.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.
- Returns
A
PageIterator
instance. An iterable ofUptimeCheckIp
instances. You can also iterate over the pages of the response using its pages property.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
update_uptime_check_config
(uptime_check_config, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Updates an uptime check configuration. You can either replace the entire configuration with a new one or replace only certain fields in the current configuration by specifying the fields to be updated via
"updateMask"
. Returns the updated configuration.Example
>>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.UptimeCheckServiceClient() >>> >>> # TODO: Initialize `uptime_check_config`: >>> uptime_check_config = {} >>> >>> response = client.update_uptime_check_config(uptime_check_config)
- Parameters
uptime_check_config (Union[dict, UptimeCheckConfig]) –
Required. If an
"updateMask"
has been specified, this field gives the values for the set of fields mentioned in the"updateMask"
. If an"updateMask"
has not been given, this uptime check configuration replaces the current configuration. If a field is mentioned in"updateMask"
but the corresonding field is omitted in this partial uptime check configuration, it has the effect of deleting/clearing the field from the configuration on the server.The following fields can be updated:
display_name
,http_check
,tcp_check
,timeout
,content_matchers
, andselected_regions
.If a dict is provided, it must be of the same form as the protobuf message
UptimeCheckConfig
update_mask (Union[dict, FieldMask]) –
Optional. If present, only the listed fields in the current uptime check configuration are updated with values from the new configuration. If this field is empty, then the current configuration is completely replaced with the new configuration.
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 be retried using a default configuration.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.
- Returns
A
UptimeCheckConfig
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.