mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
cleaned up requesters and parsers
This commit is contained in:
parent
57f9b309aa
commit
c44c9f9ac5
15 changed files with 58 additions and 69 deletions
|
@ -2,7 +2,6 @@ module Fog
|
|||
module AWS
|
||||
class CloudWatch < Fog::Service
|
||||
|
||||
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :region, :host, :path, :port, :scheme, :persistent
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ module Fog
|
|||
module Parsers
|
||||
module AWS
|
||||
module CloudWatch
|
||||
|
||||
class DeleteAlarms < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
|
|
@ -2,9 +2,9 @@ module Fog
|
|||
module Parsers
|
||||
module AWS
|
||||
module CloudWatch
|
||||
|
||||
|
||||
class DescribeAlarmHistory < Fog::Parsers::Base
|
||||
|
||||
|
||||
def reset
|
||||
@response = { 'DescribeAlarmHistoryResult' => {'AlarmHistory' => []}, 'ResponseMetadata' => {} }
|
||||
reset_alarm_history
|
||||
|
@ -13,13 +13,12 @@ module Fog
|
|||
def reset_alarm_history
|
||||
@alarm_history = {}
|
||||
end
|
||||
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
#@alarm_history[name] = value
|
||||
case name
|
||||
when 'AlarmName', 'HistoryItemType', 'HistorySummary'
|
||||
@alarm_history[name] = value
|
||||
|
|
|
@ -2,9 +2,9 @@ module Fog
|
|||
module Parsers
|
||||
module AWS
|
||||
module CloudWatch
|
||||
|
||||
|
||||
class DescribeAlarms < Fog::Parsers::Base
|
||||
|
||||
|
||||
def reset
|
||||
@response = { 'DescribeAlarmsResult' => {'MetricAlarms' => []}, 'ResponseMetadata' => {} }
|
||||
reset_metric_alarms
|
||||
|
@ -13,11 +13,11 @@ module Fog
|
|||
def reset_metric_alarms
|
||||
@metric_alarms = {'Dimensions' => []}
|
||||
end
|
||||
|
||||
|
||||
def reset_dimension
|
||||
@dimension = {}
|
||||
end
|
||||
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
|
|
|
@ -2,9 +2,9 @@ module Fog
|
|||
module Parsers
|
||||
module AWS
|
||||
module CloudWatch
|
||||
|
||||
|
||||
class DescribeAlarmsForMetric < Fog::Parsers::Base
|
||||
|
||||
|
||||
def reset
|
||||
@response = { 'DescribeAlarmsForMetricResult' => {'AlarmsForMetric' => []}, 'ResponseMetadata' => {} }
|
||||
reset_alarms_for_metric
|
||||
|
@ -13,11 +13,11 @@ module Fog
|
|||
def reset_alarms_for_metric
|
||||
@alarms_for_metric = {'Dimensions' => []}
|
||||
end
|
||||
|
||||
|
||||
def reset_dimension
|
||||
@dimension = {}
|
||||
end
|
||||
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
|
|
|
@ -2,7 +2,9 @@ module Fog
|
|||
module Parsers
|
||||
module AWS
|
||||
module CloudWatch
|
||||
|
||||
class DisableAlarmActions < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
|
|
@ -2,7 +2,9 @@ module Fog
|
|||
module Parsers
|
||||
module AWS
|
||||
module CloudWatch
|
||||
|
||||
class EnableAlarmActions < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
|
|
@ -2,7 +2,9 @@ module Fog
|
|||
module Parsers
|
||||
module AWS
|
||||
module CloudWatch
|
||||
|
||||
class PutMetricAlarm < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
|
|
@ -2,12 +2,12 @@ module Fog
|
|||
module AWS
|
||||
class CloudWatch
|
||||
class Real
|
||||
|
||||
|
||||
require 'fog/aws/parsers/cloud_watch/delete_alarms'
|
||||
|
||||
|
||||
# Delete a list of alarms
|
||||
# ==== Options
|
||||
# * AlarmNames<~Array>: An array of alarms to be deleted
|
||||
# * AlarmNames<~Array>: A list of alarms to be deleted
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
|
@ -15,10 +15,10 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/index.html?API_DeleteAlarms.html
|
||||
#
|
||||
|
||||
def delete_alarms(alarms)
|
||||
options = {}
|
||||
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarms]))
|
||||
|
||||
def delete_alarms(alarm_names)
|
||||
options = {}
|
||||
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names]))
|
||||
request({
|
||||
'Action' => 'DeleteAlarms',
|
||||
:parser => Fog::Parsers::AWS::CloudWatch::DeleteAlarms.new
|
||||
|
@ -27,7 +27,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -2,9 +2,9 @@ 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
|
||||
|
@ -20,7 +20,7 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/index.html?API_DescribeAlarmHistory.html
|
||||
#
|
||||
|
||||
|
||||
def describe_alarm_history(options={})
|
||||
request({
|
||||
'Action' => 'DescribeAlarmHistory',
|
||||
|
@ -30,7 +30,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -2,15 +2,15 @@ module Fog
|
|||
module AWS
|
||||
class CloudWatch
|
||||
class Real
|
||||
|
||||
|
||||
require 'fog/aws/parsers/cloud_watch/describe_alarms'
|
||||
|
||||
|
||||
# Retrieves alarms with the specified names
|
||||
# ==== Options
|
||||
# * ActionPrefix<~String>: The action name prefix
|
||||
# * AlarmNamePrefix<~String>: The alarm name prefix.
|
||||
# AlarmNames cannot be specified if this parameter is specified
|
||||
# * AlarmNames<~Array>: An array of alarm names to retrieve information for.
|
||||
# * AlarmNames<~Array>: A list 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
|
||||
|
@ -22,8 +22,7 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html
|
||||
#
|
||||
|
||||
|
||||
|
||||
def describe_alarms(options={})
|
||||
if alarm_names = options.delete('AlarmNames')
|
||||
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names]))
|
||||
|
|
|
@ -2,9 +2,9 @@ module Fog
|
|||
module AWS
|
||||
class CloudWatch
|
||||
class Real
|
||||
|
||||
|
||||
require 'fog/aws/parsers/cloud_watch/describe_alarms_for_metric'
|
||||
|
||||
|
||||
# Retrieves all alarms for a single metric
|
||||
# ==== Options
|
||||
# * Dimensions<~Array>: a list of dimensions to filter against
|
||||
|
@ -22,8 +22,7 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html
|
||||
#
|
||||
|
||||
|
||||
|
||||
def describe_alarms_for_metric(options)
|
||||
if dimensions = options.delete('Dimensions')
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
|
@ -37,6 +36,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -2,9 +2,9 @@ module Fog
|
|||
module AWS
|
||||
class CloudWatch
|
||||
class Real
|
||||
|
||||
|
||||
require 'fog/aws/parsers/cloud_watch/disable_alarm_actions'
|
||||
|
||||
|
||||
# Disables actions for the specified alarms
|
||||
# ==== Options
|
||||
# * AlarmNames<~Array>: The names of the alarms to disable actions for
|
||||
|
@ -15,11 +15,10 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DisableAlarmActions.html
|
||||
#
|
||||
|
||||
|
||||
def disable_alarm_actions(alarms)
|
||||
options = {}
|
||||
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarms]))
|
||||
|
||||
def disable_alarm_actions(alarm_names)
|
||||
options = {}
|
||||
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names]))
|
||||
request({
|
||||
'Action' => 'DisableAlarmActions',
|
||||
:parser => Fog::Parsers::AWS::CloudWatch::DisableAlarmActions.new
|
||||
|
@ -28,5 +27,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -2,9 +2,9 @@ module Fog
|
|||
module AWS
|
||||
class CloudWatch
|
||||
class Real
|
||||
|
||||
|
||||
require 'fog/aws/parsers/cloud_watch/enable_alarm_actions'
|
||||
|
||||
|
||||
# Enables actions for the specified alarms
|
||||
# ==== Options
|
||||
# * AlarmNames<~Array>: The names of the alarms to enable actions for
|
||||
|
@ -15,11 +15,10 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_EnableAlarmActions.html
|
||||
#
|
||||
|
||||
|
||||
def enable_alarm_actions(alarms)
|
||||
options = {}
|
||||
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarms]))
|
||||
|
||||
def enable_alarm_actions(alarm_names)
|
||||
options = {}
|
||||
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names]))
|
||||
request({
|
||||
'Action' => 'EnableAlarmActions',
|
||||
:parser => Fog::Parsers::AWS::CloudWatch::EnableAlarmActions.new
|
||||
|
@ -28,5 +27,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -2,11 +2,10 @@ module Fog
|
|||
module AWS
|
||||
class CloudWatch
|
||||
class Real
|
||||
|
||||
|
||||
require 'fog/aws/parsers/cloud_watch/put_metric_alarm'
|
||||
|
||||
# List availabe metrics
|
||||
#
|
||||
|
||||
# Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric
|
||||
# ==== Options
|
||||
# * ActionsEnabled<~Boolean>: Indicates whether or not actions should be executed during any changes to the alarm's state
|
||||
# * AlarmActions<~Array>: A list of actions to execute
|
||||
|
@ -32,7 +31,7 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html
|
||||
#
|
||||
|
||||
|
||||
def put_metric_alarm(options)
|
||||
if dimensions = options.delete('Dimensions')
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
|
@ -55,6 +54,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue