Sha256: 4711440f59aac462695f0cb9c35a94f59d6cd38cb6cf61034449fc580205e69f

Contents?: true

Size: 1.07 KB

Versions: 52

Compression:

Stored size: 1.07 KB

Contents

module Awspec::Type
  class Account < Base
    REMOVE_SUFFIX_RE = /
    _account_attributes|_account_settings|_send_quota
    /ix

    def resource_via_client
      attributes = sts_client.get_caller_identity.to_h
      Awspec::Helper::Type::ACCOUNT_ATTRIBUTES.each do |type|
        key = type.gsub(REMOVE_SUFFIX_RE, '').to_sym
        if key == 'ses'
          # https://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html
          next unless ['us-east-1', 'us-west-2', 'eu-west-1'].include?(Aws.config[:region])
        end
        eval "attributes[key] = Awspec::Type::#{type.camelize}.new.resource_via_client"
      end
      @resource_via_client ||= attributes.to_struct
    end

    def id
      @id ||= sts_client.get_caller_identity.account
    end

    def account
      id
    end

    def lambda
      resource_via_client[:lambda]
    end

    def method_missing(name)
      name = name.to_s if name.class == Symbol
      describe = name.tr('-', '_').to_sym
      super unless resource_via_client.members.include?(describe)
      resource_via_client[describe]
    end
  end
end

Version data entries

52 entries across 52 versions & 3 rubygems

Version Path
cthiesfork-awspec-1.2.2 lib/awspec/type/account.rb
cthiesfork-awspec-1.2.1 lib/awspec/type/account.rb
awspec-1.18.5 lib/awspec/type/account.rb
cthiesfork-awspec-1.2.0 lib/awspec/type/account.rb
cthiesfork-awspec-1.1.0 lib/awspec/type/account.rb
cthiesfork-awspec-1.0.0 lib/awspec/type/account.rb
awspec-1.18.4 lib/awspec/type/account.rb
awspec-1.18.3 lib/awspec/type/account.rb
awspec-1.18.2 lib/awspec/type/account.rb
awspec-1.18.1 lib/awspec/type/account.rb
awspec-1.18.0 lib/awspec/type/account.rb
awspec-1.17.4 lib/awspec/type/account.rb
awspec-1.17.3 lib/awspec/type/account.rb
awspec-1.17.2 lib/awspec/type/account.rb
awspec-1.17.1 lib/awspec/type/account.rb
awspec-1.17.0 lib/awspec/type/account.rb
awspec-1.16.1 lib/awspec/type/account.rb
awspec-1.16.0 lib/awspec/type/account.rb
awspec-1.15.3 lib/awspec/type/account.rb
awspec-1.15.2 lib/awspec/type/account.rb