Method: Google::Cloud::Monitoring::V3::GroupService::Client#list_groups

Defined in:
lib/google/cloud/monitoring/v3/group_service/client.rb

#list_groups(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Group> #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.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #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) (defaults to: nil)

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

      projects/[PROJECT_ID_OR_NUMBER]
      
    • children_of_group (::String) (defaults to: nil)

      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) (defaults to: nil)

      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) (defaults to: nil)

      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) (defaults to: nil)

      A positive number that is the maximum number of results to return.

    • page_token (::String) (defaults to: nil)

      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.

[View source]

268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/google/cloud/monitoring/v3/group_service/client.rb', line 268

def list_groups request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::ListGroupsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_groups..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_groups.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_groups.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @group_service_stub.call_rpc :list_groups, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @group_service_stub, :list_groups, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end