Delete services, too.
diff --git a/openstack/identity/v3/services/requests.go b/openstack/identity/v3/services/requests.go
index fa55d06..c40af7d 100644
--- a/openstack/identity/v3/services/requests.go
+++ b/openstack/identity/v3/services/requests.go
@@ -103,3 +103,13 @@
return &resp.Service, nil
}
+
+// Delete removes an existing service.
+// It either deletes all associated endpoints, or fails until all endpoints are deleted.
+func Delete(client *gophercloud.ServiceClient, serviceID string) error {
+ _, err := perigee.Request("DELETE", getServiceURL(client, serviceID), perigee.Options{
+ MoreHeaders: client.Provider.AuthenticatedHeaders(),
+ OkCodes: []int{204},
+ })
+ return err
+}
diff --git a/openstack/identity/v3/services/requests_test.go b/openstack/identity/v3/services/requests_test.go
index b2249e6..9cd5232 100644
--- a/openstack/identity/v3/services/requests_test.go
+++ b/openstack/identity/v3/services/requests_test.go
@@ -185,10 +185,29 @@
result, err := Update(client, "12345", "lasermagic")
if err != nil {
- t.Fatalf("Unable to update service")
+ t.Fatalf("Unable to update service: %v", err)
}
if result.ID != "12345" {
}
}
+
+func TestDeleteSuccessful(t *testing.T) {
+ testhelper.SetupHTTP()
+ defer testhelper.TeardownHTTP()
+
+ testhelper.Mux.HandleFunc("/services/12345", func(w http.ResponseWriter, r *http.Request) {
+ testhelper.TestMethod(t, r, "DELETE")
+ testhelper.TestHeader(t, r, "X-Auth-Token", tokenID)
+
+ w.WriteHeader(http.StatusNoContent)
+ })
+
+ client := serviceClient()
+
+ err := Delete(client, "12345")
+ if err != nil {
+ t.Fatalf("Unable to delete service: %v", err)
+ }
+}