Class: Fog::AWS::CloudWatch::AlarmDatum

Inherits:
Model
  • Object
show all
Defined in:
lib/rackspace-fog/aws/models/cloud_watch/alarm_datum.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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rackspace-fog/aws/models/cloud_watch/alarm_datum.rb', line 29

def save
  requires :alarm_name
  requires :comparison_operator
  requires :evaluation_periods
  requires :metric_name
  requires :namespace
  requires :period
  requires :statistic
  requires :threshold

  alarm_definition = {
      'AlarmName' => alarm_name,
      'ComparisonOperator' => comparison_operator,
      'EvaluationPeriods' => evaluation_periods,
      'MetricName' => metric_name, 
      'Namespace' => namespace,
      'Period' => period,
      'Statistic' => statistic,
      'Threshold' => threshold
      }

  alarm_definition.merge!('ActionsEnabled' => action_enabled) if action_enabled
  alarm_definition.merge!('AlarmActions' => alarm_actions) if alarm_actions
  alarm_definition.merge!('AlarmDescription' => alarm_description) if alarm_description

  #dimension is an array of Name/Value pairs, ex. [{'Name'=>'host', 'Value'=>'localhost'},{'Name'=>'version', 'Value'=>'0.11.0'}]
  alarm_definition.merge!('Dimensions' => dimensions) if dimensions
  alarm_definition.merge!('InsufficientDataActions' => insufficient_actions) if insufficient_actions
  alarm_definition.merge!('OKActions' => ok_actions) if ok_actions
  alarm_definition.merge!('Unit' => unit) if unit

  connection.put_metric_alarm(alarm_definition)
  true
end