class Aws::Partitions::EndpointProvider
@api private
Constants
- STS_LEGACY_REGIONS
When sts_regional_endpoint is set to `legacy`, the endpoint pattern stays global for the following regions:
Public Class Methods
new(rules)
click to toggle source
Intentionally marked private. The format of the endpoint rules is an implementation detail. @api private
# File lib/aws-partitions/endpoint_provider.rb, line 31 def initialize(rules) @rules = rules end
Private Class Methods
default_provider()
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 145 def default_provider @default_provider ||= EndpointProvider.new(Partitions.defaults) end
dns_suffix_for(region)
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 139 def dns_suffix_for(region) default_provider.dns_suffix_for(region) end
resolve(region, service, sts_regional_endpoints = 'regional')
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 131 def resolve(region, service, sts_regional_endpoints = 'regional') default_provider.resolve(region, service, sts_regional_endpoints) end
signing_region(region, service)
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 135 def signing_region(region, service) default_provider.signing_region(region, service) end
Public Instance Methods
dns_suffix_for(region)
click to toggle source
@api private Use the static class methods instead.
# File lib/aws-partitions/endpoint_provider.rb, line 58 def dns_suffix_for(region) get_partition(region)['dnsSuffix'] end
resolve(region, service, sts_regional_endpoints)
click to toggle source
@param [String] region The region for the client. @param [String] service The endpoint prefix for the service, e.g.
"monitoring" for cloudwatch.
@param [String] sts_regional_endpoints [STS only] Whether to use
`legacy` (global endpoint for legacy regions) or `regional` mode for using regional endpoint for supported regions except 'aws-global'
@api private Use the static class methods instead.
# File lib/aws-partitions/endpoint_provider.rb, line 42 def resolve(region, service, sts_regional_endpoints) 'https://' + endpoint_for(region, service, sts_regional_endpoints) end
signing_region(region, service)
click to toggle source
@api private Use the static class methods instead.
# File lib/aws-partitions/endpoint_provider.rb, line 47 def signing_region(region, service) get_partition(region) .fetch('services', {}) .fetch(service, {}) .fetch('endpoints', {}) .fetch(region, {}) .fetch('credentialScope', {}) .fetch('region', region) end
Private Instance Methods
default_partition()
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 125 def default_partition @rules['partitions'].find { |p| p['partition'] == 'aws' } || @rules['partitions'].first end
endpoint_for(region, service, sts_regional_endpoints)
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 64 def endpoint_for(region, service, sts_regional_endpoints) partition = get_partition(region) service_cfg = partition.fetch('services', {}).fetch(service, {}) # Find the default endpoint default_endpoint = service_cfg .fetch('defaults', {}) .fetch('hostname', partition['defaults']['hostname']) endpoints = service_cfg.fetch('endpoints', {}) # Check for sts legacy behavior sts_legacy = service == 'sts' && sts_regional_endpoints == 'legacy' && STS_LEGACY_REGIONS.include?(region) is_global = !endpoints.key?(region) && service_cfg['isRegionalized'] == false # Check for global endpoint. if sts_legacy || is_global region = service_cfg.fetch('partitionEndpoint', region) end # Check for service/region level endpoint. endpoint = endpoints .fetch(region, {}) .fetch('hostname', default_endpoint) # Replace placeholders from the endpoints endpoint.sub('{region}', region) .sub('{service}', service) .sub('{dnsSuffix}', partition['dnsSuffix']) end
get_partition(region_or_partition)
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 99 def get_partition(region_or_partition) partition_containing_region(region_or_partition) || partition_matching_region(region_or_partition) || partition_matching_name(region_or_partition) || default_partition end
partition_containing_region(region)
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 106 def partition_containing_region(region) @rules['partitions'].find do |p| p['regions'].key?(region) end end
partition_matching_name(partition_name)
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 121 def partition_matching_name(partition_name) @rules['partitions'].find { |p| p['partition'] == partition_name } end
partition_matching_region(region)
click to toggle source
# File lib/aws-partitions/endpoint_provider.rb, line 112 def partition_matching_region(region) @rules['partitions'].find do |p| region.match(p['regionRegex']) || p['services'].values.find do |svc| svc['endpoints'].key?(region) if svc.key?('endpoints') end end end