mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|cloud_watch] Updates reference to service
This commit is contained in:
parent
4dd40c1c70
commit
b42d4731e5
8 changed files with 28 additions and 28 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue