Sha256: 3c826ace9ec7558ad181e9ec1cff0a074a39c41d75c946e76dc48a8012bce7d0

Contents?: true

Size: 1.75 KB

Versions: 33

Compression:

Stored size: 1.75 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', '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

33 entries across 33 versions & 11 rubygems

Version Path
gapinc-fog-1.12.1.2.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.14.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.13.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
gapinc-fog-1.12.1.2 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
gapinc-fog-1.12.1.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
gapinc-fog-1.12.1a lib/fog/aws/parsers/auto_scaling/describe_policies.rb
gapinc-fog-1.12.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.12.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.12.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
hpfog-0.0.20 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-nirvanix-1.8.2 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.11.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.11.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-nirvanix-1.8.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.10.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-parser-fix-1.6.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-test-again-1.6.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-test-me-1.10.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb