mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #506 from jbraeuer/tiny-fixes
[aws|cloudwatch] Fix whitespace.
This commit is contained in:
commit
1c46d66c9a
7 changed files with 19 additions and 19 deletions
|
@ -13,7 +13,7 @@ module Fog
|
|||
request :list_metrics
|
||||
request :get_metric_statistics
|
||||
request :put_metric_data
|
||||
|
||||
|
||||
model_path 'fog/aws/models/cloud_watch'
|
||||
model :metric
|
||||
collection :metrics
|
||||
|
|
|
@ -13,13 +13,13 @@ module Fog
|
|||
def reset_datapoint
|
||||
@datapoint = {}
|
||||
end
|
||||
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
case name
|
||||
when 'Average', 'Maximum', 'Minimum', 'SampleCount', 'Sum'
|
||||
@datapoint[name] = value.to_f
|
||||
when 'Unit'
|
||||
|
|
|
@ -13,14 +13,14 @@ module Fog
|
|||
def reset_metric
|
||||
@metric = {'Dimensions' => []}
|
||||
end
|
||||
|
||||
|
||||
def reset_dimension
|
||||
@dimension = {}
|
||||
end
|
||||
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
case name
|
||||
when 'Dimensions'
|
||||
@in_dimensions = true
|
||||
when 'member'
|
||||
|
@ -29,9 +29,9 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
case name
|
||||
when 'Name', 'Value'
|
||||
@dimension[name] = value
|
||||
when 'Namespace', 'MetricName'
|
||||
|
|
|
@ -12,9 +12,9 @@ module Fog
|
|||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = @value
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
|||
# * Period<~Integer>: Granularity, in seconds of the returned datapoints. Must be a multiple of 60, and at least 60
|
||||
# * Statistics<~Array>: An array of up to 5 strings, which name the statistics to return
|
||||
# * Unit<~String>: The unit for the metric
|
||||
# * Dimensions<~Array>: a list of dimensions to filter against (optional)
|
||||
# * Dimensions<~Array>: a list of dimensions to filter against (optional)
|
||||
# Name : The name of the dimension
|
||||
# Value : The value to filter against
|
||||
# ==== Returns
|
||||
|
@ -30,7 +30,7 @@ module Fog
|
|||
end
|
||||
statistics = options.delete 'Statistics'
|
||||
options.merge!(AWS.indexed_param('Statistics.member.%d', [*statistics]))
|
||||
|
||||
|
||||
if dimensions = options.delete('Dimensions')
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']}))
|
||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
|||
# List availabe metrics
|
||||
#
|
||||
# ==== Options
|
||||
# * Dimensions<~Array>: a list of dimensions to filter against,
|
||||
# * Dimensions<~Array>: a list of dimensions to filter against,
|
||||
# Name : The name of the dimension
|
||||
# Value : The value to filter against
|
||||
# * MetricName<~String>: The name of the metric to filter against
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
# * Namespace<~String>: the namespace of the metric data
|
||||
# * MetricData<~Array>: the datapoints to publish of the metric
|
||||
# * MetricName<~String>: the name of the metric
|
||||
# * Timestamp<~String>: the timestamp for the data point. If omitted defaults to the time at which the data is received by CloudWatch
|
||||
# * Timestamp<~String>: the timestamp for the data point. If omitted defaults to the time at which the data is received by CloudWatch
|
||||
# * Unit<~String>: the unit
|
||||
# * Value<~Double> the value for the metric
|
||||
# * StatisticValues<~Hash>:
|
||||
|
@ -27,10 +27,10 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html
|
||||
#
|
||||
|
||||
|
||||
def put_metric_data(namespace, metric_data)
|
||||
options = {'Namespace' => namespace}
|
||||
|
||||
|
||||
#first index the dimensions for any of the datums that have dimensions
|
||||
metric_data.collect! do |metric_datum|
|
||||
if dimensions = metric_datum.delete('Dimensions')
|
||||
|
@ -45,14 +45,14 @@ module Fog
|
|||
options.merge!(AWS.indexed_param('MetricData.member.%d', [*metric_data]))
|
||||
#then finally flatten out an hashes in the overall options array
|
||||
options = flatten_hash(options)
|
||||
|
||||
|
||||
request({
|
||||
'Action' => 'PutMetricData',
|
||||
:parser => Fog::Parsers::AWS::CloudWatch::PutMetricData.new
|
||||
}.merge(options))
|
||||
end
|
||||
private
|
||||
|
||||
|
||||
def flatten_hash(starting)
|
||||
finishing = {}
|
||||
starting.each do |top_level_key, top_level_value|
|
||||
|
|
Loading…
Add table
Reference in a new issue