Delete rule support
diff --git a/openstack/compute/v2/extensions/secgroups/requests.go b/openstack/compute/v2/extensions/secgroups/requests.go
index 983f734..acd43f2 100644
--- a/openstack/compute/v2/extensions/secgroups/requests.go
+++ b/openstack/compute/v2/extensions/secgroups/requests.go
@@ -137,3 +137,14 @@
return result
}
+
+func DeleteRule(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
+ var result gophercloud.ErrResult
+
+ _, result.Err = perigee.Request("DELETE", resourceRuleURL(client, id), perigee.Options{
+ MoreHeaders: client.AuthenticatedHeaders(),
+ OkCodes: []int{202},
+ })
+
+ return result
+}
diff --git a/openstack/compute/v2/extensions/secgroups/requests_test.go b/openstack/compute/v2/extensions/secgroups/requests_test.go
index f59471f..cf13056 100644
--- a/openstack/compute/v2/extensions/secgroups/requests_test.go
+++ b/openstack/compute/v2/extensions/secgroups/requests_test.go
@@ -177,3 +177,13 @@
th.AssertDeepEquals(t, expected, rule)
}
+
+func TestDeleteRule(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ mockDeleteRuleResponse(t, ruleID)
+
+ err := DeleteRule(client.ServiceClient(), ruleID).ExtractErr()
+ th.AssertNoErr(t, err)
+}
diff --git a/openstack/compute/v2/extensions/secgroups/urls.go b/openstack/compute/v2/extensions/secgroups/urls.go
index 37a9048..7e2694c 100644
--- a/openstack/compute/v2/extensions/secgroups/urls.go
+++ b/openstack/compute/v2/extensions/secgroups/urls.go
@@ -22,3 +22,7 @@
func rootRuleURL(c *gophercloud.ServiceClient) string {
return c.ServiceURL(rulepath)
}
+
+func resourceRuleURL(c *gophercloud.ServiceClient, id string) string {
+ return c.ServiceURL(rulepath, id)
+}