Class: Fog::AWS::CloudWatch::Metrics
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::CloudWatch::Metrics
- Defined in:
- lib/fog/aws/models/cloud_watch/metrics.rb
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
Methods inherited from Collection
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json
Methods included from Fog::Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all(conditions = {}) ⇒ Object
11 12 13 14 |
# File 'lib/fog/aws/models/cloud_watch/metrics.rb', line 11 def all(conditions={}) data = connection.list_metrics(conditions).body['ListMetricsResult']['Metrics'] load(data) # data is an array of attribute hashes end |
#get(namespace, metric_name, dimensions = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/aws/models/cloud_watch/metrics.rb', line 16 def get(namespace, metric_name, dimensions=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) end if data = connection.list_metrics(list_opts).body['ListMetricsResult']['Metrics'].first new(data) end end |