Class: ZAWS::External::AWSCLI::Generators::Result::EC2::RouteTables

Inherits:
Object
  • Object
show all
Defined in:
lib/zaws/external/awscli/generators/result/ec2/route_tables.rb

Instance Method Summary collapse

Constructor Details

#initializeRouteTables

Returns a new instance of RouteTables.



8
9
10
11
12
13
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 8

def initialize
  @route_tables= {}
  @route_tables["RouteTables"]= []
  @route_tables["Associations"]= []
  self
end

Instance Method Details

#add(route_tables) ⇒ Object



36
37
38
39
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 36

def add(route_tables)
  @route_tables["RouteTables"].concat(route_tables.get_route_tables_array)
  self
end

#associate_subnets(route_table_number, subnets) ⇒ Object



47
48
49
50
51
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 47

def associate_subnets(route_table_number, subnets)
  resize_route_tables_array(route_table_number)
  @route_tables["RouteTables"][route_table_number]["Associations"].concat(subnets.get_subnets_array)
  self
end

#get_jsonObject



59
60
61
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 59

def get_json
  @route_tables.to_json
end

#get_json_single_route_table(index) ⇒ Object



63
64
65
66
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 63

def get_json_single_route_table(index)
  single={"RouteTable" => @route_tables["RouteTables"][index]}
  single.to_json
end

#get_route_tables_arrayObject



68
69
70
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 68

def get_route_tables_array
  @route_tables["RouteTables"]
end

#propagate_to_virtual_gateway(route_table_number, gateway) ⇒ Object



53
54
55
56
57
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 53

def propagate_to_virtual_gateway(route_table_number, gateway)
  resize_route_tables_array(route_table_number)
  @route_tables["RouteTables"][route_table_number]["PropagatingVgws"] << gateway.get_hash
  self
end

#resize_route_tables_array(index) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 27

def resize_route_tables_array(index)
  while index > @route_tables["RouteTables"].length-1
    @route_tables["RouteTables"].push({})
  end
  @route_tables["RouteTables"][index]["Associations"] ||= []
  @route_tables["RouteTables"][index]["PropagatingVgws"] ||= []
  @route_tables["RouteTables"][index]["Routes"] ||= []
end

#route_table_id(route_table_number, id) ⇒ Object



21
22
23
24
25
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 21

def route_table_id(route_table_number, id)
  resize_route_tables_array(route_table_number)
  @route_tables["RouteTables"][route_table_number]["RouteTableId"]=id
  self
end

#routes(route_table_number, routes) ⇒ Object



41
42
43
44
45
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 41

def routes(route_table_number, routes)
  resize_route_tables_array(route_table_number)
  @route_tables["RouteTables"][route_table_number]["Routes"].concat(routes.get_route_array)
  self
end

#vpc_id(route_table_number, vpc_id) ⇒ Object



15
16
17
18
19
# File 'lib/zaws/external/awscli/generators/result/ec2/route_tables.rb', line 15

def vpc_id(route_table_number, vpc_id)
  resize_route_tables_array(route_table_number)
  @route_tables["RouteTables"][route_table_number]["VpcId"]=vpc_id
  self
end