From b42d4731e50a2abdce3da5a05992cbac8837017b Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Sat, 22 Dec 2012 23:31:48 +0000 Subject: [PATCH] [aws|cloud_watch] Updates reference to service --- lib/fog/aws/models/cloud_watch/alarm.rb | 4 ++-- lib/fog/aws/models/cloud_watch/alarm_data.rb | 18 +++++++++--------- lib/fog/aws/models/cloud_watch/alarm_datum.rb | 6 +++--- .../aws/models/cloud_watch/alarm_histories.rb | 2 +- lib/fog/aws/models/cloud_watch/alarms.rb | 10 +++++----- .../aws/models/cloud_watch/metric_statistic.rb | 4 ++-- .../models/cloud_watch/metric_statistics.rb | 6 +++--- lib/fog/aws/models/cloud_watch/metrics.rb | 6 +++--- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/fog/aws/models/cloud_watch/alarm.rb b/lib/fog/aws/models/cloud_watch/alarm.rb index fd9c90dc2..c301bc1d0 100644 --- a/lib/fog/aws/models/cloud_watch/alarm.rb +++ b/lib/fog/aws/models/cloud_watch/alarm.rb @@ -46,13 +46,13 @@ module Fog options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }] options.delete_if { |key, value| value.nil? } - connection.put_metric_alarm(options) + service.put_metric_alarm(options) reload end def destroy requires :id - connection.delete_alarms(id) + service.delete_alarms(id) end end end diff --git a/lib/fog/aws/models/cloud_watch/alarm_data.rb b/lib/fog/aws/models/cloud_watch/alarm_data.rb index 269452093..add59bf60 100644 --- a/lib/fog/aws/models/cloud_watch/alarm_data.rb +++ b/lib/fog/aws/models/cloud_watch/alarm_data.rb @@ -6,33 +6,33 @@ module Fog class CloudWatch class AlarmData < Fog::Collection model Fog::AWS::CloudWatch::AlarmDatum - + def all(conditions={}) - data = connection.describe_alarms(conditions).body['DescribeAlarmsResult']['MetricAlarms'] + 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.collect do |name, value| {'Name' => name, 'Value' => value} end - list_opts.merge!('Dimensions' => dimensions_array) + list_opts.merge!('Dimensions' => dimensions_array) end if period - list_opts.merge!('Period' => period) + list_opts.merge!('Period' => period) end if statistic - list_opts.merge!('Statistic' => statistic) + list_opts.merge!('Statistic' => statistic) end if unit - list_opts.merge!('Unit' => unit) + list_opts.merge!('Unit' => unit) end - data = connection.describe_alarms_for_metric(list_opts).body['DescribeAlarmsForMetricResult']['MetricAlarms'] + data = service.describe_alarms_for_metric(list_opts).body['DescribeAlarmsForMetricResult']['MetricAlarms'] load(data) end - + end end end diff --git a/lib/fog/aws/models/cloud_watch/alarm_datum.rb b/lib/fog/aws/models/cloud_watch/alarm_datum.rb index ea773e010..76ca09f18 100644 --- a/lib/fog/aws/models/cloud_watch/alarm_datum.rb +++ b/lib/fog/aws/models/cloud_watch/alarm_datum.rb @@ -16,7 +16,7 @@ module Fog attribute :comparison_operator, :aliases => 'ComparisonOperator' attribute :state_reason, :aliases => 'StateReason' attribute :action_enabled, :aliases => 'ActionsEnabled' - attribute :period, :aliases => 'Period' + attribute :period, :aliases => 'Period' attribute :evaluation_periods, :aliases => 'EvaluationPeriods' attribute :threshold, :aliases => 'Threshold' attribute :alarm_actions, :aliases => 'AlarmActions' @@ -40,7 +40,7 @@ module Fog 'AlarmName' => alarm_name, 'ComparisonOperator' => comparison_operator, 'EvaluationPeriods' => evaluation_periods, - 'MetricName' => metric_name, + 'MetricName' => metric_name, 'Namespace' => namespace, 'Period' => period, 'Statistic' => statistic, @@ -57,7 +57,7 @@ module Fog alarm_definition.merge!('OKActions' => ok_actions) if ok_actions alarm_definition.merge!('Unit' => unit) if unit - connection.put_metric_alarm(alarm_definition) + service.put_metric_alarm(alarm_definition) true end end diff --git a/lib/fog/aws/models/cloud_watch/alarm_histories.rb b/lib/fog/aws/models/cloud_watch/alarm_histories.rb index 7e4a76f95..93d357d4e 100644 --- a/lib/fog/aws/models/cloud_watch/alarm_histories.rb +++ b/lib/fog/aws/models/cloud_watch/alarm_histories.rb @@ -8,7 +8,7 @@ module Fog model Fog::AWS::CloudWatch::AlarmHistory def all(conditions={}) - data = connection.describe_alarm_history(conditions).body['DescribeAlarmHistoryResult']['AlarmHistoryItems'] + data = service.describe_alarm_history(conditions).body['DescribeAlarmHistoryResult']['AlarmHistoryItems'] load(data) # data is an array of attribute hashes end diff --git a/lib/fog/aws/models/cloud_watch/alarms.rb b/lib/fog/aws/models/cloud_watch/alarms.rb index 57e4df30b..834bfaf4a 100644 --- a/lib/fog/aws/models/cloud_watch/alarms.rb +++ b/lib/fog/aws/models/cloud_watch/alarms.rb @@ -12,7 +12,7 @@ module Fog data = [] next_token = nil loop do - result = connection.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult'] + result = service.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult'] data += result['MetricAlarms'] next_token = result['NextToken'] break if next_token.nil? @@ -21,23 +21,23 @@ module Fog end def get(identity) - data = connection.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first + data = service.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first new(data) unless data.nil? end #alarm_names is an array of alarm names def delete(alarm_names) - connection.delete_alarms(alarm_names) + service.delete_alarms(alarm_names) true end def disable(alarm_names) - connection.disable_alarm_actions(alarm_names) + service.disable_alarm_actions(alarm_names) true end def enable(alarm_names) - connection.enable_alarm_actions(alarm_names) + service.enable_alarm_actions(alarm_names) true end diff --git a/lib/fog/aws/models/cloud_watch/metric_statistic.rb b/lib/fog/aws/models/cloud_watch/metric_statistic.rb index 6c9850893..5e304567d 100644 --- a/lib/fog/aws/models/cloud_watch/metric_statistic.rb +++ b/lib/fog/aws/models/cloud_watch/metric_statistic.rb @@ -17,7 +17,7 @@ module Fog attribute :namespace, :aliases => 'Namespace' attribute :dimensions, :aliases => 'Dimensions' attribute :value - + def save requires :metric_name requires :namespace @@ -36,7 +36,7 @@ module Fog 'SampleCount' => sample_count }) end - connection.put_metric_data(namespace, [put_opts]) + service.put_metric_data(namespace, [put_opts]) true end end diff --git a/lib/fog/aws/models/cloud_watch/metric_statistics.rb b/lib/fog/aws/models/cloud_watch/metric_statistics.rb index 46ff60c2a..fc0bc95e1 100644 --- a/lib/fog/aws/models/cloud_watch/metric_statistics.rb +++ b/lib/fog/aws/models/cloud_watch/metric_statistics.rb @@ -6,17 +6,17 @@ module Fog class CloudWatch class MetricStatistics < Fog::Collection model Fog::AWS::CloudWatch::MetricStatistic - + def all(conditions) metricName = conditions['MetricName'] namespace = conditions['Namespace'] dimensions = conditions['Dimensions'] get_metric_opts = {"StartTime" => (Time.now-3600).iso8601, "EndTime" => Time.now.iso8601, "Period" => 300}.merge(conditions) - data = connection.get_metric_statistics(get_metric_opts).body['GetMetricStatisticsResult']['Datapoints'] + data = service.get_metric_statistics(get_metric_opts).body['GetMetricStatisticsResult']['Datapoints'] data.collect! { |datum| datum.merge('MetricName' => metricName, 'Namespace' => namespace, 'Dimensions' => dimensions) } load(data) # data is an array of attribute hashes end - + end end end diff --git a/lib/fog/aws/models/cloud_watch/metrics.rb b/lib/fog/aws/models/cloud_watch/metrics.rb index 6dc907960..9df9780f1 100644 --- a/lib/fog/aws/models/cloud_watch/metrics.rb +++ b/lib/fog/aws/models/cloud_watch/metrics.rb @@ -11,7 +11,7 @@ module Fog model Fog::AWS::CloudWatch::Metric def all(conditions={}) - result = connection.list_metrics(conditions).body['ListMetricsResult'] + result = service.list_metrics(conditions).body['ListMetricsResult'] merge_attributes("NextToken" => result["NextToken"]) load(result['Metrics']) # an array of attribute hashes end @@ -28,7 +28,7 @@ module Fog subset = subset.all("NextToken" => next_token) subset.each_metric_this_page {|m| yield m } end - + self end end @@ -41,7 +41,7 @@ module Fog end # list_opts.merge!('Dimensions' => dimensions_array) end - if data = connection.list_metrics(list_opts).body['ListMetricsResult']['Metrics'].first + if data = service.list_metrics(list_opts).body['ListMetricsResult']['Metrics'].first new(data) end end