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
|
||||||
|
|
|
@ -6,33 +6,33 @@ module Fog
|
||||||
class CloudWatch
|
class CloudWatch
|
||||||
class AlarmData < Fog::Collection
|
class AlarmData < Fog::Collection
|
||||||
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
|
||||||
|
|
||||||
def get(namespace, metric_name, dimensions=nil, period=nil, statistic=nil, unit=nil)
|
def get(namespace, metric_name, dimensions=nil, period=nil, statistic=nil, unit=nil)
|
||||||
list_opts = {'Namespace' => namespace, 'MetricName' => metric_name}
|
list_opts = {'Namespace' => namespace, 'MetricName' => metric_name}
|
||||||
if dimensions
|
if dimensions
|
||||||
dimensions_array = dimensions.collect do |name, value|
|
dimensions_array = dimensions.collect do |name, value|
|
||||||
{'Name' => name, 'Value' => value}
|
{'Name' => name, 'Value' => value}
|
||||||
end
|
end
|
||||||
list_opts.merge!('Dimensions' => dimensions_array)
|
list_opts.merge!('Dimensions' => dimensions_array)
|
||||||
end
|
end
|
||||||
if period
|
if period
|
||||||
list_opts.merge!('Period' => period)
|
list_opts.merge!('Period' => period)
|
||||||
end
|
end
|
||||||
if statistic
|
if statistic
|
||||||
list_opts.merge!('Statistic' => statistic)
|
list_opts.merge!('Statistic' => statistic)
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
||||||
attribute :comparison_operator, :aliases => 'ComparisonOperator'
|
attribute :comparison_operator, :aliases => 'ComparisonOperator'
|
||||||
attribute :state_reason, :aliases => 'StateReason'
|
attribute :state_reason, :aliases => 'StateReason'
|
||||||
attribute :action_enabled, :aliases => 'ActionsEnabled'
|
attribute :action_enabled, :aliases => 'ActionsEnabled'
|
||||||
attribute :period, :aliases => 'Period'
|
attribute :period, :aliases => 'Period'
|
||||||
attribute :evaluation_periods, :aliases => 'EvaluationPeriods'
|
attribute :evaluation_periods, :aliases => 'EvaluationPeriods'
|
||||||
attribute :threshold, :aliases => 'Threshold'
|
attribute :threshold, :aliases => 'Threshold'
|
||||||
attribute :alarm_actions, :aliases => 'AlarmActions'
|
attribute :alarm_actions, :aliases => 'AlarmActions'
|
||||||
|
@ -40,7 +40,7 @@ module Fog
|
||||||
'AlarmName' => alarm_name,
|
'AlarmName' => alarm_name,
|
||||||
'ComparisonOperator' => comparison_operator,
|
'ComparisonOperator' => comparison_operator,
|
||||||
'EvaluationPeriods' => evaluation_periods,
|
'EvaluationPeriods' => evaluation_periods,
|
||||||
'MetricName' => metric_name,
|
'MetricName' => metric_name,
|
||||||
'Namespace' => namespace,
|
'Namespace' => namespace,
|
||||||
'Period' => period,
|
'Period' => period,
|
||||||
'Statistic' => statistic,
|
'Statistic' => statistic,
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
||||||
attribute :namespace, :aliases => 'Namespace'
|
attribute :namespace, :aliases => 'Namespace'
|
||||||
attribute :dimensions, :aliases => 'Dimensions'
|
attribute :dimensions, :aliases => 'Dimensions'
|
||||||
attribute :value
|
attribute :value
|
||||||
|
|
||||||
def save
|
def save
|
||||||
requires :metric_name
|
requires :metric_name
|
||||||
requires :namespace
|
requires :namespace
|
||||||
|
@ -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
|
||||||
|
|
|
@ -6,17 +6,17 @@ module Fog
|
||||||
class CloudWatch
|
class CloudWatch
|
||||||
class MetricStatistics < Fog::Collection
|
class MetricStatistics < Fog::Collection
|
||||||
model Fog::AWS::CloudWatch::MetricStatistic
|
model Fog::AWS::CloudWatch::MetricStatistic
|
||||||
|
|
||||||
def all(conditions)
|
def all(conditions)
|
||||||
metricName = conditions['MetricName']
|
metricName = conditions['MetricName']
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
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
|
||||||
|
@ -28,7 +28,7 @@ module Fog
|
||||||
subset = subset.all("NextToken" => next_token)
|
subset = subset.all("NextToken" => next_token)
|
||||||
subset.each_metric_this_page {|m| yield m }
|
subset.each_metric_this_page {|m| yield m }
|
||||||
end
|
end
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
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