Class: Aws::Partitions::Partition

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-partitions/partition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Partition

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 Partition.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :name (required, String)
  • :regions (required, Hash<String,Region>)
  • :services (required, Hash<String,Service>)


10
11
12
13
14
15
16
# File 'lib/aws-partitions/partition.rb', line 10

def initialize(options = {})
  @name = options[:name]
  @regions = options[:regions]
  @region_regex = options[:region_regex]
  @services = options[:services]
  @metadata = options[:metadata]
end

Instance Attribute Details

#metadataMetadata (readonly)

Returns The metadata for the partition.

Returns:

  • (Metadata)

    The metadata for the partition.



25
26
27
# File 'lib/aws-partitions/partition.rb', line 25

def 
  @metadata
end

#nameString (readonly)

Returns The partition name, e.g. “aws”, “aws-cn”, “aws-us-gov”.

Returns:

  • (String)

    The partition name, e.g. “aws”, “aws-cn”, “aws-us-gov”.



19
20
21
# File 'lib/aws-partitions/partition.rb', line 19

def name
  @name
end

#region_regexString (readonly)

Returns The regex representing the region format.

Returns:

  • (String)

    The regex representing the region format.



22
23
24
# File 'lib/aws-partitions/partition.rb', line 22

def region_regex
  @region_regex
end

Class Method Details

.build(partition) ⇒ 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.



77
78
79
80
81
82
83
84
# File 'lib/aws-partitions/partition.rb', line 77

def build(partition)
  Partition.new(
    name: partition['partition'],
    regions: build_regions(partition),
    region_regex: partition['regionRegex'],
    services: build_services(partition)
  )
end

Instance Method Details

#region(region_name) ⇒ Region

Parameters:

  • region_name (String)

    The name of the region, e.g. “us-east-1”.

Returns:

Raises:

  • (ArgumentError)

    Raises ‘ArgumentError` for unknown region name.



30
31
32
33
34
35
36
37
38
# File 'lib/aws-partitions/partition.rb', line 30

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

#region?(region_name) ⇒ Boolean

Returns true if the region is in the partition.

Parameters:

  • region_name (String)

    The name of the region, e.g. “us-east-1”.

Returns:

  • (Boolean)

    true if the region is in the partition.



47
48
49
# File 'lib/aws-partitions/partition.rb', line 47

def region?(region_name)
  @regions.key?(region_name)
end

#regionsArray<Region>

Returns:



41
42
43
# File 'lib/aws-partitions/partition.rb', line 41

def regions
  @regions.values
end

#service(service_name) ⇒ Service

Parameters:

  • service_name (String)

    The service module name.

Returns:

Raises:

  • (ArgumentError)

    Raises ‘ArgumentError` for unknown service name.



54
55
56
57
58
59
60
61
62
# File 'lib/aws-partitions/partition.rb', line 54

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

#service?(service_name) ⇒ Boolean

Returns true if the service is in the partition.

Parameters:

  • service_name (String)

    The service module name.

Returns:

  • (Boolean)

    true if the service is in the partition.



71
72
73
# File 'lib/aws-partitions/partition.rb', line 71

def service?(service_name)
  @services.key?(service_name)
end

#servicesArray<Service>

Returns:



65
66
67
# File 'lib/aws-partitions/partition.rb', line 65

def services
  @services.values
end