class Aws::Partitions::Partition
Attributes
@return [String] The partition name, e.g. “aws”, “aws-cn”, “aws-us-gov”.
Public Class Methods
@api private
# File lib/aws-partitions/partition.rb, line 69 def build(partition) Partition.new( name: partition['partition'], regions: build_regions(partition), services: build_services(partition) ) end
@option options [required, String] :name @option options [required, Hash<String,Region>] :regions @option options [required, Hash<String,Service>] :services @api private
# File lib/aws-partitions/partition.rb, line 10 def initialize(options = {}) @name = options[:name] @regions = options[:regions] @services = options[:services] end
Private Class Methods
@param [Hash] partition @return [Hash<String,Region>]
# File lib/aws-partitions/partition.rb, line 81 def build_regions(partition) partition['regions'].each_with_object({}) do |(region_name, region), regions| next if region_name == "#{partition['partition']}-global" regions[region_name] = Region.build( region_name, region, partition ) end end
@param [Hash] partition @return [Hash<String,Service>]
# File lib/aws-partitions/partition.rb, line 94 def build_services(partition) Partitions.service_ids.each_with_object({}) do |(service_name, service), services| service_data = partition['services'].fetch( service, 'endpoints' => {} ) services[service_name] = Service.build( service_name, service_data, partition ) end end
Public Instance Methods
@param [String] region_name The name of the region, e.g. “us-east-1”. @return [Region] @raise [ArgumentError] Raises `ArgumentError` for unknown region name.
# File lib/aws-partitions/partition.rb, line 22 def region(region_name) if @regions.key?(region_name) @regions[region_name] else msg = "invalid region name #{region_name.inspect}; valid region "\ "names include #{@regions.keys.join(', ')}" raise ArgumentError, msg end end
@param [String] region_name The name of the region, e.g. “us-east-1”. @return [Boolean] true if the region is in the partition.
# File lib/aws-partitions/partition.rb, line 39 def region?(region_name) @regions.key?(region_name) end
@return [Array<Region>]
# File lib/aws-partitions/partition.rb, line 33 def regions @regions.values end
@param [String] service_name The service module name. @return [Service] @raise [ArgumentError] Raises `ArgumentError` for unknown service name.
# File lib/aws-partitions/partition.rb, line 46 def service(service_name) if @services.key?(service_name) @services[service_name] else msg = "invalid service name #{service_name.inspect}; valid service "\ "names include #{@services.keys.join(', ')}" raise ArgumentError, msg end end
@param [String] service_name The service module name. @return [Boolean] true if the service is in the partition.
# File lib/aws-partitions/partition.rb, line 63 def service?(service_name) @services.key?(service_name) end
@return [Array<Service>]
# File lib/aws-partitions/partition.rb, line 57 def services @services.values end