1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/models/compute/route_tables.rb

89 lines
2.2 KiB
Ruby
Raw Normal View History

require 'fog/core/collection'
require 'fog/aws/models/compute/route_table'
module Fog
module Compute
2015-01-02 12:34:40 -05:00
class AWS
class RouteTables < Fog::Collection
attribute :filters
model Fog::Compute::AWS::RouteTable
# Creates a new route table
#
2015-01-02 12:34:40 -05:00
# AWS.route_tables.new
#
# ==== Returns
#
# Returns the details of the new route table
#
2015-01-02 12:34:40 -05:00
#>> AWS.route_tables.new
# <Fog::Compute::AWS::RouteTable
# id=nil,
# vpc_id=nil,
# routes=nil,
# associations=nil,
# tags=nil
# >
#
def initialize(attributes)
self.filters ||= {}
super
end
# Returns an array of all route tables that have been created
#
2015-01-02 12:34:40 -05:00
# AWS.route_tables.all
#
# ==== Returns
#
# Returns an array of all route tables
#
2015-01-02 12:34:40 -05:00
#>> AWS.route_tables.all
# <Fog::Compute::AWS::RouteTables
# filters={}
# [
# <Fog::Compute::AWS::RouteTable
# id="rtb-41e8552f",
# TODO
# >
# ]
# >
#
def all(filters_arg = filters)
unless filters_arg.is_a?(Hash)
Fog::Logger.warning("all with #{filters_arg.class} param is deprecated, use all('route-table-id' => []) instead [light_black](#{caller.first})[/]")
filters_arg = {'route-table-id' => [*filters_arg]}
end
filters = filters_arg
data = service.describe_route_tables(filters).body
load(data['routeTableSet'])
end
# Used to retrieve a route table
# route_table_id is required to get the associated route table information.
#
# You can run the following command to get the details:
2015-01-02 12:34:40 -05:00
# AWS.route_tables.get("rtb-41e8552f")
#
# ==== Returns
#
2015-01-02 12:34:40 -05:00
#>> AWS.route_tables.get("rtb-41e8552f")
# <Fog::Compute::AWS::RouteTable
# id="rtb-41e8552f",
# TODO
# >
#
def get(route_table_id)
if route_table_id
self.class.new(:service => service).all('route-table-id' => route_table_id).first
end
end
end
end
end
end