Sha256: c100bb3c8a9cd8c7b706a85329acd137b83cfc980fe32e56ce122b0086762636

Contents?: true

Size: 1.73 KB

Versions: 31

Compression:

Stored size: 1.73 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'
              if @in_alarms == true
                @scaling_policy['Alarms'] << @alarm
                reset_alarm
              end            
            when 'member'
              @results['ScalingPolicies'] << @scaling_policy
              reset_scaling_policy              
            end
          end

        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 8 rubygems

Version Path
rackspace-fog-1.4.2 lib/rackspace-fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.4.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
michiels-fog-1.3.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.3.1 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.3.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.2.0 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
ktheory-fog-1.1.2 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog-1.1.2 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog_tractical-1.1.4 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
fog_tractical-1.1.3 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/auto_scaling/describe_policies.rb