Class: Fog::Google::Monitoring::MetricDescriptors

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/google/models/monitoring/metric_descriptors.rb

Instance Method Summary collapse

Instance Method Details

#all(filter: nil, page_size: nil, page_token: nil) ⇒ Array<Fog::Google::Monitoring::MetricDescriptor>

Lists all Metric Descriptors.

Parameters:

  • filter (String) (defaults to: nil)

    Monitoring filter specifying which metric descriptors are to be returned. @see cloud.google.com/monitoring/api/v3/filters filter documentation

  • page_size (String) (defaults to: nil)

    Maximum number of metric descriptors per page. Used for pagination.

  • page_token (String) (defaults to: nil)

    The pagination token, which is used to page through large result sets.

Returns:



18
19
20
21
22
23
24
25
26
# File 'lib/fog/google/models/monitoring/metric_descriptors.rb', line 18

def all(filter: nil, page_size: nil, page_token: nil)
  data = service.list_metric_descriptors(
    :filter => filter,
    :page_size => page_size,
    :page_token => page_token
  ).to_h[:metric_descriptors] || []

  load(data)
end

#get(metric_type) ⇒ Fog::Google::Monitoring::MetricDescriptor

Get a Metric Descriptors.

Parameters:

  • metric_type (String)

    Metric type. For example, “custom.googleapis.com/test-metric”

Returns:



33
34
35
36
37
38
39
# File 'lib/fog/google/models/monitoring/metric_descriptors.rb', line 33

def get(metric_type)
  data = service.get_metric_descriptor(metric_type).to_h
  new(data)
rescue ::Google::Apis::ClientError => e
  raise e unless e.status_code == 404
  nil
end