Sha256: cc7d76934b1dd5c356002b9bf12b8043c3877f7abd4527434b187e3a9a9990ca

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

module Aws
  module Plugins

    # @seahorse.client.option [String] :region (ENV['AWS_REGION'])
    #   The AWS region to connect to.  The region is used to construct
    #   the client endpoint.
    #
    # @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) { ENV['AWS_REGION'] || ENV['AMAZON_REGION'] }

      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

4 entries across 4 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.0.rc4 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc3 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc2 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc1 lib/aws/plugins/regional_endpoint.rb