Skip to content

Commit

Permalink
Added DescribeDBParameterGroups and DeleteDBParameterGroup RDS APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Costanzo committed Oct 20, 2014
1 parent 835bb75 commit 87d924a
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
53 changes: 53 additions & 0 deletions rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ type DBSnapshot struct {
VpcId string `xml:"VpcId"`
}

type DBParameterGroup struct {
DBParameterGroupFamily string `xml:"DBParameterGroupFamily"`
DBParameterGroupName string `xml:"DBParameterGroupName"`
Description string `xml:"Description"`
}

// ----------------------------------------------------------------------------
// Create

Expand Down Expand Up @@ -511,6 +517,32 @@ func (rds *Rds) DescribeDBSnapshots(options *DescribeDBSnapshots) (resp *Describ
return
}

// DescribeDBParameterGroups request params
type DescribeDBParameterGroups struct {
DBParameterGroupName string
}

type DescribeDBParameterGroupsResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
DBParameterGroups []DBParameterGroup `xml:"DescribeDBParameterGroupsResult>DBParameterGroups>DBParameterGroup"`
}

func (rds *Rds) DescribeDBParameterGroups(options *DescribeDBParameterGroups) (resp *DescribeDBParameterGroupsResp, err error) {
params := makeParams("DescribeDBParameterGroups")

params["DBParameterGroupName"] = options.DBParameterGroupName

resp = &DescribeDBParameterGroupsResp{}

err = rds.query(params, resp)

if err != nil {
resp = nil
}

return
}

// DeleteDBInstance request params
type DeleteDBInstance struct {
FinalDBSnapshotIdentifier string
Expand Down Expand Up @@ -584,6 +616,27 @@ func (rds *Rds) DeleteDBSubnetGroup(options *DeleteDBSubnetGroup) (resp *SimpleR
return
}

// DeleteDBParameterGroup request params
type DeleteDBParameterGroup struct {
DBParameterGroupName string
}

func (rds *Rds) DeleteDBParameterGroup(options *DeleteDBParameterGroup) (resp *SimpleResp, err error) {
params := makeParams("DeleteDBParameterGroup")

params["DBParameterGroupName"] = options.DBParameterGroupName

resp = &SimpleResp{}

err = rds.query(params, resp)

if err != nil {
resp = nil
}

return
}

type RestoreDBInstanceFromDBSnapshot struct {
DBInstanceIdentifier string
DBSnapshotIdentifier string
Expand Down
35 changes: 35 additions & 0 deletions rds/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,25 @@ func (s *S) Test_DescribeDBSubnetGroups(c *C) {
c.Assert(resp.DBSubnetGroups[0].VpcId, DeepEquals, "vpc-e7abbdce")
}

func (s *S) Test_DescribeDBParameterGroups(c *C) {
testServer.Response(200, nil, DescribeDBParameterGroupsExample)

options := rds.DescribeDBParameterGroups{
DBParameterGroupName: "mydbparamgroup3",
}

resp, err := s.rds.DescribeDBParameterGroups(&options)
req := testServer.WaitRequest()

c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeDBParameterGroups"})
c.Assert(req.Form["DBParameterGroupName"], DeepEquals, []string{"mydbparamgroup3"})
c.Assert(err, IsNil)
c.Assert(resp.RequestId, Equals, "b75d527a-b98c-11d3-f272-7cd6cce12cc5")
c.Assert(resp.DBParameterGroups[0].DBParameterGroupFamily, Equals, "mysql5.6")
c.Assert(resp.DBParameterGroups[0].Description, Equals, "My new DB Parameter Group")
c.Assert(resp.DBParameterGroups[0].DBParameterGroupName, Equals, "mydbparamgroup3")
}

func (s *S) Test_DeleteDBInstance(c *C) {
testServer.Response(200, nil, DeleteDBInstanceExample)

Expand Down Expand Up @@ -250,6 +269,22 @@ func (s *S) Test_DeleteDBSubnetGroup(c *C) {
c.Assert(resp.RequestId, Equals, "6295e5ab-bbf3-11d3-f4c6-37db295f7674")
}

func (s *S) Test_DeleteDBParameterGroup(c *C) {
testServer.Response(200, nil, DeleteDBParameterGroupExample)

options := rds.DeleteDBParameterGroup{
DBParameterGroupName: "mydbparamgroup3",
}

resp, err := s.rds.DeleteDBParameterGroup(&options)
req := testServer.WaitRequest()

c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteDBParameterGroup"})
c.Assert(req.Form["DBParameterGroupName"], DeepEquals, []string{"mydbparamgroup3"})
c.Assert(err, IsNil)
c.Assert(resp.RequestId, Equals, "cad6c267-ba25-11d3-fe11-33d33a9bb7e3")
}

func (s *S) Test_AuthorizeDBSecurityGroupIngress(c *C) {
testServer.Response(200, nil, AuthorizeDBSecurityGroupIngressExample)

Expand Down
26 changes: 26 additions & 0 deletions rds/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,29 @@ var CreateDBParameterGroupExample = `
</ResponseMetadata>
</CreateDBParameterGroupResponse>
`

var DescribeDBParameterGroupsExample = `
<DescribeDBParameterGroupsResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
<DescribeDBParameterGroupsResult>
<DBParameterGroups>
<DBParameterGroup>
<DBParameterGroupFamily>mysql5.6</DBParameterGroupFamily>
<Description>My new DB Parameter Group</Description>
<DBParameterGroupName>mydbparamgroup3</DBParameterGroupName>
</DBParameterGroup>
</DBParameterGroups>
</DescribeDBParameterGroupsResult>
<ResponseMetadata>
<RequestId>b75d527a-b98c-11d3-f272-7cd6cce12cc5</RequestId>
</ResponseMetadata>
</DescribeDBParameterGroupsResponse>
`


var DeleteDBParameterGroupExample = `
<DeleteDBParameterGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
<ResponseMetadata>
<RequestId>cad6c267-ba25-11d3-fe11-33d33a9bb7e3</RequestId>
</ResponseMetadata>
</DeleteDBParameterGroupResponse>
`

0 comments on commit 87d924a

Please sign in to comment.