AlertPolicyServiceClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
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 <https://cloud.google.com/monitoring/docs/>
, which can be
reached by clicking the "Monitoring" tab in Cloud
Console <https://console.cloud.google.com/>
.
Methods
AlertPolicyServiceClient
AlertPolicyServiceClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Constructor.
Parameters | |
---|---|
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
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 |
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 |
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. |
alert_policy_condition_path
alert_policy_condition_path(project, alert_policy, condition)
Return a fully-qualified alert_policy_condition string.
alert_policy_path
alert_policy_path(project, alert_policy)
Return a fully-qualified alert_policy string.
create_alert_policy
create_alert_policy(name, alert_policy, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates a new alerting policy.
.. rubric:: 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 | Description |
name |
str
The project in which to create the alerting policy. The format is |
alert_policy |
Union[dict, AlertPolicy]
The requested alerting policy. You should omit the |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
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
delete_alert_policy(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Deletes an alerting policy.
.. rubric:: 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 | Description |
name |
str
The alerting policy to delete. The format is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] For more information, see |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
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. |
from_service_account_file
from_service_account_file(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Parameter | |
---|---|
Name | Description |
filename |
str
The path to the service account private key json file. |
Returns | |
---|---|
Type | Description |
AlertPolicyServiceClient | The 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 | |
---|---|
Name | Description |
filename |
str
The path to the service account private key json file. |
Returns | |
---|---|
Type | Description |
AlertPolicyServiceClient | The constructed client. |
get_alert_policy
get_alert_policy(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Gets a single alerting policy.
.. rubric:: 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 | Description |
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 |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
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
list_alert_policies(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 existing alerting policies for the project.
.. rubric:: 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 | Description |
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 |
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 |
order_by |
str
A comma-separated list of fields by which to sort the result. Supports the same set of field references as the |
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 |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
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. |
project_path
project_path(project)
Return a fully-qualified project string.
update_alert_policy
update_alert_policy(alert_policy, update_mask=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
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.
.. rubric:: 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 | |
---|---|
Name | Description |
alert_policy |
Union[dict, AlertPolicy]
Required. The updated alerting policy or the updated values for the fields listed in |
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 ( |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
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. |