Sha256: 7d8cae21153308441740ed4af443395a308a871e31a0265882304abcdd158457

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

require 'ddbcli/ddb-error'

module DynamoDB
  class Endpoint

    ENDPOINTS = {
      'dynamodb.us-east-1.amazonaws.com'      => 'us-east-1',
      'dynamodb.us-west-1.amazonaws.com'      => 'us-west-1',
      'dynamodb.us-west-2.amazonaws.com'      => 'us-west-2',
      'dynamodb.eu-west-1.amazonaws.com'      => 'eu-west-1',
      'dynamodb.ap-northeast-1.amazonaws.com' => 'ap-northeast-1',
      'dynamodb.ap-southeast-1.amazonaws.com' => 'ap-southeast-1',
      'dynamodb.ap-southeast-2.amazonaws.com' => 'ap-southeast-2',
      'dynamodb.sa-east-1.amazonaws.com'      => 'sa-east-1',
    }

    def self.endpoint_and_region(endpoint_or_region)
      if ENDPOINTS.key?(endpoint_or_region)
        [endpoint_or_region, ENDPOINTS[endpoint_or_region]]
      elsif ENDPOINTS.value?(endpoint_or_region)
        ep_key = ENDPOINTS.respond_to?(:key) ? ENDPOINTS.key(endpoint_or_region) : ENDPOINTS.index(endpoint_or_region)
        [ep_key, endpoint_or_region]
      else
        raise DynamoDB::Error, 'Unknown endpoint or region'
      end
    end

    def self.regions
      ENDPOINTS.values.dup
    end
  end # Endpoint
end # DynamoDB

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ddbcli-0.4.1 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.4.0 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.3.8 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.3.7 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.3.6 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.3.5 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.3.4 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.3.3 lib/ddbcli/ddb-endpoint.rb
ddbcli-0.3.2 lib/ddbcli/ddb-endpoint.rb