Update existing Services.
diff --git a/openstack/identity/v3/services/requests.go b/openstack/identity/v3/services/requests.go
index 7b1a250..fa55d06 100644
--- a/openstack/identity/v3/services/requests.go
+++ b/openstack/identity/v3/services/requests.go
@@ -8,16 +8,16 @@
"github.com/rackspace/gophercloud/openstack/utils"
)
+type response struct {
+ Service ServiceResult `json:"service"`
+}
+
// Create adds a new service of the requested type to the catalog.
func Create(client *gophercloud.ServiceClient, serviceType string) (*ServiceResult, error) {
type request struct {
Type string `json:"type"`
}
- type response struct {
- Service ServiceResult `json:"service"`
- }
-
req := request{Type: serviceType}
var resp response
@@ -70,10 +70,6 @@
// Info returns additional information about a service, given its ID.
func Info(client *gophercloud.ServiceClient, serviceID string) (*ServiceResult, error) {
- type response struct {
- Service ServiceResult `json:"service"`
- }
-
var resp response
_, err := perigee.Request("GET", getServiceURL(client, serviceID), perigee.Options{
MoreHeaders: client.Provider.AuthenticatedHeaders(),
@@ -85,3 +81,25 @@
}
return &resp.Service, nil
}
+
+// Update changes the service type of an existing service.s
+func Update(client *gophercloud.ServiceClient, serviceID string, serviceType string) (*ServiceResult, error) {
+ type request struct {
+ Type string `json:"type"`
+ }
+
+ req := request{Type: serviceType}
+
+ var resp response
+ _, err := perigee.Request("PATCH", getServiceURL(client, serviceID), perigee.Options{
+ MoreHeaders: client.Provider.AuthenticatedHeaders(),
+ ReqBody: &req,
+ Results: &resp,
+ OkCodes: []int{200},
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ return &resp.Service, nil
+}