@api private
# File lib/aws-sdk-core/endpoint_provider.rb, line 5 def initialize(rules) @rules = rules end
# File lib/aws-sdk-core/endpoint_provider.rb, line 89 def default_provider @default_provider ||= EndpointProvider.new(Partitions.defaults) end
# File lib/aws-sdk-core/endpoint_provider.rb, line 79 def resolve(region, service) default_provider.resolve(region, service) end
# File lib/aws-sdk-core/endpoint_provider.rb, line 83 def signing_region(region, service) default_provider.signing_region(region, service) end
# File lib/aws-sdk-core/endpoint_provider.rb, line 9 def resolve(region, service) "https://" + endpoint_for(region, service) end
# File lib/aws-sdk-core/endpoint_provider.rb, line 13 def signing_region(region, service) get_partition(region). fetch("services", {}). fetch(service, {}). fetch("endpoints", {}). fetch(region, {}). fetch("credentialScope", {}). fetch("region", region) end
# File lib/aws-sdk-core/endpoint_provider.rb, line 45 def default_endpoint(partition, service, region) hostname_template = partition["defaults"]["hostname"] hostname_template. sub('{region}', region). sub('{service}', service). sub('{dnsSuffix}', partition["dnsSuffix"]) end
# File lib/aws-sdk-core/endpoint_provider.rb, line 72 def default_partition @rules['partitions'].find { |p| p["partition"] == "aws" } || @rules['partitions'].first end
# File lib/aws-sdk-core/endpoint_provider.rb, line 25 def endpoint_for(region, service) partition = get_partition(region) endpoint = default_endpoint(partition, service, region) service_cfg = partition.fetch("services", {}).fetch(service, {}) # Check for service-level default endpoint. endpoint = service_cfg.fetch("defaults", {}).fetch("hostname", endpoint) # Check for global endpoint. if service_cfg["isRegionalized"] == false region = service_cfg.fetch("partitionEndpoint", region) end # Check for service/region level endpoint. endpoint = service_cfg.fetch("endpoints", {}). fetch(region, {}).fetch("hostname", endpoint) endpoint end
# File lib/aws-sdk-core/endpoint_provider.rb, line 53 def get_partition(region) partition_containing_region(region) || partition_matching_region(region) || default_partition end
# File lib/aws-sdk-core/endpoint_provider.rb, line 59 def partition_containing_region(region) @rules['partitions'].find do |p| p['regions'].key?(region) end end
# File lib/aws-sdk-core/endpoint_provider.rb, line 65 def partition_matching_region(region) @rules['partitions'].find do |p| region.match(p["regionRegex"]) || p['services'].values.find { |svc| svc['endpoints'].key?(region) } end end