| 1 | package VM::EC2::REST::customer_gateway; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use VM::EC2 ''; # important not to import anything! | ||
| 5 | package VM::EC2; # add methods to VM::EC2 | ||
| 6 | |||
| 7 | VM::EC2::Dispatch->register( | ||
| 8 | DescribeCustomerGateways => 'fetch_items,customerGatewaySet,VM::EC2::VPC::CustomerGateway', | ||
| 9 | CreateCustomerGateway => 'fetch_one,customerGateway,VM::EC2::VPC::CustomerGateway', | ||
| 10 | DeleteCustomerGateway => 'boolean', | ||
| 11 | ); | ||
| 12 | |||
| 13 | my $VEP = 'VM::EC2::ParmParser'; | ||
| 14 | |||
| 15 | =head1 NAME VM::EC2::REST::customer_gateway | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | use VM::EC2 ':vpc'; | ||
| 20 | |||
| 21 | =head1 METHODS | ||
| 22 | |||
| 23 | These methods control customer gateways for AWS VPNs. | ||
| 24 | |||
| 25 | Implemented: | ||
| 26 | CreateCustomerGateway | ||
| 27 | DeleteCustomerGateway | ||
| 28 | DescribeCustomerGateways | ||
| 29 | |||
| 30 | Unimplemented: | ||
| 31 | (none) | ||
| 32 | |||
| 33 | =head2 @gtwys = $ec2->describe_customer_gateways(-customer_gateway_id=>\@ids, | ||
| 34 | -filter =>\%filters) | ||
| 35 | |||
| 36 | =head2 @gtwys = $ec2->describe_customer_gateways(\@customer_gateway_ids) | ||
| 37 | |||
| 38 | =head2 @gtwys = $ec2->describe_customer_gateways(%filters) | ||
| 39 | |||
| 40 | Provides information on VPN customer gateways. | ||
| 41 | |||
| 42 | Returns a series of VM::EC2::VPC::CustomerGateway objects. | ||
| 43 | |||
| 44 | Optional parameters are: | ||
| 45 | |||
| 46 | -customer_gateway_id ID of the gateway(s) to return information on. | ||
| 47 | This can be a string scalar, or an arrayref. | ||
| 48 | |||
| 49 | -filter Tags and other filters to apply. | ||
| 50 | |||
| 51 | The filter argument is a hashreference in which the keys are the filter names, | ||
| 52 | and the values are the match strings. Some filters accept wildcards. | ||
| 53 | |||
| 54 | There are a number of filters, which are listed in full at | ||
| 55 | http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeCustomerGateways.html | ||
| 56 | |||
| 57 | Here is a alpha-sorted list of filter names: bgp-asn, customer-gateway-id, | ||
| 58 | ip-address, state, type, tag-key, tag-value, tag:key | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | sub describe_customer_gateways { | ||
| 63 | my $self = shift; | ||
| 64 | my %args = $VEP->args(-customer_gateway_id,@_); | ||
| 65 | my @params = $VEP->format_parms(\%args, | ||
| 66 | { | ||
| 67 | list_parm => 'CustomerGatewayId', | ||
| 68 | filter_parm => 'Filter', | ||
| 69 | }); | ||
| 70 | return $self->call('DescribeCustomerGateways',@params); | ||
| 71 | } | ||
| 72 | |||
| 73 | =head2 $cust_gtwy = $ec2->create_customer_gateway(-type =>$type, | ||
| 74 | -ip_address=>$ip, | ||
| 75 | -bgp_asn =>$asn) | ||
| 76 | |||
| 77 | Provides information to AWS about a VPN customer gateway device. The customer | ||
| 78 | gateway is the appliance at the customer end of the VPN connection (compared | ||
| 79 | to the virtual private gateway, which is the device at the AWS side of the | ||
| 80 | VPN connection). | ||
| 81 | |||
| 82 | Arguments: | ||
| 83 | |||
| 84 | -ip_address -- The IP address of the customer gateway appliance | ||
| 85 | |||
| 86 | -bgp_asn -- The Border Gateway Protocol (BGP) Autonomous System Number | ||
| 87 | (ASN) of the customer gateway | ||
| 88 | |||
| 89 | -type -- Optional as there is only currently (2012-06-15 API) only | ||
| 90 | one type (ipsec.1) | ||
| 91 | |||
| 92 | -ip -- Alias for -ip_address | ||
| 93 | |||
| 94 | Returns a L<VM::EC2::VPC::CustomerGateway> object on success. | ||
| 95 | |||
| 96 | =cut | ||
| 97 | |||
| 98 | sub create_customer_gateway { | ||
| 99 | my $self = shift; | ||
| 100 | my %args = @_; | ||
| 101 | $args{-type} ||= 'ipsec.1'; | ||
| 102 | $args{-ip_address} ||= $args{-ip}; | ||
| 103 | $args{-ip_address} or | ||
| 104 | croak "create_customer_gateway(): -ip_address argument missing"; | ||
| 105 | $args{-bgp_asn} or | ||
| 106 | croak "create_customer_gateway(): -bgp_asn argument missing"; | ||
| 107 | my @params = $VEP->format_parms(\%args, | ||
| 108 | { | ||
| 109 | single_parm => [qw(Type IpAddress BgpAsn)], | ||
| 110 | }); | ||
| 111 | return $self->call('CreateCustomerGateway',@params); | ||
| 112 | } | ||
| 113 | |||
| 114 | =head2 $success = $ec2->delete_customer_gateway(-customer_gateway_id=>$id) | ||
| 115 | |||
| 116 | =head2 $success = $ec2->delete_customer_gateway($id) | ||
| 117 | |||
| 118 | Deletes a VPN customer gateway. You must delete the VPN connection before | ||
| 119 | deleting the customer gateway. | ||
| 120 | |||
| 121 | Arguments: | ||
| 122 | |||
| 123 | -customer_gateway_id -- The ID of the customer gateway to delete | ||
| 124 | |||
| 125 | Returns true on successful deletion. | ||
| 126 | |||
| 127 | =cut | ||
| 128 | |||
| 129 | sub delete_customer_gateway { | ||
| 130 | my $self = shift; | ||
| 131 | my %args = $VEP->args(-customer_gateway_id,@_); | ||
| 132 | $args{-customer_gateway_id} or | ||
| 133 | croak "delete_customer_gateway(): -customer_gateway_id argument missing"; | ||
| 134 | my @params = $VEP->format_parms(\%args, | ||
| 135 | { | ||
| 136 | single_parm => 'CustomerGatewayId', | ||
| 137 | }); | ||
| 138 | return $self->call('DeleteCustomerGateway',@params); | ||
| 139 | } | ||
| 140 | |||
| 141 | =head1 SEE ALSO | ||
| 142 | |||
| 143 | L<VM::EC2> | ||
| 144 | |||
| 145 | =head1 AUTHOR | ||
| 146 | |||
| 147 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
| 148 | |||
| 149 | Copyright (c) 2011 Ontario Institute for Cancer Research | ||
| 150 | |||
| 151 | This package and its accompanying libraries is free software; you can | ||
| 152 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 153 | version 1, or at your option, any later version) or the Artistic | ||
| 154 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 155 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 156 | |||
| 157 | =cut | ||
| 158 | |||
| 159 | |||
| 160 | 1; |