Add Identity HTTP operations
diff --git a/openstack/common/extensions/requests.go b/openstack/common/extensions/requests.go
index b6f371a..0b71085 100755
--- a/openstack/common/extensions/requests.go
+++ b/openstack/common/extensions/requests.go
@@ -8,9 +8,7 @@
// Get retrieves information for a specific extension using its alias.
func Get(c *gophercloud.ServiceClient, alias string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", ExtensionURL(c, alias), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- })
+ _, res.Err = c.Get(ExtensionURL(c, alias), &res.Body, nil)
return res
}
diff --git a/openstack/identity/v2/extensions/admin/roles/requests.go b/openstack/identity/v2/extensions/admin/roles/requests.go
index 619bf3b..9a33314 100644
--- a/openstack/identity/v2/extensions/admin/roles/requests.go
+++ b/openstack/identity/v2/extensions/admin/roles/requests.go
@@ -19,7 +19,7 @@
// ID is a required argument.
func AddUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
var result UserRoleResult
- _, result.Err = client.Request("PUT", userRoleURL(client, tenantID, userID, roleID), gophercloud.RequestOpts{})
+ _, result.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
return result
}
@@ -28,6 +28,6 @@
// tenant ID is a required argument.
func DeleteUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
var result UserRoleResult
- _, result.Err = client.Request("DELETE", userRoleURL(client, tenantID, userID, roleID), gophercloud.RequestOpts{})
+ _, result.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
return result
}
diff --git a/openstack/identity/v2/tokens/requests.go b/openstack/identity/v2/tokens/requests.go
index db1ac82..efa054f 100644
--- a/openstack/identity/v2/tokens/requests.go
+++ b/openstack/identity/v2/tokens/requests.go
@@ -75,10 +75,8 @@
}
var result CreateResult
- _, result.Err = client.Request("POST", CreateURL(client), gophercloud.RequestOpts{
- JSONBody: &request,
- JSONResponse: &result.Body,
- OkCodes: []int{200, 203},
+ _, result.Err = client.Post(CreateURL(client), request, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 203},
})
return result
}
diff --git a/openstack/identity/v2/users/requests.go b/openstack/identity/v2/users/requests.go
index 8aa1a20..88be45e 100644
--- a/openstack/identity/v2/users/requests.go
+++ b/openstack/identity/v2/users/requests.go
@@ -90,10 +90,8 @@
return res
}
- _, res.Err = client.Request("POST", rootURL(client), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- JSONBody: reqBody,
- OkCodes: []int{200, 201},
+ _, res.Err = client.Post(rootURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201},
})
return res
@@ -102,11 +100,7 @@
// Get requests details on a single user, either by ID.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var result GetResult
-
- _, result.Err = client.Request("GET", ResourceURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- })
-
+ _, result.Err = client.Get(ResourceURL(client, id), &result.Body, nil)
return result
}
@@ -144,22 +138,17 @@
// Update is the operation responsible for updating exist users by their UUID.
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult {
var result UpdateResult
-
- _, result.Err = client.Request("PUT", ResourceURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: opts.ToUserUpdateMap(),
- OkCodes: []int{200},
+ reqBody := opts.ToUserUpdateMap()
+ _, result.Err = client.Put(ResourceURL(client, id), reqBody, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
-
return result
}
// Delete is the operation responsible for permanently deleting an API user.
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var result DeleteResult
-
- _, result.Err = client.Request("DELETE", ResourceURL(client, id), gophercloud.RequestOpts{})
-
+ _, result.Err = client.Delete(ResourceURL(client, id), nil)
return result
}
diff --git a/openstack/identity/v3/endpoints/requests.go b/openstack/identity/v3/endpoints/requests.go
index 7591de0..99a495d 100644
--- a/openstack/identity/v3/endpoints/requests.go
+++ b/openstack/identity/v3/endpoints/requests.go
@@ -56,11 +56,7 @@
reqBody.Endpoint.Region = gophercloud.MaybeString(opts.Region)
var result CreateResult
- _, result.Err = client.Request("POST", listURL(client), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &result.Body,
- OkCodes: []int{201},
- })
+ _, result.Err = client.Post(listURL(client), reqBody, &result.Body, nil)
return result
}
@@ -122,6 +118,6 @@
// Delete removes an endpoint from the service catalog.
func Delete(client *gophercloud.ServiceClient, endpointID string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", endpointURL(client, endpointID), gophercloud.RequestOpts{})
+ _, res.Err = client.Delete(endpointURL(client, endpointID), nil)
return res
}
diff --git a/openstack/identity/v3/services/requests.go b/openstack/identity/v3/services/requests.go
index a93cfe7..3ee924f 100644
--- a/openstack/identity/v3/services/requests.go
+++ b/openstack/identity/v3/services/requests.go
@@ -18,10 +18,7 @@
req := request{Type: serviceType}
var result CreateResult
- _, result.Err = client.Request("POST", listURL(client), gophercloud.RequestOpts{
- JSONBody: &req,
- JSONResponse: &result.Body,
- })
+ _, result.Err = client.Post(listURL(client), req, &result.Body, nil)
return result
}
@@ -50,9 +47,7 @@
// Get returns additional information about a service, given its ID.
func Get(client *gophercloud.ServiceClient, serviceID string) GetResult {
var result GetResult
- _, result.Err = client.Request("GET", serviceURL(client, serviceID), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- })
+ _, result.Err = client.Get(serviceURL(client, serviceID), &result.Body, nil)
return result
}
@@ -77,6 +72,6 @@
// It either deletes all associated endpoints, or fails until all endpoints are deleted.
func Delete(client *gophercloud.ServiceClient, serviceID string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", serviceURL(client, serviceID), gophercloud.RequestOpts{})
+ _, res.Err = client.Delete(serviceURL(client, serviceID), nil)
return res
}
diff --git a/openstack/identity/v3/tokens/requests.go b/openstack/identity/v3/tokens/requests.go
index ecbe10e..d449ca3 100644
--- a/openstack/identity/v3/tokens/requests.go
+++ b/openstack/identity/v3/tokens/requests.go
@@ -235,10 +235,7 @@
var result CreateResult
var response *http.Response
- response, result.Err = c.Request("POST", tokenURL(c), gophercloud.RequestOpts{
- JSONBody: &req,
- JSONResponse: &result.Body,
- })
+ response, result.Err = c.Post(tokenURL(c), req, &result.Body, nil)
if result.Err != nil {
return result
}
@@ -250,10 +247,9 @@
func Get(c *gophercloud.ServiceClient, token string) GetResult {
var result GetResult
var response *http.Response
- response, result.Err = c.Request("GET", tokenURL(c), gophercloud.RequestOpts{
- MoreHeaders: subjectTokenHeaders(c, token),
- JSONResponse: &result.Body,
- OkCodes: []int{200, 203},
+ response, result.Err = c.Get(tokenURL(c), &result.Body, &gophercloud.RequestOpts{
+ MoreHeaders: subjectTokenHeaders(c, token),
+ OkCodes: []int{200, 203},
})
if result.Err != nil {
return result
@@ -278,7 +274,7 @@
// Revoke immediately makes specified token invalid.
func Revoke(c *gophercloud.ServiceClient, token string) RevokeResult {
var res RevokeResult
- _, res.Err = c.Request("DELETE", tokenURL(c), gophercloud.RequestOpts{
+ _, res.Err = c.Delete(tokenURL(c), &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(c, token),
})
return res