File: route_table.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 (64 lines) | stat: -rw-r--r-- 1,564 bytes parent folder | download | duplicates (4)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Fog
  module AWS
    class Compute
      class RouteTable < Fog::Model
        identity :id,                :aliases => 'routeTableId'

        attribute :vpc_id,           :aliases => 'vpcId'
        attribute :routes,           :aliases => 'routeSet'
        attribute :associations,     :aliases => 'associationSet'
        attribute :tags,             :aliases => 'tagSet'


        def initialize(attributes={})
          super
        end

        # Remove an existing route table
        #
        # route_tables.destroy
        #
        # ==== Returns
        #
        # True or false depending on the result
        #

        def destroy
          requires :id

          service.delete_route_table(id)
          true
        end

        # Create a route table
        #
        # >> routetable = connection.route_tables.new
        # >> routetable.save
        #
        # == Returns:
        #
        # True or an exception depending on the result. Keep in mind that this *creates* a new route table.
        #

        def save
          requires :vpc_id

          data = service.create_route_table(vpc_id).body['routeTable'].first
          new_attributes = data.reject {|key,value| key == 'requestId'}
          merge_attributes(new_attributes)
          true
        end

        private

        def associationSet=(new_association_set)
          merge_attributes(new_association_set.first || {})
        end

        def routeSet=(new_route_set)
          merge_attributes(new_route_set || {})
        end
      end
    end
  end
end