Sha256: a28e2e7080bc80ff12812a3579e471385a15240a951cde3e2b9545cd760bae20

Contents?: true

Size: 1.44 KB

Versions: 70

Compression:

Stored size: 1.44 KB

Contents

require 'fog/aws/parsers/iam/policy_parser'

module Fog
  module Parsers
    module AWS
      module IAM
        class ListManagedPolicies < Fog::Parsers::AWS::IAM::PolicyParser
          def reset
            super
            @response = { 'Policies' => [] , 'Marker' => '', 'IsTruncated' => false}
          end

          def finished_policy(policy)
            @response['Policies'] << policy
          end

          def start_element(name,attrs = [])
            case name
            when 'AttachedPolicies'
              @stack << name
            when 'AttachedPolicy'
              @policy = fresh_policy
            when 'member'
              if @stack.last == 'AttachedPolicies'
                @policy = fresh_policy
              end
            end
            super
          end

          def end_element(name)
            case name
            when 'RequestId', 'Marker'
              @response[name] = value
            when 'IsTruncated'
              @response[name] = (value == 'true')
            when 'PolicyArn', 'PolicyName'
              @policy[name] = value
            when 'AttachedPolicies'
              if @stack.last == 'AttachedPolicies'
                @stack.pop
              end
            when 'member'
              if @stack.last == 'AttachedPolicies'
                finished_policy(@policy)
                @policy = nil
              end
            end
            super
          end
        end
      end
    end
  end
end

Version data entries

70 entries across 68 versions & 3 rubygems

Version Path
fog-aws-0.8.0 lib/fog/aws/parsers/iam/list_managed_policies.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-aws-0.7.5/lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.7.6 lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.7.5 lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.7.4 lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.7.3 lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.7.2 lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.6.0 lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.5.0 lib/fog/aws/parsers/iam/list_managed_policies.rb
fog-aws-0.4.1 lib/fog/aws/parsers/iam/list_managed_policies.rb