Cloud Monitoring V3 API - Class Google::Cloud::Monitoring::V3::GroupService::Client (v0.7.1)

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

Client for the GroupService service.

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.

Inherits

  • Object

Methods

.configure

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

Configure the GroupService 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 GroupService clients
::Google::Cloud::Monitoring::V3::GroupService::Client.configure do |config|
  config.timeout = 10.0
end

#configure

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

Configure the GroupService 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_group

def create_group(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Group
def create_group(name: nil, group: nil, validate_only: nil) -> ::Google::Cloud::Monitoring::V3::Group

Creates a new group.

Overloads
def create_group(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Group
Pass arguments to create_group via a request object, either of type CreateGroupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::CreateGroupRequest, ::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_group(name: nil, group: nil, validate_only: nil) -> ::Google::Cloud::Monitoring::V3::Group
Pass arguments to create_group 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
  • name (::String) —

    Required. The project in which to create the group. The format is:

    projects/[PROJECT_ID_OR_NUMBER]
    
  • group (::Google::Cloud::Monitoring::V3::Group, ::Hash) — Required. A group definition. It is an error to define the name field because the system assigns the name.
  • validate_only (::Boolean) — If true, validate this request but do not create the group.
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::GroupService::Client.new

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

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

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

#delete_group

def delete_group(request, options = nil) -> ::Google::Protobuf::Empty
def delete_group(name: nil, recursive: nil) -> ::Google::Protobuf::Empty

Deletes an existing group.

Overloads
def delete_group(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_group via a request object, either of type DeleteGroupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::DeleteGroupRequest, ::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_group(name: nil, recursive: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_group 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
  • name (::String) —

    Required. The group to delete. The format is:

    projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
    
  • recursive (::Boolean) — If this field is true, then the request means to delete a group with all its descendants. Otherwise, the request means to delete a group only when it has no descendants. The default value is false.
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::GroupService::Client.new

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

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

# The returned object is of type Google::Protobuf::Empty.
p result

#get_group

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

Gets a single group.

Overloads
def get_group(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Group
Pass arguments to get_group via a request object, either of type Google::Cloud::Monitoring::V3::GetGroupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::GetGroupRequest, ::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_group(name: nil) -> ::Google::Cloud::Monitoring::V3::Group
Pass arguments to get_group 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 group to retrieve. The format is:

    projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_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::GroupService::Client.new

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

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

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

#initialize

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

Create a new GroupService client object.

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

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

#list_group_members

def list_group_members(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Api::MonitoredResource>
def list_group_members(name: nil, page_size: nil, page_token: nil, filter: nil, interval: nil) -> ::Gapic::PagedEnumerable<::Google::Api::MonitoredResource>

Lists the monitored resources that are members of a group.

Overloads
def list_group_members(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Api::MonitoredResource>
Pass arguments to list_group_members via a request object, either of type ListGroupMembersRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::ListGroupMembersRequest, ::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_group_members(name: nil, page_size: nil, page_token: nil, filter: nil, interval: nil) -> ::Gapic::PagedEnumerable<::Google::Api::MonitoredResource>
Pass arguments to list_group_members 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
  • name (::String) —

    Required. The group whose members are listed. The format is:

    projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
    
  • page_size (::Integer) — A positive number that is the maximum number of results to return.
  • page_token (::String) — If this field is not empty then it must contain the next_page_token value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
  • filter (::String) —

    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 (::Google::Cloud::Monitoring::V3::TimeInterval, ::Hash) — 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.
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::GroupService::Client.new

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

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

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Api::MonitoredResource.
  p response
end

#list_groups

def list_groups(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Group>
def list_groups(name: nil, children_of_group: nil, ancestors_of_group: nil, descendants_of_group: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Group>

Lists the existing groups.

Overloads
def list_groups(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Group>
Pass arguments to list_groups via a request object, either of type ListGroupsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::ListGroupsRequest, ::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_groups(name: nil, children_of_group: nil, ancestors_of_group: nil, descendants_of_group: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Group>
Pass arguments to list_groups 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
  • name (::String) —

    Required. The project whose groups are to be listed. The format is:

    projects/[PROJECT_ID_OR_NUMBER]
    
  • children_of_group (::String) — A group name. The format is:

    projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
    

    Returns groups whose parent_name field contains the group name. If no groups have this parent, the results are empty.

  • ancestors_of_group (::String) — A group name. The format is:

    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 (::String) — A group name. The format is:

    projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
    

    Returns the descendants of the specified group. This is a superset of the results returned by the children_of_group filter, and includes children-of-children, and so forth.

  • page_size (::Integer) — A positive number that is the maximum number of results to return.
  • page_token (::String) — If this field is not empty then it must contain the next_page_token value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
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::GroupService::Client.new

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

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

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Monitoring::V3::Group.
  p response
end

#update_group

def update_group(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Group
def update_group(group: nil, validate_only: nil) -> ::Google::Cloud::Monitoring::V3::Group

Updates an existing group. You can change any group attributes except name.

Overloads
def update_group(request, options = nil) -> ::Google::Cloud::Monitoring::V3::Group
Pass arguments to update_group via a request object, either of type UpdateGroupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Monitoring::V3::UpdateGroupRequest, ::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_group(group: nil, validate_only: nil) -> ::Google::Cloud::Monitoring::V3::Group
Pass arguments to update_group 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
  • group (::Google::Cloud::Monitoring::V3::Group, ::Hash) — Required. The new definition of the group. All fields of the existing group, excepting name, are replaced with the corresponding fields of this group.
  • validate_only (::Boolean) — If true, validate this request but do not update the existing group.
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::GroupService::Client.new

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

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

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