Sha256: 029bf8a4e0ecf3187ca9abc978ffae09631f4b4a4006a89538635cd8ce8724ea

Contents?: true

Size: 1.57 KB

Versions: 41

Compression:

Stored size: 1.57 KB

Contents

require "fog/core/collection"
require "fog/google/models/monitoring/metric_descriptor"

module Fog
  module Google
    class Monitoring
      class MetricDescriptors < Fog::Collection
        model Fog::Google::Monitoring::MetricDescriptor

        ##
        # Lists all Metric Descriptors.
        #
        # @param filter [String] Monitoring filter specifying which metric descriptors are to be returned.
        #   @see https://cloud.google.com/monitoring/api/v3/filters filter documentation
        # @param page_size [String] Maximum number of metric descriptors per page. Used for pagination.
        # @param page_token [String] The pagination token, which is used to page through large result sets.
        # @return [Array<Fog::Google::Monitoring::MetricDescriptor>] List of Metric Descriptors.
        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 a Metric Descriptors.
        #
        # @param metric_type [String] Metric type. For example, "custom.googleapis.com/test-metric"
        # @return [Fog::Google::Monitoring::MetricDescriptor] A Metric Descriptor.
        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
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
fog-google-1.24.1 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.24.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.23.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.22.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.21.1 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.21.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.20.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.19.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.18.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.17.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.16.1 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.16.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.15.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.14.0 lib/fog/google/models/monitoring/metric_descriptors.rb
gitlab-fog-google-1.14.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.13.0 lib/fog/google/models/monitoring/metric_descriptors.rb
gitlab-fog-google-1.13.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.12.1 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.12.0 lib/fog/google/models/monitoring/metric_descriptors.rb
fog-google-1.11.0 lib/fog/google/models/monitoring/metric_descriptors.rb