Sha256: 56b208c7a86613796577696e343d2c91dc6355a3248667c01aa5ae443d3095eb

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

module Aws
  module Plugins

    # @seahorse.client.option [String] :region
    #   The AWS region to connect to.  The region is used to construct
    #   the client endpoint.  Defaults to `ENV['AWS_DEFAULT_REGION']`.
    #   Also checks `AWS_REGION` and `AMAZON_REGION`.
    #
    # @seahorse.client.option [String] :endpoint
    #   The HTTP endpoint for this client. Normally you should not need
    #   to configure the `:endpoint` directly.  It is constructed from
    #   the `:region` option.  However, sometime you need to specify
    #   the full endpoint, especially when connecting to test
    #   endpoints.
    #
    class RegionalEndpoint < Seahorse::Client::Plugin

      # raised when region is not configured
      MISSING_REGION = 'missing required configuration option :region'

      option(:region) {
        keys = %w(AWS_DEFAULT_REGION AWS_REGION AMAZON_REGION)
        ENV.values_at(*keys).compact.first
      }

      option(:endpoint) do |cfg|
        endpoints = cfg.api.metadata['regional_endpoints']
        if endpoints && endpoints[cfg.region]
          endpoints[cfg.region]
        else
          "#{cfg.api.metadata['endpoint_prefix']}.#{cfg.region}.amazonaws.com"
        end
      end

      def after_initialize(client)
        raise Errors::MissingRegionError unless client.config.region
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.0.rc10 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc9 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc8 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc7 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc6 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc5 lib/aws/plugins/regional_endpoint.rb