Sha256: ac9b72442195d35bd368d963863365d0575c1f8b2d95dfa6f9d40ffd4e78fc8a

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

class Organizations < Mapper
  #
  # Returns an array of resources.
  #
  def collect
    resources = []

    #
    # describe_organization
    #
    @client.describe_organization.each do |response|
      log(response.context.operation_name)

      struct = OpenStruct.new(response.organization.to_h)
      struct.type = 'organization'

      resources.push(struct.to_h)
    end

    #
    # list_handshakes_for_account
    #
    @client.list_handshakes_for_account.each_with_index do |response, page|
      log(response.context.operation_name, page)

      response.handshakes.each do |handshake|
        struct = OpenStruct.new(handshake.to_h)
        struct.type = 'handshake'

        resources.push(struct.to_h)
      end
    end

    #
    # list_policies
    #
    @client.list_policies({ filter: 'SERVICE_CONTROL_POLICY' }).each_with_index do |response, page|
      log(response.context.operation_name, page)

      response.policies.each do |policy|
        struct = OpenStruct.new(policy.to_h)
        struct.type = 'service_control_policy'
        struct.content = JSON.parse(CGI.unescape(@client.describe_policy({ policy_id: policy.id }).policy.content))

        resources.push(struct.to_h)
      end
    end

    resources
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aws_recon-0.2.18 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.17 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.16 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.15 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.14 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.13 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.12 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.11 lib/aws_recon/collectors/organizations.rb
aws_recon-0.2.10 lib/aws_recon/collectors/organizations.rb