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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
require 'fog/aws/models/compute/vpc'
module Fog
module AWS
class Compute
class Vpcs < Fog::Collection
attribute :filters
model Fog::AWS::Compute::VPC
# Creates a new VPC
#
# AWS.vpcs.new
#
# ==== Returns
#
# Returns the details of the new VPC
#
#>> AWS.vpcs.new
# <Fog::AWS::VPC::VPC
# id=nil,
# state=nil,
# cidr_block=nil,
# dhcp_options_id=nil
# tags=nil
# tenancy=nil
# >
#
def initialize(attributes)
self.filters ||= {}
super
end
# Returns an array of all VPCs that have been created
#
# AWS.vpcs.all
#
# ==== Returns
#
# Returns an array of all VPCs
#
#>> AWS.vpcs.all
# <Fog::AWS::VPC::VPCs
# filters={}
# [
# <Fog::AWS::VPC::VPC
# id="vpc-12345678",
# 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('vpc-id' => []) instead [light_black](#{caller.first})[/]")
filters_arg = {'vpc-id' => [*filters_arg]}
end
filters = filters_arg
data = service.describe_vpcs(filters).body
load(data['vpcSet'])
end
# Used to retrieve a VPC
# vpc_id is required to get the associated VPC information.
#
# You can run the following command to get the details:
# AWS.vpcs.get("vpc-12345678")
#
# ==== Returns
#
#>> AWS.vpcs.get("vpc-12345678")
# <Fog::AWS::Compute::VPC
# id="vpc-12345678",
# TODO
# >
#
def get(vpc_id)
if vpc_id
self.class.new(:service => service).all('vpc-id' => vpc_id).first
end
end
end
end
end
end
|