Class: Aws::EndpointProvider Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/endpoint_provider.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ EndpointProvider

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of EndpointProvider.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :rules (Array<Hash>) — default: []

    An array of grouped rules.



8
9
10
# File 'lib/aws-sdk-core/endpoint_provider.rb', line 8

def initialize(options = {})
  @rules = options[:rules] || []
end

Class Method Details

.default_providerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
# File 'lib/aws-sdk-core/endpoint_provider.rb', line 86

def default_provider
  @default_provider ||= EndpointProvider.new(rules: default_rules)
end

.default_rulesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



90
91
92
93
# File 'lib/aws-sdk-core/endpoint_provider.rb', line 90

def default_rules
  path = File.join(File.dirname(__FILE__), '..', '..', 'endpoints.json')
  MultiJson.load(File.read(path))
end

Instance Method Details

#add_rule(options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :pattern (required, String)

    The endpoint pattern with optional placeholders. This is applied when rules match during resolution. Valid placeholders include:

    • ‘scheme`

    • ‘region`

    • ‘service`

    An example pattern:

    "#{scheme}://{service}.{region}.amazonaws.com"
    
  • :priority (Integer) — default: 100

    A number from 0 to 999. Rules with lower number have a higher priority and are evaluated first.

  • :region_prefix (String) — default: ""

    Causes regions with this prefix to match. Leave this empty if you want to match all regions.

  • :services (Array<String>)

    A list of services this rule applies to. Omit this option if you want this rule to apply to all services.

    The string must be the service endpoint prefix as a string. E.g. “s3”, “ec2”, “monitoring” (for cloud watch).



54
55
56
# File 'lib/aws-sdk-core/endpoint_provider.rb', line 54

def add_rule(options = {})
  @rules = (@rules + [new_rule(options)]).sort_by { |r| r['priority'] }
end

#resolve(options) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :service (required, String)
  • :region (required, String)
  • :scheme (required, String)

Returns:

  • (String, nil)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/aws-sdk-core/endpoint_provider.rb', line 16

def resolve(options)
  @rules.each do |rule_group|
    if region_matches?(rule_group, options)
      rule_group['rules'].each do |rule|
        if service_matches?(rule, options)
          return expand_endpoint(rule['config']['endpoint'], options)
        end
      end
    end
  end
  nil
end