forked from goamz/goamz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package ec2 | ||
|
||
// RouteTable describes a route table which contains a set of rules, called routes | ||
// that are used to determine where network traffic is directed. | ||
// | ||
// See http://goo.gl/bI9hkg for more details. | ||
type RouteTable struct { | ||
Id string `xml:"routeTableId"` | ||
VpcId string `xml:"vpcId"` | ||
Routes []Route `xml:"routeSet>item"` | ||
Associations []RouteTableAssociation `xml:"associationSet>item"` | ||
PropagatingVgws []PropagatingVgw `xml:"propagatingVgwSet>item"` | ||
Tags []Tag `xml:"tagSet>item"` | ||
} | ||
|
||
// Route describes a route in a route table. | ||
// | ||
// See http://goo.gl/hE5Kxe for more details. | ||
type Route struct { | ||
DestinationCidrBlock string `xml:"destinationCidrBlock"` // The CIDR block used for the destination match. | ||
GatewayId string `xml:"gatewayId"` // The ID of a gateway attached to your VPC. | ||
InstanceId string `xml:"instanceId"` // The ID of a NAT instance in your VPC. | ||
InstanceOwnerId string `xml:"instanceOwnerId"` // The AWS account ID of the owner of the instance. | ||
NetworkInterfaceId string `xml:"networkInterfaceId"` // The ID of the network interface. | ||
State string `xml:"state"` // The state of the route. Valid values: active | blackhole | ||
Origin string `xml:"origin"` // Describes how the route was created. Valid values: Valid values: CreateRouteTable | CreateRoute | EnableVgwRoutePropagation | ||
VpcPeeringConnectionId string `xml:"vpcPeeringConnectionId"` // The ID of the VPC peering connection. | ||
} | ||
|
||
// RouteTableAssociation describes an association between a route table and a subnet. | ||
// | ||
// See http://goo.gl/BZB8o8 for more details. | ||
type RouteTableAssociation struct { | ||
Id string `xml:"routeTableAssociationId"` // The ID of the association between a route table and a subnet. | ||
RouteTableId string `xml:"routeTableId"` // The ID of the route table. | ||
SubnetId string `xml:"subnetId"` // The ID of the subnet. | ||
Main bool `xml:"main"` // Indicates whether this is the main route table. | ||
} | ||
|
||
// PropagatingVgw describes a virtual private gateway propagating route. | ||
// | ||
// See http://goo.gl/myGQtG for more details. | ||
type PropagatingVgw struct { | ||
GatewayId string `xml:"gatewayID"` | ||
} | ||
|
||
// DescribeRouteTablesResp represents a response from a DescribeRouteTables call | ||
// | ||
// See http://goo.gl/T3tVsg for more details. | ||
type DescribeRouteTablesResp struct { | ||
RequestId string `xml:"requestId"` | ||
RouteTables []RouteTable `xml:"routeTableSet>item"` | ||
} | ||
|
||
// DescribeRouteTables describes one or more of your route tables | ||
// | ||
// See http://goo.gl/S0RVos for more details. | ||
func (ec2 *EC2) DescribeRouteTables(routeTableIds []string, filter *Filter) (resp *DescribeRouteTablesResp, err error) { | ||
params := makeParams("DescribeRouteTables") | ||
addParamsList(params, "RouteTableId", routeTableIds) | ||
filter.addParams(params) | ||
resp = &DescribeRouteTablesResp{} | ||
err = ec2.query(params, resp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ec2_test | ||
|
||
import ( | ||
"github.com/goamz/goamz/ec2" | ||
"github.com/motain/gocheck" | ||
) | ||
|
||
func (s *S) TestDescribeRouteTables(c *gocheck.C) { | ||
testServer.Response(200, nil, DescribeRouteTablesExample) | ||
|
||
filter := ec2.NewFilter() | ||
filter.Add("key1", "value1") | ||
filter.Add("key2", "value2", "value3") | ||
|
||
resp, err := s.ec2.DescribeRouteTables([]string{"rt1", "rt2"}, nil) | ||
|
||
req := testServer.WaitRequest() | ||
c.Assert(req.Form["Action"], gocheck.DeepEquals, []string{"DescribeRouteTables"}) | ||
c.Assert(req.Form["RouteTableId.1"], gocheck.DeepEquals, []string{"rt1"}) | ||
c.Assert(req.Form["RouteTableId.2"], gocheck.DeepEquals, []string{"rt2"}) | ||
|
||
c.Assert(err, gocheck.IsNil) | ||
c.Assert(resp.RequestId, gocheck.Equals, "6f570b0b-9c18-4b07-bdec-73740dcf861aEXAMPLE") | ||
c.Assert(resp.RouteTables, gocheck.HasLen, 2) | ||
|
||
rt1 := resp.RouteTables[0] | ||
c.Assert(rt1.Id, gocheck.Equals, "rtb-13ad487a") | ||
c.Assert(rt1.VpcId, gocheck.Equals, "vpc-11ad4878") | ||
c.Assert(rt1.Routes, gocheck.DeepEquals, []ec2.Route{ | ||
{DestinationCidrBlock: "10.0.0.0/22", GatewayId: "local", State: "active", Origin: "CreateRouteTable"}, | ||
}) | ||
c.Assert(rt1.Associations, gocheck.DeepEquals, []ec2.RouteTableAssociation{ | ||
{Id: "rtbassoc-12ad487b", RouteTableId: "rtb-13ad487a", Main: true}, | ||
}) | ||
|
||
rt2 := resp.RouteTables[1] | ||
c.Assert(rt2.Id, gocheck.Equals, "rtb-f9ad4890") | ||
c.Assert(rt2.VpcId, gocheck.Equals, "vpc-11ad4878") | ||
c.Assert(rt2.Routes, gocheck.DeepEquals, []ec2.Route{ | ||
{DestinationCidrBlock: "10.0.0.0/22", GatewayId: "local", State: "active", Origin: "CreateRouteTable"}, | ||
{DestinationCidrBlock: "0.0.0.0/0", GatewayId: "igw-eaad4883", State: "active"}, | ||
}) | ||
c.Assert(rt2.Associations, gocheck.DeepEquals, []ec2.RouteTableAssociation{ | ||
{Id: "rtbassoc-faad4893", RouteTableId: "rtb-f9ad4890", SubnetId: "subnet-15ad487c"}, | ||
}) | ||
} |