1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/models/cloud_watch/alarm_data.rb
Josh Lane d48d376e9c initial import
* take the liberty of correcting Aws naming
2014-12-31 09:17:51 -08:00

38 lines
1.2 KiB
Ruby

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