Sha256: cb924d88b7a629442a1f1588955ec6e85e9d8d8a30641efc094bbad85809d0f4

Contents?: true

Size: 1.21 KB

Versions: 22

Compression:

Stored size: 1.21 KB

Contents

require 'fog/core/collection'
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

22 entries across 22 versions & 5 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-0.1.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-0.1.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-0.0.8 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-0.0.7 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-0.0.6 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-aws-0.0.5 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.26.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.25.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
nsidc-fog-1.24.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.24.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.11 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.10 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.9 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.8 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.7 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.6 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.23.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.4 lib/fog/aws/models/cloud_watch/alarm_data.rb
ns-fog-1.22.3 lib/fog/aws/models/cloud_watch/alarm_data.rb