Class: Aws::Partitions::PartitionList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws-partitions/partition_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePartitionList

Returns a new instance of PartitionList.



9
10
11
# File 'lib/aws-partitions/partition_list.rb', line 9

def initialize
  @partitions = {}
end

Class Method Details

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



104
105
106
107
108
109
# File 'lib/aws-partitions/partition_list.rb', line 104

def build(partitions)
  partitions['partitions'].inject(PartitionList.new) do |list, partition|
    list.add_partition(Partition.build(partition))
    list
  end
end

Instance Method Details

#add_partition(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.

Parameters:



37
38
39
40
41
42
43
# File 'lib/aws-partitions/partition_list.rb', line 37

def add_partition(partition)
  if Partition === partition
    @partitions[partition.name] = partition
  else
    raise ArgumentError, "expected Partition, got #{partition.class}"
  end
end

#clearObject

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.

Removed all partitions.



80
81
82
# File 'lib/aws-partitions/partition_list.rb', line 80

def clear
  @partitions = {}
end

#each(&block) ⇒ Enumerator<Partition>

Returns:



14
15
16
# File 'lib/aws-partitions/partition_list.rb', line 14

def each(&block)
  @partitions.each_value(&block)
end

#merge_metadata(partitions_metadata) ⇒ 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.

Parameters:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/aws-partitions/partition_list.rb', line 47

def ()
  ['partitions'].each do ||
    outputs = ['outputs']

    if existing = @partitions[['id']]
      @partitions[['id']] = Partition.new(
        name: existing.name,
        regions: (
          ['id'],
          ['regions'],
          existing),
        region_regex: ['regionRegex'],
        services: existing.services.each_with_object({}) do |s, services|
          services[s.name] = s
        end,
        metadata: outputs
      )
    else
      @partitions[['id']] = Partition.new(
        name: ['id'],
        regions: (
          ['id'], ['regions']
        ),
        region_regex: ['regionRegex'],
        services: {},
        metadata: outputs
      )
    end
  end
end

#partition(partition_name) ⇒ Partition

Parameters:

  • partition_name (String)

Returns:



20
21
22
23
24
25
26
27
28
# File 'lib/aws-partitions/partition_list.rb', line 20

def partition(partition_name)
  if @partitions.key?(partition_name)
    @partitions[partition_name]
  else
    msg = "invalid partition name #{partition_name.inspect}; valid "\
          "partition names include %s" % [@partitions.keys.join(', ')]
    raise ArgumentError, msg
  end
end

#partitionsArray<Partition>

Returns:



31
32
33
# File 'lib/aws-partitions/partition_list.rb', line 31

def partitions
  @partitions.values
end