Sha256: 569470ceadd5bbd05811cbc0c49d4a31b64e093a8990a98436e712dce2a1798b

Contents?: true

Size: 1.72 KB

Versions: 44

Compression:

Stored size: 1.72 KB

Contents

module Fog
  module Parsers
    module AWS
      module AutoScaling

        class DescribePolicies < Fog::Parsers::Base

          def reset
            reset_scaling_policy
            reset_alarm
            @results = { 'ScalingPolicies' => [] }
            @response = { 'DescribePoliciesResult' => {}, 'ResponseMetadata' => {} }
            @in_alarms = false
          end

          def reset_scaling_policy
            @scaling_policy = { 'Alarms' => [] }
          end

          def reset_alarm
            @alarm = {}
          end

          def start_element(name, attrs = [])
            super
            case name
            when 'Alarms'
              @in_alarms = true
            end
          end

          def end_element(name)
            case name
            when 'AlarmARN', 'AlarmName'
              @alarm[name] = value

            when 'AdjustmentType', 'AutoScalingGroupName', 'PolicyARN', 'PolicyName'
              @scaling_policy[name] = value
            when 'Cooldown', 'MinAdjustmentStep', 'ScalingAdjustment'
              @scaling_policy[name] = value.to_i

            when 'NextToken'
              @results[name] = value

            when 'RequestId'
              @response['ResponseMetadata'][name] = value

            when 'DescribePoliciesResponse'
              @response['DescribePoliciesResult'] = @results

            when 'Alarms'
              @in_alarms = false
            when 'member'
              if @in_alarms
                @scaling_policy['Alarms'] << @alarm
                reset_alarm
              else
                @results['ScalingPolicies'] << @scaling_policy
                reset_scaling_policy
              end
            end
          end

        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 3 rubygems

Version Path
fog-1.22.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.21.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.20.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.19.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/parsers/auto_scaling/describe_policies.rb