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

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

Instance Method Summary collapse

Instance Method Details

#saveObject



28
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
# File 'lib/fog/aws/models/cloud_watch/alarm_datum.rb', line 28

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

  service.put_metric_alarm(alarm_definition)
  true
end