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 = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
||||||
options.delete_if { |key, value| value.nil? }
|
options.delete_if { |key, value| value.nil? }
|
||||||
|
|
||||||
connection.put_metric_alarm(options)
|
service.put_metric_alarm(options)
|
||||||
reload
|
reload
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
connection.delete_alarms(id)
|
service.delete_alarms(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
||||||
model Fog::AWS::CloudWatch::AlarmDatum
|
model Fog::AWS::CloudWatch::AlarmDatum
|
||||||
|
|
||||||
def all(conditions={})
|
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
|
load(data) # data is an array of attribute hashes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ module Fog
|
||||||
if unit
|
if unit
|
||||||
list_opts.merge!('Unit' => unit)
|
list_opts.merge!('Unit' => unit)
|
||||||
end
|
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)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ module Fog
|
||||||
alarm_definition.merge!('OKActions' => ok_actions) if ok_actions
|
alarm_definition.merge!('OKActions' => ok_actions) if ok_actions
|
||||||
alarm_definition.merge!('Unit' => unit) if unit
|
alarm_definition.merge!('Unit' => unit) if unit
|
||||||
|
|
||||||
connection.put_metric_alarm(alarm_definition)
|
service.put_metric_alarm(alarm_definition)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
||||||
model Fog::AWS::CloudWatch::AlarmHistory
|
model Fog::AWS::CloudWatch::AlarmHistory
|
||||||
|
|
||||||
def all(conditions={})
|
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
|
load(data) # data is an array of attribute hashes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
||||||
data = []
|
data = []
|
||||||
next_token = nil
|
next_token = nil
|
||||||
loop do
|
loop do
|
||||||
result = connection.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult']
|
result = service.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult']
|
||||||
data += result['MetricAlarms']
|
data += result['MetricAlarms']
|
||||||
next_token = result['NextToken']
|
next_token = result['NextToken']
|
||||||
break if next_token.nil?
|
break if next_token.nil?
|
||||||
|
@ -21,23 +21,23 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(identity)
|
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?
|
new(data) unless data.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
#alarm_names is an array of alarm names
|
#alarm_names is an array of alarm names
|
||||||
def delete(alarm_names)
|
def delete(alarm_names)
|
||||||
connection.delete_alarms(alarm_names)
|
service.delete_alarms(alarm_names)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable(alarm_names)
|
def disable(alarm_names)
|
||||||
connection.disable_alarm_actions(alarm_names)
|
service.disable_alarm_actions(alarm_names)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable(alarm_names)
|
def enable(alarm_names)
|
||||||
connection.enable_alarm_actions(alarm_names)
|
service.enable_alarm_actions(alarm_names)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ module Fog
|
||||||
'SampleCount' => sample_count
|
'SampleCount' => sample_count
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
connection.put_metric_data(namespace, [put_opts])
|
service.put_metric_data(namespace, [put_opts])
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
||||||
namespace = conditions['Namespace']
|
namespace = conditions['Namespace']
|
||||||
dimensions = conditions['Dimensions']
|
dimensions = conditions['Dimensions']
|
||||||
get_metric_opts = {"StartTime" => (Time.now-3600).iso8601, "EndTime" => Time.now.iso8601, "Period" => 300}.merge(conditions)
|
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) }
|
data.collect! { |datum| datum.merge('MetricName' => metricName, 'Namespace' => namespace, 'Dimensions' => dimensions) }
|
||||||
load(data) # data is an array of attribute hashes
|
load(data) # data is an array of attribute hashes
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Fog
|
||||||
model Fog::AWS::CloudWatch::Metric
|
model Fog::AWS::CloudWatch::Metric
|
||||||
|
|
||||||
def all(conditions={})
|
def all(conditions={})
|
||||||
result = connection.list_metrics(conditions).body['ListMetricsResult']
|
result = service.list_metrics(conditions).body['ListMetricsResult']
|
||||||
merge_attributes("NextToken" => result["NextToken"])
|
merge_attributes("NextToken" => result["NextToken"])
|
||||||
load(result['Metrics']) # an array of attribute hashes
|
load(result['Metrics']) # an array of attribute hashes
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ module Fog
|
||||||
end
|
end
|
||||||
# list_opts.merge!('Dimensions' => dimensions_array)
|
# list_opts.merge!('Dimensions' => dimensions_array)
|
||||||
end
|
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)
|
new(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue