Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Add ModifySubnetAttribute #95

Merged
merged 1 commit into from
Sep 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,19 @@ type CreateSubnetResp struct {
Subnet Subnet `xml:"subnet"`
}

// The ModifySubnetAttribute request parameters
//
// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-ModifySubnetAttribute.html
type ModifySubnetAttribute struct {
SubnetId string
MapPublicIpOnLaunch bool
}

type ModifySubnetAttributeResp struct {
RequestId string `xml:"requestId"`
Return bool `xml:"return"`
}

// Response to a DescribeInternetGateways request.
type InternetGatewaysResp struct {
RequestId string `xml:"requestId"`
Expand Down Expand Up @@ -2331,6 +2344,22 @@ func (ec2 *EC2) DeleteSubnet(id string) (resp *SimpleResp, err error) {
return
}

// ModifySubnetAttribute
//
// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-ModifySubnetAttribute.html
func (ec2 *EC2) ModifySubnetAttribute(options *ModifySubnetAttribute) (resp *ModifySubnetAttributeResp, err error) {
params := makeParams("ModifySubnetAttribute")
params["SubnetId"] = options.SubnetId
params["MapPublicIpOnLaunch.Value"] = options.MapPublicIpOnLaunch

resp = &SimpleResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}

// DescribeSubnets
//
// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html
Expand Down
18 changes: 18 additions & 0 deletions ec2/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,24 @@ func (s *S) TestCreateSubnet(c *C) {
c.Assert(resp.Subnet.AvailableIpAddressCount, Equals, 251)
}

func (s *S) TestModifySubnetAttribute(c *C) {
testServer.Response(200, nil, ModifySubnetAttributeExample)

options := &ec2.ModifySubnetAttribute{
SubnetId: "foo",
MapPublicIpOnLaunch: true
}

resp, err := s.ec2.ModifySubnetAttribute(options)

req := testServer.WaitRequest()
c.Assert(req.Form["SubnetId"], DeepEquals, []string{"foo"})
c.Assert(req.Form["MapPublicIpOnLaunch"], Equals, true)

c.Assert(err, IsNil)
c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
}

func (s *S) TestResetImageAttribute(c *C) {
testServer.Response(200, nil, ResetImageAttributeExample)

Expand Down
8 changes: 8 additions & 0 deletions ec2/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,14 @@ var CreateSubnetExample = `
</CreateSubnetResponse>
`

// http://goo.gl/tu2Kxm
var ModifySubnetAttributeExample = `
<ModifySubnetAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2014-06-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<return>true</return>
</ModifySubnetAttributeResponse>
`

// http://goo.gl/r6ZCPm
var ResetImageAttributeExample = `
<ResetImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2014-06-15/">
Expand Down