Sha256: 9d28cfbef8eb0149117af1700f145fb353d7add88a7afd5383179da1223a8f63

Contents?: true

Size: 1.25 KB

Versions: 35

Compression:

Stored size: 1.25 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 = connection.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.collect 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 = connection.describe_alarms_for_metric(list_opts).body['DescribeAlarmsForMetricResult']['MetricAlarms']
          load(data)
        end
        
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 13 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-nirvanix-1.8.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-parser-fix-1.6.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-test-again-1.6.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-parser-fix-1.6.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-sgonyea-1.8.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.8.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.7.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.6.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.5.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.4.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/cloud_watch/alarm_data.rb
michiels-fog-1.3.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/aws/models/cloud_watch/alarm_data.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.3.1 lib/fog/aws/models/cloud_watch/alarm_data.rb
fog-1.3.0 lib/fog/aws/models/cloud_watch/alarm_data.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/cloud_watch/alarm_data.rb