Sha256: cb8f3929b7027fa03fa5fdbe2f200e66956e93218f91de89d76970fad48f47a6

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module Aws
  module Plugins

    # @seahorse.client.option [required, 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 A default endpoint is
    #   constructed from the `:region`.
    #
    class RegionalEndpoint < Seahorse::Client::Plugin

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

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

      option(:endpoint) do |cfg|
        EndpointProvider.default_provider.resolve(
          service: cfg.api.metadata('endpointPrefix'),
          region: cfg.region,
          scheme: 'https'
        )
      end

      def after_initialize(client)
        if client.config.region.nil? or client.config.region == ''
          raise Errors::MissingRegionError
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.0 lib/aws-sdk-core/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc16 lib/aws/plugins/regional_endpoint.rb
aws-sdk-core-2.0.0.rc15 lib/aws/plugins/regional_endpoint.rb