Cloud Monitoring V3 API - Class Google::Cloud::Monitoring::V3::SnoozeService::Client (v1.0.0)

Reference documentation and code samples for the Cloud Monitoring V3 API class Google::Cloud::Monitoring::V3::SnoozeService::Client.

Client for the SnoozeService service.

The SnoozeService API is used to temporarily prevent an alert policy from generating alerts. A Snooze is a description of the criteria under which one or more alert policies should not fire alerts for the specified duration.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the SnoozeService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all SnoozeService clients
::Google::Cloud::Monitoring::V3::SnoozeService::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the SnoozeService 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.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_snooze

def create_snooze(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Snooze
def create_snooze(parent: nil, snooze: nil) -> ::Google::Cloud::Monitoring::V3::Snooze

Creates a Snooze that will prevent alerts, which match the provided criteria, from being opened. The Snooze applies for a specific time interval.

Overloads
def create_snooze(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Snooze
Pass arguments to create_snooze via a request object, either of type CreateSnoozeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::CreateSnoozeRequest, ::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_snooze(parent: nil, snooze: nil) -> ::Google::Cloud::Monitoring::V3::Snooze
Pass arguments to create_snooze 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).
Parameters
  • parent (::String) —

    Required. The project in which a Snooze should be created. The format is:

    projects/[PROJECT_ID_OR_NUMBER]
    
  • snooze (::Google::Cloud::Monitoring::V3::Snooze, ::Hash) — Required. The Snooze to create. Omit the name field, as it will be filled in by the API.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::V3::CreateSnoozeRequest.new

# Call the create_snooze method.
result = client.create_snooze request

# The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
p result

#get_snooze

def get_snooze(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Snooze
def get_snooze(name: nil) -> ::Google::Cloud::Monitoring::V3::Snooze

Retrieves a Snooze by name.

Overloads
def get_snooze(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Snooze
Pass arguments to get_snooze via a request object, either of type GetSnoozeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::GetSnoozeRequest, ::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_snooze(name: nil) -> ::Google::Cloud::Monitoring::V3::Snooze
Pass arguments to get_snooze 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).
Parameter
  • name (::String) —

    Required. The ID of the Snooze to retrieve. The format is:

    projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
    
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::V3::GetSnoozeRequest.new

# Call the get_snooze method.
result = client.get_snooze request

# The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new SnoozeService client object.

Yields
  • (config) — Configure the SnoozeService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Monitoring::V3::SnoozeService::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Monitoring::V3::SnoozeService::Client.new do |config|
  config.timeout = 10.0
end

#list_snoozes

def list_snoozes(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Snooze>
def list_snoozes(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Snooze>

Lists the Snoozes associated with a project. Can optionally pass in filter, which specifies predicates to match Snoozes.

Overloads
def list_snoozes(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Snooze>
Pass arguments to list_snoozes via a request object, either of type ListSnoozesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::ListSnoozesRequest, ::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_snoozes(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Snooze>
Pass arguments to list_snoozes 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).
Parameters
  • parent (::String) —

    Required. The project whose Snoozes should be listed. The format is:

    projects/[PROJECT_ID_OR_NUMBER]
    
  • filter (::String) —

    Optional. Optional filter to restrict results to the given criteria. The following fields are supported.

    • interval.start_time
    • interval.end_time

    For example:

    ```
    interval.start_time > "2022-03-11T00:00:00-08:00" AND
        interval.end_time < "2022-03-12T00:00:00-08:00"
    ```
    
  • page_size (::Integer) — Optional. The maximum number of results to return for a single query. The server may further constrain the maximum number of results returned in a single page. The value should be in the range [1, 1000]. If the value given is outside this range, the server will decide the number of results to be returned.
  • page_token (::String) — Optional. The next_page_token from a previous call to ListSnoozesRequest to get the next page of results.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::V3::ListSnoozesRequest.new

# Call the list_snoozes method.
result = client.list_snoozes 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::Snooze.
  p item
end

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)

#update_snooze

def update_snooze(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Snooze
def update_snooze(snooze: nil, update_mask: nil) -> ::Google::Cloud::Monitoring::V3::Snooze

Updates a Snooze, identified by its name, with the parameters in the given Snooze object.

Overloads
def update_snooze(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Snooze
Pass arguments to update_snooze via a request object, either of type UpdateSnoozeRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::UpdateSnoozeRequest, ::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_snooze(snooze: nil, update_mask: nil) -> ::Google::Cloud::Monitoring::V3::Snooze
Pass arguments to update_snooze 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).
Parameters
  • snooze (::Google::Cloud::Monitoring::V3::Snooze, ::Hash) — Required. The Snooze to update. Must have the name field present.
  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — Required. The fields to update.

    For each field listed in update_mask:

    • If the Snooze object supplied in the UpdateSnoozeRequest has a value for that field, the value of the field in the existing Snooze will be set to the value of the field in the supplied Snooze.
    • If the field does not have a value in the supplied Snooze, the field in the existing Snooze is set to its default value.

    Fields not listed retain their existing value.

    The following are the field names that are accepted in update_mask:

    • display_name
    • interval.start_time
    • interval.end_time

    That said, the start time and end time of the Snooze determines which fields can legally be updated. Before attempting an update, users should consult the documentation for UpdateSnoozeRequest, which talks about which fields can be updated.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/monitoring/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Monitoring::V3::UpdateSnoozeRequest.new

# Call the update_snooze method.
result = client.update_snooze request

# The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
p result