Sha256: 19163bbbb1618de2677d015e97b544a1d2a2e7a6469ab682d10c85d987628350

Contents?: true

Size: 1.18 KB

Versions: 75

Compression:

Stored size: 1.18 KB

Contents

require 'fog/aws/models/cloud_watch/alarm_datum'

module Fog
  module AWS
    class CloudWatch
      class AlarmData < Fog::Collection
        model Fog::AWS::CloudWatch::AlarmDatum

        def all(conditions={})
          data = service.describe_alarms(conditions).body['DescribeAlarmsResult']['MetricAlarms']
          load(data) # data is an array of attribute hashes
        end

        def get(namespace, metric_name, dimensions=nil, period=nil, statistic=nil, unit=nil)
          list_opts = {'Namespace' => namespace, 'MetricName' => metric_name}
          if dimensions
            dimensions_array = dimensions.map do |name, value|
              {'Name' => name, 'Value' => value}
            end
            list_opts.merge!('Dimensions' => dimensions_array)
          end
          if period
            list_opts.merge!('Period' => period)
          end
          if statistic
          list_opts.merge!('Statistic' => statistic)
          end
          if unit
            list_opts.merge!('Unit' => unit)
          end
          data = service.describe_alarms_for_metric(list_opts).body['DescribeAlarmsForMetricResult']['MetricAlarms']
          load(data)
        end
      end
    end
  end
end

Version data entries

75 entries across 73 versions & 3 rubygems

Version Path
fog-aws-3.29.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.28.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.27.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.26.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.25.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.24.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.23.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.22.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.21.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.21.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.20.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.19.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.18.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.17.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.16.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.15.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.14.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.13.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.12.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-3.11.0 lib/fog/aws/models/cloud_watch/alarm_data.rb