Sha256: 4115a8786cb3736751b3d78ab09369f3b904c7873ba5dba265dc9d219953adcb

Contents?: true

Size: 767 Bytes

Versions: 7

Compression:

Stored size: 767 Bytes

Contents

require 'multi_json'

module Aws
  # @api private
  class EndpointProvider

    # @api private
    PATH = File.join(File.dirname(__FILE__), '..', '..', 'endpoints.json')

    # @api private
    RULES = MultiJson.load(File.read(PATH))['endpoints']

    class << self

      def resolve(region, service)
        keys(region, service).each do |key|
          if match = RULES[key]
            return expand(match['endpoint'], region.to_s, service.to_s)
          end
        end
      end

      private

      def keys(region, service)
        ["#{region}/#{service}", "#{region}/*", "*/#{service}", "*/*"]
      end

      def expand(pattern, region, service)
        'https://' + pattern.sub('{region}', region).sub('{service}', service)
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.10 lib/aws-sdk-core/endpoint_provider.rb
aws-sdk-core-2.0.9 lib/aws-sdk-core/endpoint_provider.rb
aws-sdk-core-2.0.8 lib/aws-sdk-core/endpoint_provider.rb
aws-sdk-core-2.0.7 lib/aws-sdk-core/endpoint_provider.rb
aws-sdk-core-2.0.6 lib/aws-sdk-core/endpoint_provider.rb
aws-sdk-core-2.0.5 lib/aws-sdk-core/endpoint_provider.rb
aws-sdk-core-2.0.4 lib/aws-sdk-core/endpoint_provider.rb