From 0af87e09cc89001190e1fe49f99696807b686a81 Mon Sep 17 00:00:00 2001 From: Michael Zeng Date: Thu, 29 Sep 2011 18:18:58 -0400 Subject: [PATCH] adding describe_alarm_history --- lib/fog/aws/cloud_watch.rb | 1 + .../cloud_watch/describe_alarm_history.rb | 36 +++++++++++++++++++ .../cloud_watch/describe_alarm_history.rb | 36 +++++++++++++++++++ .../requests/cloud_watch/describe_alarms.rb | 1 + 4 files changed, 74 insertions(+) create mode 100644 lib/fog/aws/parsers/cloud_watch/describe_alarm_history.rb create mode 100644 lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb diff --git a/lib/fog/aws/cloud_watch.rb b/lib/fog/aws/cloud_watch.rb index e539c7331..db1401b6f 100644 --- a/lib/fog/aws/cloud_watch.rb +++ b/lib/fog/aws/cloud_watch.rb @@ -14,6 +14,7 @@ module Fog request :describe_alarms request :put_metric_alarm request :delete_alarms + request :describe_alarm_history model_path 'fog/aws/models/cloud_watch' model :metric diff --git a/lib/fog/aws/parsers/cloud_watch/describe_alarm_history.rb b/lib/fog/aws/parsers/cloud_watch/describe_alarm_history.rb new file mode 100644 index 000000000..ccb58845b --- /dev/null +++ b/lib/fog/aws/parsers/cloud_watch/describe_alarm_history.rb @@ -0,0 +1,36 @@ +module Fog + module Parsers + module AWS + module CloudWatch + + class DescribeAlarmHistory < Fog::Parsers::Base + + def reset + @response = { 'DescribeAlarmHistoryResult' => {'AlarmHistory' => []}, 'ResponseMetadata' => {} } + reset_alarm_history + end + + def reset_alarm_history + @alarm_history = {} + end + + def start_element(name, attrs = []) + super + end + + def end_element(name) + @dimension[name] = value + case name + #when 'Name', 'Value' + #@dimension[name] = value + when 'RequestId' + @response['ResponseMetadata'][name] = value + when 'member' + @response['DescribeAlarmHistoryResult']['AlarmHistory'] << @metric_alarms + end + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb b/lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb new file mode 100644 index 000000000..31d4de2cb --- /dev/null +++ b/lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb @@ -0,0 +1,36 @@ +module Fog + module AWS + class CloudWatch + class Real + + require 'fog/aws/parsers/cloud_watch/describe_alarm_history' + + # Retrieves history for the specified alarm + # ==== Options + # * AlarmName<~String>: The name of the alarm + # * EndDate<~DateTime>: The ending date to retrieve alarm history + # * HistoryItemType<~String>: The type of alarm histories to retrieve + # * MaxRecords<~Integer>: The maximum number of alarm history records to retrieve + # * NextToken<~String> The token returned by a previous call to indicate that there is more data available + # * StartData<~DateTime>: The starting date to retrieve alarm history + # + # ==== Returns + # * response<~Excon::Response>: + # + # ==== See Also + # http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/index.html?API_DescribeAlarmHistory.html + # + + def describe_alarm_history(options={}) + request({ + 'Action' => 'DescribeAlarmHistory', + :parser => Fog::Parsers::AWS::CloudWatch::DescribeAlarmHistory.new + }.merge(options)) + end + end + end + end +end + + + diff --git a/lib/fog/aws/requests/cloud_watch/describe_alarms.rb b/lib/fog/aws/requests/cloud_watch/describe_alarms.rb index 502571f17..9176716e7 100644 --- a/lib/fog/aws/requests/cloud_watch/describe_alarms.rb +++ b/lib/fog/aws/requests/cloud_watch/describe_alarms.rb @@ -14,6 +14,7 @@ module Fog # * AlarmNames<~Array>: An array of alarm names to retrieve information for. # * MaxRecords<~Integer>: The maximum number of alarm descriptions to retrieve # * NextToken<~String>: The token returned by a previous call to indicate that there is more data available + # * NextToken<~String> The token returned by a previous call to indicate that there is more data available # * StateValue<~String>: The state value to be used in matching alarms # # ==== Returns