Class: Fog::AWS::CloudWatch::MetricStatistic

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/cloud_watch/metric_statistic.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

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::Model

Instance Method Details

#saveObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/aws/models/cloud_watch/metric_statistic.rb', line 21

def save
  requires :metric_name
  requires :namespace
  requires :unit

  put_opts = {'MetricName' => metric_name, 'Unit' => unit}
  put_opts.merge!('Dimensions' => dimensions) if dimensions
  if value
    put_opts.merge!('Value' => value)
  else
    put_opts.merge!('StatisticValues' => {
      'Minimum' => minimum,
      'Maximum' => maximum,
      'Sum' => sum,
      'Average' => average,
      'SampleCount' => sample_count
    })
  end
  connection.put_metric_data(namespace, [put_opts])
  true
end