Class: Fog::Parsers::AWS::CloudWatch::DescribeAlarmsForMetric

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb

Instance Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



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
63
64
# File 'lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb', line 31

def end_element(name)
  case name
  when 'Name', 'Value'
    @dimension[name] = value
  when 'Period', 'EvaluationPeriods'
    @metric_alarms[name] = value.to_i
  when 'Threshold'
    @metric_alarms[name] = value.to_f
  when 'AlarmActions', 'OKActions', 'InsufficientDataActions'
    @metric_alarms[name] = value.to_s.strip
  when 'AlarmName', 'Namespace', 'MetricName', 'AlarmDescription', 'AlarmArn', 'Unit',
      'StateValue', 'Statistic', 'ComparisonOperator', 'StateReason', 'ActionsEnabled'
    @metric_alarms[name] = value
  when 'StateUpdatedTimestamp', 'AlarmConfigurationUpdatedTimestamp'
    @metric_alarms[name] = Time.parse value
  when 'Dimensions'
    @in_dimensions = false
  when 'NextToken'
    @response['ResponseMetadata'][name] = value
  when 'RequestId'
    @response['ResponseMetadata'][name] = value
  when 'member'
    if !@in_dimensions
      if @metric_alarms.key?('AlarmName')
        @response['DescribeAlarmsForMetricResult']['MetricAlarms']  << @metric_alarms
        reset_metric_alarms
      elsif @response['DescribeAlarmsForMetricResult']['MetricAlarms'].last != nil
        @response['DescribeAlarmsForMetricResult']['MetricAlarms'].last.merge!( @metric_alarms)
      end
    else
      @metric_alarms['Dimensions'] << @dimension
    end
  end
end

#resetObject



6
7
8
9
# File 'lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb', line 6

def reset
  @response = { 'DescribeAlarmsForMetricResult' => {'MetricAlarms' => []}, 'ResponseMetadata' => {} }
  reset_metric_alarms
end

#reset_dimensionObject



15
16
17
# File 'lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb', line 15

def reset_dimension
  @dimension = {}
end

#reset_metric_alarmsObject



11
12
13
# File 'lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb', line 11

def reset_metric_alarms
  @metric_alarms = {'Dimensions' => []}
end

#start_element(name, attrs = []) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb', line 19

def start_element(name, attrs = [])
  super
  case name
  when 'Dimensions'
    @in_dimensions = true
  when 'member'
    if @in_dimensions
      reset_dimension
    end
  end
end