File: cluster_subnet_group_parser.rb

package info (click to toggle)
ruby-fog-aws 3.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,816 kB
  • sloc: ruby: 68,587; makefile: 6
file content (50 lines) | stat: -rw-r--r-- 1,388 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Fog
  module Parsers
    module Redshift
      module AWS
        class ClusterSubnetGroupParser < Fog::Parsers::Base
          # :cluster_subnet_group_name - (String)
          # :description - (String)
          # :vpc_id - (String)
          # :subnet_group_status - (String)
          # :subnets - (Array)
          #   :subnet_identifier - (String)
          #   :subnet_availability_zone - (Hash)
          #     :name - (String)
          #   :subnet_status - (String)

          def reset
            @response = { 'Subnets' => [] }
          end

          def fresh_subnet
            {'SubnetAvailabilityZone'=>{}}
          end

          def start_element(name, attrs = [])
            super
            case name
            when 'Subnets'
              @subnet = fresh_subnet
            end
          end

          def end_element(name)
            super
            case name
            when 'ClusterSubnetGroupName', 'Desciption', 'VpcId', 'SubnetGroupStatus'
              @response[name] = value
            when 'SubnetIdentifier', 'SubnetStatus'
              @subnet[name] = value
            when 'Name'
              @subnet['SubnetAvailabilityZone'][name] = value
            when 'Subnet'
              @response['Subnets'] << {name => @subnet}
              @subnet = fresh_subnet
            end
          end
        end
      end
    end
  end
end