Class: Fog::AWS::CloudWatch::AlarmData

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/aws/models/cloud_watch/alarm_data.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#all(conditions = {}) ⇒ Object



10
11
12
13
# File 'lib/fog/aws/models/cloud_watch/alarm_data.rb', line 10

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

#get(namespace, metric_name, dimensions = nil, period = nil, statistic = nil, unit = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/aws/models/cloud_watch/alarm_data.rb', line 15

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