Feature/filestorage sharenetworks delete (#122)
* sfs: Add delete for share networks
* sfs: Make name and descr required for creating share network
* sfs: Add acceptance test for share network Delete
* sfs: Remove required parameters
After taking a close look at the code it appeared that 'name'
and 'description' are not required parameters
diff --git a/openstack/sharedfilesystems/v2/sharenetworks/requests.go b/openstack/sharedfilesystems/v2/sharenetworks/requests.go
index f551861..ad29404 100644
--- a/openstack/sharedfilesystems/v2/sharenetworks/requests.go
+++ b/openstack/sharedfilesystems/v2/sharenetworks/requests.go
@@ -44,3 +44,9 @@
})
return
}
+
+// Delete will delete the existing ShareNetwork with the provided ID.
+func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
+ _, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
+}
diff --git a/openstack/sharedfilesystems/v2/sharenetworks/results.go b/openstack/sharedfilesystems/v2/sharenetworks/results.go
index 9a2891a..946ddd8 100644
--- a/openstack/sharedfilesystems/v2/sharenetworks/results.go
+++ b/openstack/sharedfilesystems/v2/sharenetworks/results.go
@@ -50,3 +50,8 @@
type CreateResult struct {
commonResult
}
+
+// DeleteResult contains the response body and error from a Delete request.
+type DeleteResult struct {
+ gophercloud.ErrResult
+}
diff --git a/openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures.go b/openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures.go
index bc61084..a014e5e 100644
--- a/openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures.go
+++ b/openstack/sharedfilesystems/v2/sharenetworks/testing/fixtures.go
@@ -61,3 +61,11 @@
"53482b62-2c84-4a53-b6ab-30d9d9800d06"))
})
}
+
+func MockDeleteResponse(t *testing.T) {
+ th.Mux.HandleFunc("/share-networks/fa158a3d-6d9f-4187-9ca5-abbb82646eb2", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "DELETE")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ w.WriteHeader(http.StatusAccepted)
+ })
+}
diff --git a/openstack/sharedfilesystems/v2/sharenetworks/testing/requests_test.go b/openstack/sharedfilesystems/v2/sharenetworks/testing/requests_test.go
index 9a00885..15baf0d 100644
--- a/openstack/sharedfilesystems/v2/sharenetworks/testing/requests_test.go
+++ b/openstack/sharedfilesystems/v2/sharenetworks/testing/requests_test.go
@@ -30,3 +30,14 @@
th.AssertEquals(t, n.NeutronNetID, "998b42ee-2cee-4d36-8b95-67b5ca1f2109")
th.AssertEquals(t, n.NeutronSubnetID, "53482b62-2c84-4a53-b6ab-30d9d9800d06")
}
+
+// Verifies that share network deletion works
+func TestDelete(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ MockDeleteResponse(t)
+
+ res := sharenetworks.Delete(client.ServiceClient(), "fa158a3d-6d9f-4187-9ca5-abbb82646eb2")
+ th.AssertNoErr(t, res.Err)
+}
diff --git a/openstack/sharedfilesystems/v2/sharenetworks/urls.go b/openstack/sharedfilesystems/v2/sharenetworks/urls.go
index 637ea98..7cd6c73 100644
--- a/openstack/sharedfilesystems/v2/sharenetworks/urls.go
+++ b/openstack/sharedfilesystems/v2/sharenetworks/urls.go
@@ -5,3 +5,7 @@
func createURL(c *gophercloud.ServiceClient) string {
return c.ServiceURL("share-networks")
}
+
+func deleteURL(c *gophercloud.ServiceClient, id string) string {
+ return c.ServiceURL("share-networks", id)
+}