Reference documentation and code samples for the Cloud Monitoring V3 API class Google::Cloud::Monitoring::V3::AlertPolicyService::Client.
Client for the AlertPolicyService service.
The AlertPolicyService API is used to manage (list, create, delete, edit) alert policies in Cloud 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 Cloud Monitoring, which can be reached by clicking the "Monitoring" tab in Cloud console.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the AlertPolicyService Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all AlertPolicyService clients ::Google::Cloud::Monitoring::V3::AlertPolicyService::Client.configure do |config| config.timeout = 10.0 end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the AlertPolicyService Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#create_alert_policy
def create_alert_policy(request, options = nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
def create_alert_policy(name: nil, alert_policy: nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
Creates a new alerting policy.
Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
def create_alert_policy(request, options = nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
create_alert_policy
via a request object, either of type
CreateAlertPolicyRequest or an equivalent Hash.
- request (::Google::Cloud::Monitoring::V3::CreateAlertPolicyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_alert_policy(name: nil, alert_policy: nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
create_alert_policy
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The
project in which
to create the alerting policy. The format is:
projects/[PROJECT_ID_OR_NUMBER]
Note that this field names the parent container in which the alerting policy will be written, not the name of the created policy. |name| must be a host project of a Metrics Scope, otherwise INVALID_ARGUMENT error will return. 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/[ALERT_POLICY_ID]
, identifying the policy in the container. -
alert_policy (::Google::Cloud::Monitoring::V3::AlertPolicy, ::Hash) — Required. 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.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Monitoring::V3::AlertPolicy)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/monitoring/v3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Monitoring::V3::AlertPolicyService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Monitoring::V3::CreateAlertPolicyRequest.new # Call the create_alert_policy method. result = client.create_alert_policy request # The returned object is of type Google::Cloud::Monitoring::V3::AlertPolicy. p result
#delete_alert_policy
def delete_alert_policy(request, options = nil) -> ::Google::Protobuf::Empty
def delete_alert_policy(name: nil) -> ::Google::Protobuf::Empty
Deletes an alerting policy.
Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
def delete_alert_policy(request, options = nil) -> ::Google::Protobuf::Empty
delete_alert_policy
via a request object, either of type
DeleteAlertPolicyRequest or an equivalent Hash.
- request (::Google::Cloud::Monitoring::V3::DeleteAlertPolicyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_alert_policy(name: nil) -> ::Google::Protobuf::Empty
delete_alert_policy
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The alerting policy to delete. The format is:
projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
For more information, see AlertPolicy.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Protobuf::Empty)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/monitoring/v3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Monitoring::V3::AlertPolicyService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Monitoring::V3::DeleteAlertPolicyRequest.new # Call the delete_alert_policy method. result = client.delete_alert_policy request # The returned object is of type Google::Protobuf::Empty. p result
#get_alert_policy
def get_alert_policy(request, options = nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
def get_alert_policy(name: nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
Gets a single alerting policy.
def get_alert_policy(request, options = nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
get_alert_policy
via a request object, either of type
GetAlertPolicyRequest or an equivalent Hash.
- request (::Google::Cloud::Monitoring::V3::GetAlertPolicyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_alert_policy(name: nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
get_alert_policy
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) —
Required. The alerting policy to retrieve. The format is:
projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Monitoring::V3::AlertPolicy)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/monitoring/v3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Monitoring::V3::AlertPolicyService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Monitoring::V3::GetAlertPolicyRequest.new # Call the get_alert_policy method. result = client.get_alert_policy request # The returned object is of type Google::Cloud::Monitoring::V3::AlertPolicy. p result
#initialize
def initialize() { |config| ... } -> Client
Create a new AlertPolicyService client object.
- (config) — Configure the AlertPolicyService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Monitoring::V3::AlertPolicyService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Monitoring::V3::AlertPolicyService::Client.new do |config| config.timeout = 10.0 end
#list_alert_policies
def list_alert_policies(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::AlertPolicy>
def list_alert_policies(name: nil, filter: nil, order_by: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::AlertPolicy>
Lists the existing alerting policies for the workspace.
def list_alert_policies(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::AlertPolicy>
list_alert_policies
via a request object, either of type
ListAlertPoliciesRequest or an equivalent Hash.
- request (::Google::Cloud::Monitoring::V3::ListAlertPoliciesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_alert_policies(name: nil, filter: nil, order_by: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::AlertPolicy>
list_alert_policies
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The
project whose
alert policies are to be listed. The format is:
projects/[PROJECT_ID_OR_NUMBER]
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 (::String) — Optional. 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 (::String) — Optional. 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 (::Integer) — Optional. The maximum number of results to return in a single response.
-
page_token (::String) — Optional. If this field is not empty then it must contain the
nextPageToken
value returned by a previous call to this method. Using this field causes the method to return more results from the previous method call.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::AlertPolicy>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::AlertPolicy>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/monitoring/v3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Monitoring::V3::AlertPolicyService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Monitoring::V3::ListAlertPoliciesRequest.new # Call the list_alert_policies method. result = client.list_alert_policies request # The returned object is of type Gapic::PagedEnumerable. You can iterate # over elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Cloud::Monitoring::V3::AlertPolicy. p item end
#logger
def logger() -> Logger
The logger used for request/response debug logging.
- (Logger)
#universe_domain
def universe_domain() -> String
The effective universe domain
- (String)
#update_alert_policy
def update_alert_policy(request, options = nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
def update_alert_policy(update_mask: nil, alert_policy: nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
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.
Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
def update_alert_policy(request, options = nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
update_alert_policy
via a request object, either of type
UpdateAlertPolicyRequest or an equivalent Hash.
- request (::Google::Cloud::Monitoring::V3::UpdateAlertPolicyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_alert_policy(update_mask: nil, alert_policy: nil) -> ::Google::Cloud::Monitoring::V3::AlertPolicy
update_alert_policy
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
update_mask (::Google::Protobuf::FieldMask, ::Hash) —
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.
- The new policy will have the same
-
alert_policy (::Google::Cloud::Monitoring::V3::AlertPolicy, ::Hash) — 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.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Monitoring::V3::AlertPolicy)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/monitoring/v3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Monitoring::V3::AlertPolicyService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Monitoring::V3::UpdateAlertPolicyRequest.new # Call the update_alert_policy method. result = client.update_alert_policy request # The returned object is of type Google::Cloud::Monitoring::V3::AlertPolicy. p result