<s> """<STR_LIT>""" <EOL> from boto . ec2 . connection import EC2Connection <EOL> from boto . resultset import ResultSet <EOL> from boto . vpc . vpc import VPC <EOL> from boto . vpc . customergateway import CustomerGateway <EOL> from boto . vpc . routetable import RouteTable <EOL> from boto . vpc . internetgateway import InternetGateway <EOL> from boto . vpc . vpngateway import VpnGateway , Attachment <EOL> from boto . vpc . dhcpoptions import DhcpOptions <EOL> from boto . vpc . subnet import Subnet <EOL> from boto . vpc . vpnconnection import VpnConnection <EOL> class VPCConnection ( EC2Connection ) : <EOL> def get_all_vpcs ( self , vpc_ids = None , filters = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if vpc_ids : <EOL> self . build_list_params ( params , vpc_ids , '<STR_LIT>' ) <EOL> if filters : <EOL> self . build_filter_params ( params , dict ( filters ) ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , VPC ) ] ) <EOL> def create_vpc ( self , cidr_block ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : cidr_block } <EOL> return self . get_object ( '<STR_LIT>' , params , VPC ) <EOL> def delete_vpc ( self , vpc_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : vpc_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def get_all_route_tables ( self , route_table_ids = None , filters = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if route_table_ids : <EOL> self . build_list_params ( params , route_table_ids , "<STR_LIT>" ) <EOL> if filters : <EOL> self . build_filter_params ( params , dict ( filters ) ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , RouteTable ) ] ) <EOL> def associate_route_table ( self , route_table_id , subnet_id ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : route_table_id , <EOL> '<STR_LIT>' : subnet_id <EOL> } <EOL> result = self . get_object ( '<STR_LIT>' , params , ResultSet ) <EOL> return result . associationId <EOL> def disassociate_route_table ( self , association_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : association_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def create_route_table ( self , vpc_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : vpc_id } <EOL> return self . get_object ( '<STR_LIT>' , params , RouteTable ) <EOL> def delete_route_table ( self , route_table_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : route_table_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def create_route ( self , route_table_id , destination_cidr_block , gateway_id = None , instance_id = None ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : route_table_id , <EOL> '<STR_LIT>' : destination_cidr_block <EOL> } <EOL> if gateway_id is not None : <EOL> params [ '<STR_LIT>' ] = gateway_id <EOL> elif instance_id is not None : <EOL> params [ '<STR_LIT>' ] = instance_id <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def delete_route ( self , route_table_id , destination_cidr_block ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : route_table_id , <EOL> '<STR_LIT>' : destination_cidr_block <EOL> } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def get_all_internet_gateways ( self , internet_gateway_ids = None , filters = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if internet_gateway_ids : <EOL> self . build_list_params ( params , internet_gateway_ids , '<STR_LIT>' ) <EOL> if filters : <EOL> self . build_filter_params ( params , dict ( filters ) ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , InternetGateway ) ] ) <EOL> def create_internet_gateway ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . get_object ( '<STR_LIT>' , { } , InternetGateway ) <EOL> def delete_internet_gateway ( self , internet_gateway_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : internet_gateway_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def attach_internet_gateway ( self , internet_gateway_id , vpc_id ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : internet_gateway_id , <EOL> '<STR_LIT>' : vpc_id <EOL> } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def detach_internet_gateway ( self , internet_gateway_id , vpc_id ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : internet_gateway_id , <EOL> '<STR_LIT>' : vpc_id <EOL> } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def get_all_customer_gateways ( self , customer_gateway_ids = None , filters = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if customer_gateway_ids : <EOL> self . build_list_params ( params , customer_gateway_ids , '<STR_LIT>' ) <EOL> if filters : <EOL> self . build_filter_params ( params , dict ( filters ) ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , CustomerGateway ) ] ) <EOL> def create_customer_gateway ( self , type , ip_address , bgp_asn ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : type , <EOL> '<STR_LIT>' : ip_address , <EOL> '<STR_LIT>' : bgp_asn } <EOL> return self . get_object ( '<STR_LIT>' , params , CustomerGateway ) <EOL> def delete_customer_gateway ( self , customer_gateway_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : customer_gateway_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def get_all_vpn_gateways ( self , vpn_gateway_ids = None , filters = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if vpn_gateway_ids : <EOL> self . build_list_params ( params , vpn_gateway_ids , '<STR_LIT>' ) <EOL> if filters : <EOL> self . build_filter_params ( params , dict ( filters ) ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , VpnGateway ) ] ) <EOL> def create_vpn_gateway ( self , type , availability_zone = None ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : type } <EOL> if availability_zone : <EOL> params [ '<STR_LIT>' ] = availability_zone <EOL> return self . get_object ( '<STR_LIT>' , params , VpnGateway ) <EOL> def delete_vpn_gateway ( self , vpn_gateway_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : vpn_gateway_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def attach_vpn_gateway ( self , vpn_gateway_id , vpc_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : vpn_gateway_id , <EOL> '<STR_LIT>' : vpc_id } <EOL> return self . get_object ( '<STR_LIT>' , params , Attachment ) <EOL> def get_all_subnets ( self , subnet_ids = None , filters = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if subnet_ids : <EOL> self . build_list_params ( params , subnet_ids , '<STR_LIT>' ) <EOL> if filters : <EOL> self . build_filter_params ( params , dict ( filters ) ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , Subnet ) ] ) <EOL> def create_subnet ( self , vpc_id , cidr_block , availability_zone = None ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : vpc_id , <EOL> '<STR_LIT>' : cidr_block } <EOL> if availability_zone : <EOL> params [ '<STR_LIT>' ] = availability_zone <EOL> return self . get_object ( '<STR_LIT>' , params , Subnet ) <EOL> def delete_subnet ( self , subnet_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : subnet_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def get_all_dhcp_options ( self , dhcp_options_ids = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if dhcp_options_ids : <EOL> self . build_list_params ( params , dhcp_options_ids , '<STR_LIT>' ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , DhcpOptions ) ] ) <EOL> def create_dhcp_options ( self , vpc_id , cidr_block , availability_zone = None ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : vpc_id , <EOL> '<STR_LIT>' : cidr_block } <EOL> if availability_zone : <EOL> params [ '<STR_LIT>' ] = availability_zone <EOL> return self . get_object ( '<STR_LIT>' , params , DhcpOptions ) <EOL> def delete_dhcp_options ( self , dhcp_options_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : dhcp_options_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def associate_dhcp_options ( self , dhcp_options_id , vpc_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : dhcp_options_id , <EOL> '<STR_LIT>' : vpc_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) <EOL> def get_all_vpn_connections ( self , vpn_connection_ids = None , filters = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if vpn_connection_ids : <EOL> self . build_list_params ( params , vpn_connection_ids , '<STR_LIT>' ) <EOL> if filters : <EOL> self . build_filter_params ( params , dict ( filters ) ) <EOL> return self . get_list ( '<STR_LIT>' , params , [ ( '<STR_LIT>' , VpnConnection ) ] ) <EOL> def create_vpn_connection ( self , type , customer_gateway_id , vpn_gateway_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : type , <EOL> '<STR_LIT>' : customer_gateway_id , <EOL> '<STR_LIT>' : vpn_gateway_id } <EOL> return self . get_object ( '<STR_LIT>' , params , VpnConnection ) <EOL> def delete_vpn_connection ( self , vpn_connection_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : vpn_connection_id } <EOL> return self . get_status ( '<STR_LIT>' , params ) </s>
