class Aws::Partitions::Region

Attributes

description[R]

@return [String] A short description of this region.

name[R]

@return [String] The name of this region, e.g. “us-east-1”.

partition_name[R]

@return [String] The partition this region exists in, e.g. “aws”,

"aws-cn", "aws-us-gov".
services[R]

@return [Set<String>] The list of services available in this region.

Service names are the module names as used by the AWS SDK
for Ruby.

Public Class Methods

build(region_name, region, partition) click to toggle source

@api private

# File lib/aws-sdk-core/partitions/region.rb, line 37
def build(region_name, region, partition)
  Region.new(
    name: region_name,
    description: region['description'],
    partition_name: partition['partition'],
    services: region_services(region_name, partition)
  )
end
new(options = {}) click to toggle source

@option options [required, String] :name @option options [required, String] :description @option options [required, String] :partition_name @option options [required, Set<String>] :services @api private

# File lib/aws-sdk-core/partitions/region.rb, line 12
def initialize(options = {})
  @name = options[:name]
  @description = options[:description]
  @partition_name = options[:partition_name]
  @services = options[:services]
end

Private Class Methods

region_services(region_name, partition) click to toggle source
# File lib/aws-sdk-core/partitions/region.rb, line 48
def region_services(region_name, partition)
  Partitions.service_ids.inject(Set.new) do |services, (svc_name, svc_id)|
    if svc = partition['services'][svc_id]
      services << svc_name if service_in_region?(svc, region_name)
    else
      #raise "missing endpoints for #{svc_name} / #{svc_id}"
    end
    services
  end
end
service_in_region?(svc, region_name) click to toggle source
# File lib/aws-sdk-core/partitions/region.rb, line 59
def service_in_region?(svc, region_name)
  svc_endpoints_contains_region?(svc, region_name) ||
  svc_partition_endpoint_matches_region?(svc, region_name)
end
svc_endpoints_contains_region?(svc, region_name) click to toggle source
# File lib/aws-sdk-core/partitions/region.rb, line 64
def svc_endpoints_contains_region?(svc, region_name)
  svc['endpoints'].key?(region_name)
end
svc_partition_endpoint_matches_region?(svc, region_name) click to toggle source
# File lib/aws-sdk-core/partitions/region.rb, line 68
def svc_partition_endpoint_matches_region?(svc, region_name)
  if pe = svc['partitionEndpoint']
    region = svc['endpoints'][pe].fetch('credentialScope', {})['region']
    region == region_name
  end
end