Merge pull request #402 from jamiehannaford/http-status
Add default HTTP statuses
diff --git a/openstack/blockstorage/v1/apiversions/requests.go b/openstack/blockstorage/v1/apiversions/requests.go
index f5a793c..bb2c259 100644
--- a/openstack/blockstorage/v1/apiversions/requests.go
+++ b/openstack/blockstorage/v1/apiversions/requests.go
@@ -16,9 +16,6 @@
// type from the result, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, v string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", getURL(client, v), gophercloud.RequestOpts{
- OkCodes: []int{200},
- JSONResponse: &res.Body,
- })
+ _, res.Err = client.Get(getURL(client, v), &res.Body, nil)
return res
}
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
index 1b313a6..d2f10aa 100644
--- a/openstack/blockstorage/v1/snapshots/requests.go
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -67,10 +67,8 @@
return res
}
- _, res.Err = client.Request("POST", createURL(client), gophercloud.RequestOpts{
- OkCodes: []int{200, 201},
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
+ _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201},
})
return res
}
@@ -78,9 +76,7 @@
// Delete will delete the existing Snapshot with the provided ID.
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", deleteURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{202, 204},
- })
+ _, res.Err = client.Delete(deleteURL(client, id), nil)
return res
}
@@ -88,10 +84,7 @@
// object from the response, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{200},
- JSONResponse: &res.Body,
- })
+ _, res.Err = client.Get(getURL(client, id), &res.Body, nil)
return res
}
@@ -173,10 +166,8 @@
return res
}
- _, res.Err = client.Request("PUT", updateMetadataURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{200},
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
+ _, res.Err = client.Put(updateMetadataURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
diff --git a/openstack/blockstorage/v1/volumes/requests.go b/openstack/blockstorage/v1/volumes/requests.go
index e67ba10..253aaf7 100644
--- a/openstack/blockstorage/v1/volumes/requests.go
+++ b/openstack/blockstorage/v1/volumes/requests.go
@@ -83,10 +83,8 @@
return res
}
- _, res.Err = client.Request("POST", createURL(client), gophercloud.RequestOpts{
- OkCodes: []int{200, 201},
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
+ _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201},
})
return res
}
@@ -94,9 +92,7 @@
// Delete will delete the existing Volume with the provided ID.
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", deleteURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{202, 204},
- })
+ _, res.Err = client.Delete(deleteURL(client, id), nil)
return res
}
@@ -104,10 +100,7 @@
// from the response, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = client.Get(getURL(client, id), &res.Body, nil)
return res
}
@@ -203,10 +196,8 @@
return res
}
- _, res.Err = client.Request("PUT", updateURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{200},
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
+ _, res.Err = client.Put(updateURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
diff --git a/openstack/blockstorage/v1/volumetypes/requests.go b/openstack/blockstorage/v1/volumetypes/requests.go
index 6fedaa6..1673d13 100644
--- a/openstack/blockstorage/v1/volumetypes/requests.go
+++ b/openstack/blockstorage/v1/volumetypes/requests.go
@@ -44,11 +44,8 @@
return res
}
- _, res.Err = client.Request("POST", createURL(client), gophercloud.RequestOpts{
- MoreHeaders: client.AuthenticatedHeaders(),
- OkCodes: []int{200, 201},
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
+ _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201},
})
return res
}
@@ -56,10 +53,7 @@
// Delete will delete the volume type with the provided ID.
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", deleteURL(client, id), gophercloud.RequestOpts{
- MoreHeaders: client.AuthenticatedHeaders(),
- OkCodes: []int{202},
- })
+ _, res.Err = client.Delete(deleteURL(client, id), nil)
return res
}
@@ -67,11 +61,7 @@
// type from the result, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, err := client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- MoreHeaders: client.AuthenticatedHeaders(),
- OkCodes: []int{200},
- JSONResponse: &res.Body,
- })
+ _, err := client.Get(getURL(client, id), &res.Body, nil)
res.Err = err
return res
}
diff --git a/openstack/cdn/v1/base/requests.go b/openstack/cdn/v1/base/requests.go
index b63dc95..dd221bc 100644
--- a/openstack/cdn/v1/base/requests.go
+++ b/openstack/cdn/v1/base/requests.go
@@ -6,17 +6,14 @@
// entire API.
func Get(c *gophercloud.ServiceClient) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c), &res.Body, nil)
return res
}
// Ping retrieves a ping to the server.
func Ping(c *gophercloud.ServiceClient) PingResult {
var res PingResult
- _, res.Err = c.Request("GET", pingURL(c), gophercloud.RequestOpts{
+ _, res.Err = c.Get(pingURL(c), nil, &gophercloud.RequestOpts{
OkCodes: []int{204},
MoreHeaders: map[string]string{"Accept": ""},
})
diff --git a/openstack/cdn/v1/flavors/requests.go b/openstack/cdn/v1/flavors/requests.go
index 138fd97..8755a95 100644
--- a/openstack/cdn/v1/flavors/requests.go
+++ b/openstack/cdn/v1/flavors/requests.go
@@ -17,9 +17,6 @@
// Get retrieves a specific flavor based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
diff --git a/openstack/cdn/v1/serviceassets/requests.go b/openstack/cdn/v1/serviceassets/requests.go
index a80aa0d..1ddc65f 100644
--- a/openstack/cdn/v1/serviceassets/requests.go
+++ b/openstack/cdn/v1/serviceassets/requests.go
@@ -43,8 +43,6 @@
}
var res DeleteResult
- _, res.Err = c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = c.Delete(url, nil)
return res
}
diff --git a/openstack/cdn/v1/services/requests.go b/openstack/cdn/v1/services/requests.go
index 78a3087..8b37928 100644
--- a/openstack/cdn/v1/services/requests.go
+++ b/openstack/cdn/v1/services/requests.go
@@ -177,10 +177,7 @@
}
// Send request to API
- resp, err := c.Request("POST", createURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
+ resp, err := c.Post(createURL(c), &reqBody, nil, nil)
res.Header = resp.Header
res.Err = err
return res
@@ -199,10 +196,7 @@
}
var res GetResult
- _, res.Err = c.Request("GET", url, gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(url, &res.Body, nil)
return res
}
@@ -379,8 +373,6 @@
}
var res DeleteResult
- _, res.Err = c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = c.Delete(url, nil)
return res
}
diff --git a/openstack/common/extensions/requests.go b/openstack/common/extensions/requests.go
index dfd81c9..0b71085 100755
--- a/openstack/common/extensions/requests.go
+++ b/openstack/common/extensions/requests.go
@@ -8,10 +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,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(ExtensionURL(c, alias), &res.Body, nil)
return res
}
diff --git a/openstack/compute/v2/extensions/bootfromvolume/requests.go b/openstack/compute/v2/extensions/bootfromvolume/requests.go
index b64014f..c0ba368 100644
--- a/openstack/compute/v2/extensions/bootfromvolume/requests.go
+++ b/openstack/compute/v2/extensions/bootfromvolume/requests.go
@@ -99,10 +99,8 @@
return res
}
- _, res.Err = client.Request("POST", createURL(client), gophercloud.RequestOpts{
- JSONBody: reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 202},
+ _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 202},
})
return res
}
diff --git a/openstack/compute/v2/extensions/defsecrules/requests.go b/openstack/compute/v2/extensions/defsecrules/requests.go
index 294bae3..9f27ef1 100644
--- a/openstack/compute/v2/extensions/defsecrules/requests.go
+++ b/openstack/compute/v2/extensions/defsecrules/requests.go
@@ -73,10 +73,8 @@
return result
}
- _, result.Err = client.Request("POST", rootURL(client), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: &reqBody,
- OkCodes: []int{200},
+ _, result.Err = client.Post(rootURL(client), reqBody, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return result
@@ -85,22 +83,13 @@
// Get will return details for a particular default rule.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var result GetResult
-
- _, result.Err = client.Request("GET", resourceURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- OkCodes: []int{200},
- })
-
+ _, result.Err = client.Get(resourceURL(client, id), &result.Body, nil)
return result
}
// Delete will permanently delete a default rule from the project.
func Delete(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
var result gophercloud.ErrResult
-
- _, result.Err = client.Request("DELETE", resourceURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
-
+ _, result.Err = client.Delete(resourceURL(client, id), nil)
return result
}
diff --git a/openstack/compute/v2/extensions/floatingip/requests.go b/openstack/compute/v2/extensions/floatingip/requests.go
index d154038..8abb72d 100644
--- a/openstack/compute/v2/extensions/floatingip/requests.go
+++ b/openstack/compute/v2/extensions/floatingip/requests.go
@@ -45,10 +45,8 @@
return res
}
- _, res.Err = client.Request("POST", createURL(client), gophercloud.RequestOpts{
- JSONBody: reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -56,19 +54,14 @@
// Get returns data about a previously created FloatingIP.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = client.Get(getURL(client, id), &res.Body, nil)
return res
}
// Delete requests the deletion of a previous allocated FloatingIP.
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", deleteURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = client.Delete(deleteURL(client, id), nil)
return res
}
@@ -82,10 +75,7 @@
addFloatingIp["address"] = fip
reqBody := map[string]interface{}{"addFloatingIp": addFloatingIp}
- _, res.Err = client.Request("POST", associateURL(client, serverId), gophercloud.RequestOpts{
- JSONBody: reqBody,
- OkCodes: []int{202},
- })
+ _, res.Err = client.Post(associateURL(client, serverId), reqBody, nil, nil)
return res
}
@@ -97,9 +87,6 @@
removeFloatingIp["address"] = fip
reqBody := map[string]interface{}{"removeFloatingIp": removeFloatingIp}
- _, res.Err = client.Request("POST", disassociateURL(client, serverId), gophercloud.RequestOpts{
- JSONBody: reqBody,
- OkCodes: []int{202},
- })
+ _, res.Err = client.Post(disassociateURL(client, serverId), reqBody, nil, nil)
return res
}
diff --git a/openstack/compute/v2/extensions/keypairs/requests.go b/openstack/compute/v2/extensions/keypairs/requests.go
index 287e412..c56ee67 100644
--- a/openstack/compute/v2/extensions/keypairs/requests.go
+++ b/openstack/compute/v2/extensions/keypairs/requests.go
@@ -81,10 +81,8 @@
return res
}
- _, res.Err = client.Request("POST", createURL(client), gophercloud.RequestOpts{
- JSONBody: reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -92,18 +90,13 @@
// Get returns public data about a previously uploaded KeyPair.
func Get(client *gophercloud.ServiceClient, name string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", getURL(client, name), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = client.Get(getURL(client, name), &res.Body, nil)
return res
}
// Delete requests the deletion of a previous stored KeyPair from the server.
func Delete(client *gophercloud.ServiceClient, name string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", deleteURL(client, name), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = client.Delete(deleteURL(client, name), nil)
return res
}
diff --git a/openstack/compute/v2/extensions/secgroups/requests.go b/openstack/compute/v2/extensions/secgroups/requests.go
index 8f0a7a0..4cef480 100644
--- a/openstack/compute/v2/extensions/secgroups/requests.go
+++ b/openstack/compute/v2/extensions/secgroups/requests.go
@@ -78,10 +78,8 @@
return result
}
- _, result.Err = client.Request("POST", rootURL(client), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: &reqBody,
- OkCodes: []int{200},
+ _, result.Err = client.Post(rootURL(client), reqBody, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return result
@@ -123,10 +121,8 @@
return result
}
- _, result.Err = client.Request("PUT", resourceURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: &reqBody,
- OkCodes: []int{200},
+ _, result.Err = client.Put(resourceURL(client, id), reqBody, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return result
@@ -135,23 +131,14 @@
// Get will return details for a particular security group.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var result GetResult
-
- _, result.Err = client.Request("GET", resourceURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- OkCodes: []int{200},
- })
-
+ _, result.Err = client.Get(resourceURL(client, id), &result.Body, nil)
return result
}
// Delete will permanently delete a security group from the project.
func Delete(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
var result gophercloud.ErrResult
-
- _, result.Err = client.Request("DELETE", resourceURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, result.Err = client.Delete(resourceURL(client, id), nil)
return result
}
@@ -234,10 +221,8 @@
return result
}
- _, result.Err = client.Request("POST", rootRuleURL(client), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: &reqBody,
- OkCodes: []int{200},
+ _, result.Err = client.Post(rootRuleURL(client), reqBody, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return result
@@ -246,11 +231,7 @@
// DeleteRule will permanently delete a rule from a security group.
func DeleteRule(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
var result gophercloud.ErrResult
-
- _, result.Err = client.Request("DELETE", resourceRuleURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, result.Err = client.Delete(resourceRuleURL(client, id), nil)
return result
}
@@ -264,25 +245,13 @@
// rules of the group on the server.
func AddServerToGroup(client *gophercloud.ServiceClient, serverID, groupName string) gophercloud.ErrResult {
var result gophercloud.ErrResult
-
- _, result.Err = client.Request("POST", serverActionURL(client, serverID), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: actionMap("add", groupName),
- OkCodes: []int{202},
- })
-
+ _, result.Err = client.Post(serverActionURL(client, serverID), actionMap("add", groupName), &result.Body, nil)
return result
}
// RemoveServerFromGroup will disassociate a server from a security group.
func RemoveServerFromGroup(client *gophercloud.ServiceClient, serverID, groupName string) gophercloud.ErrResult {
var result gophercloud.ErrResult
-
- _, result.Err = client.Request("POST", serverActionURL(client, serverID), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: actionMap("remove", groupName),
- OkCodes: []int{202},
- })
-
+ _, result.Err = client.Post(serverActionURL(client, serverID), actionMap("remove", groupName), &result.Body, nil)
return result
}
diff --git a/openstack/compute/v2/extensions/startstop/requests.go b/openstack/compute/v2/extensions/startstop/requests.go
index 04b5909..0e090e6 100644
--- a/openstack/compute/v2/extensions/startstop/requests.go
+++ b/openstack/compute/v2/extensions/startstop/requests.go
@@ -9,27 +9,15 @@
// Start is the operation responsible for starting a Compute server.
func Start(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
var res gophercloud.ErrResult
-
reqBody := map[string]interface{}{"os-start": nil}
-
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil)
return res
}
// Stop is the operation responsible for stopping a Compute server.
func Stop(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
var res gophercloud.ErrResult
-
reqBody := map[string]interface{}{"os-stop": nil}
-
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil)
return res
}
diff --git a/openstack/compute/v2/extensions/tenantnetworks/requests.go b/openstack/compute/v2/extensions/tenantnetworks/requests.go
index cd73479..3ec13d3 100644
--- a/openstack/compute/v2/extensions/tenantnetworks/requests.go
+++ b/openstack/compute/v2/extensions/tenantnetworks/requests.go
@@ -17,9 +17,6 @@
// Get returns data about a previously created Network.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = client.Get(getURL(client, id), &res.Body, nil)
return res
}
diff --git a/openstack/compute/v2/extensions/volumeattach/requests.go b/openstack/compute/v2/extensions/volumeattach/requests.go
index 79709fd..b4ebede 100644
--- a/openstack/compute/v2/extensions/volumeattach/requests.go
+++ b/openstack/compute/v2/extensions/volumeattach/requests.go
@@ -54,10 +54,8 @@
return res
}
- _, res.Err = client.Request("POST", createURL(client, serverId), gophercloud.RequestOpts{
- JSONBody: reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Post(createURL(client, serverId), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -65,18 +63,13 @@
// Get returns public data about a previously created VolumeAttachment.
func Get(client *gophercloud.ServiceClient, serverId, aId string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", getURL(client, serverId, aId), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = client.Get(getURL(client, serverId, aId), &res.Body, nil)
return res
}
// Delete requests the deletion of a previous stored VolumeAttachment from the server.
func Delete(client *gophercloud.ServiceClient, serverId, aId string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", deleteURL(client, serverId, aId), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = client.Delete(deleteURL(client, serverId, aId), nil)
return res
}
diff --git a/openstack/compute/v2/flavors/requests.go b/openstack/compute/v2/flavors/requests.go
index 1d33f58..586be67 100644
--- a/openstack/compute/v2/flavors/requests.go
+++ b/openstack/compute/v2/flavors/requests.go
@@ -62,9 +62,7 @@
// Get instructs OpenStack to provide details on a single flavor, identified by its ID.
// Use ExtractFlavor to convert its result into a Flavor.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
- var gr GetResult
- _, gr.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &gr.Body,
- })
- return gr
+ var res GetResult
+ _, res.Err = client.Get(getURL(client, id), &res.Body, nil)
+ return res
}
diff --git a/openstack/compute/v2/images/requests.go b/openstack/compute/v2/images/requests.go
index 9e9c3b1..5eb19b5 100644
--- a/openstack/compute/v2/images/requests.go
+++ b/openstack/compute/v2/images/requests.go
@@ -60,9 +60,6 @@
// Use ExtractImage() to interpret the result as an openstack Image.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var result GetResult
- _, result.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- OkCodes: []int{200},
- })
+ _, result.Err = client.Get(getURL(client, id), &result.Body, nil)
return result
}
diff --git a/openstack/compute/v2/servers/requests.go b/openstack/compute/v2/servers/requests.go
index de112cf..e0950e4 100644
--- a/openstack/compute/v2/servers/requests.go
+++ b/openstack/compute/v2/servers/requests.go
@@ -216,29 +216,22 @@
return res
}
- _, res.Err = client.Request("POST", listURL(client), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- JSONBody: reqBody,
- OkCodes: []int{202},
- })
+ _, res.Err = client.Post(listURL(client), reqBody, &res.Body, nil)
return res
}
// Delete requests that a server previously provisioned be removed from your account.
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", deleteURL(client, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = client.Delete(deleteURL(client, id), nil)
return res
}
// Get requests details on a single server, by ID.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var result GetResult
- _, result.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- OkCodes: []int{200, 203},
+ _, result.Err = client.Get(getURL(client, id), &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 203},
})
return result
}
@@ -280,9 +273,9 @@
// Update requests that various attributes of the indicated server be changed.
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult {
var result UpdateResult
- _, result.Err = client.Request("PUT", updateURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: opts.ToServerUpdateMap(),
+ reqBody := opts.ToServerUpdateMap()
+ _, result.Err = client.Put(updateURL(client, id), reqBody, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return result
}
@@ -298,12 +291,7 @@
req.ChangePassword.AdminPass = newPassword
var res ActionResult
-
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: req,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Post(actionURL(client, id), req, nil, nil)
return res
}
@@ -367,15 +355,13 @@
return res
}
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: struct {
- C map[string]string `json:"reboot"`
- }{
- map[string]string{"type": string(how)},
- },
- OkCodes: []int{202},
- })
+ reqBody := struct {
+ C map[string]string `json:"reboot"`
+ }{
+ map[string]string{"type": string(how)},
+ }
+ _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil)
return res
}
@@ -468,12 +454,7 @@
return result
}
- _, result.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &result.Body,
- OkCodes: []int{202},
- })
-
+ _, result.Err = client.Post(actionURL(client, id), reqBody, &result.Body, nil)
return result
}
@@ -514,11 +495,7 @@
return res
}
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil)
return res
}
@@ -527,11 +504,10 @@
func ConfirmResize(client *gophercloud.ServiceClient, id string) ActionResult {
var res ActionResult
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: map[string]interface{}{"confirmResize": nil},
- OkCodes: []int{204},
+ reqBody := map[string]interface{}{"confirmResize": nil}
+ _, res.Err = client.Post(actionURL(client, id), reqBody, nil, &gophercloud.RequestOpts{
+ OkCodes: []int{201, 202, 204},
})
-
return res
}
@@ -539,12 +515,8 @@
// See Resize() for more details.
func RevertResize(client *gophercloud.ServiceClient, id string) ActionResult {
var res ActionResult
-
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONBody: map[string]interface{}{"revertResize": nil},
- OkCodes: []int{202},
- })
-
+ reqBody := map[string]interface{}{"revertResize": nil}
+ _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil)
return res
}
@@ -586,10 +558,8 @@
return result
}
- _, result.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &result.Body,
- JSONBody: &reqBody,
- OkCodes: []int{200},
+ _, result.Err = client.Post(actionURL(client, id), reqBody, &result.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return result
@@ -625,9 +595,8 @@
res.Err = err
return res
}
- _, res.Err = client.Request("PUT", metadataURL(client, id), gophercloud.RequestOpts{
- JSONBody: metadata,
- JSONResponse: &res.Body,
+ _, res.Err = client.Put(metadataURL(client, id), metadata, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -635,9 +604,7 @@
// Metadata requests all the metadata for the given server ID.
func Metadata(client *gophercloud.ServiceClient, id string) GetMetadataResult {
var res GetMetadataResult
- _, res.Err = client.Request("GET", metadataURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- })
+ _, res.Err = client.Get(metadataURL(client, id), &res.Body, nil)
return res
}
@@ -657,9 +624,8 @@
res.Err = err
return res
}
- _, res.Err = client.Request("POST", metadataURL(client, id), gophercloud.RequestOpts{
- JSONBody: metadata,
- JSONResponse: &res.Body,
+ _, res.Err = client.Post(metadataURL(client, id), metadata, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -695,9 +661,8 @@
return res
}
- _, res.Err = client.Request("PUT", metadatumURL(client, id, key), gophercloud.RequestOpts{
- JSONBody: metadatum,
- JSONResponse: &res.Body,
+ _, res.Err = client.Put(metadatumURL(client, id, key), metadatum, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -714,7 +679,7 @@
// DeleteMetadatum will delete the key-value pair with the given key for the given server ID.
func DeleteMetadatum(client *gophercloud.ServiceClient, id, key string) DeleteMetadatumResult {
var res DeleteMetadatumResult
- _, res.Err = client.Request("DELETE", metadatumURL(client, id, key), gophercloud.RequestOpts{
+ _, res.Err = client.Delete(metadatumURL(client, id, key), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
diff --git a/openstack/identity/v2/extensions/admin/roles/requests.go b/openstack/identity/v2/extensions/admin/roles/requests.go
index bbdf76a..9a33314 100644
--- a/openstack/identity/v2/extensions/admin/roles/requests.go
+++ b/openstack/identity/v2/extensions/admin/roles/requests.go
@@ -19,11 +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{
- OkCodes: []int{200, 201},
- })
-
+ _, result.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
return result
}
@@ -32,10 +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{
- OkCodes: []int{204},
- })
-
+ _, 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 2afe62a..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,12 +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,
- OkCodes: []int{200},
- })
-
+ _, result.Err = client.Get(ResourceURL(client, id), &result.Body, nil)
return result
}
@@ -145,24 +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{
- OkCodes: []int{204},
- })
-
+ _, 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 3e09b2a..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,8 +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{
- OkCodes: []int{204},
- })
+ _, 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 c6820c7..3ee924f 100644
--- a/openstack/identity/v3/services/requests.go
+++ b/openstack/identity/v3/services/requests.go
@@ -18,11 +18,7 @@
req := request{Type: serviceType}
var result CreateResult
- _, result.Err = client.Request("POST", listURL(client), gophercloud.RequestOpts{
- JSONBody: &req,
- JSONResponse: &result.Body,
- OkCodes: []int{201},
- })
+ _, result.Err = client.Post(listURL(client), req, &result.Body, nil)
return result
}
@@ -51,10 +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,
- OkCodes: []int{200},
- })
+ _, result.Err = client.Get(serviceURL(client, serviceID), &result.Body, nil)
return result
}
@@ -79,8 +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{
- OkCodes: []int{204},
- })
+ _, 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 bbd3c56..d449ca3 100644
--- a/openstack/identity/v3/tokens/requests.go
+++ b/openstack/identity/v3/tokens/requests.go
@@ -235,11 +235,7 @@
var result CreateResult
var response *http.Response
- response, result.Err = c.Request("POST", tokenURL(c), gophercloud.RequestOpts{
- JSONBody: &req,
- JSONResponse: &result.Body,
- OkCodes: []int{201},
- })
+ response, result.Err = c.Post(tokenURL(c), req, &result.Body, nil)
if result.Err != nil {
return result
}
@@ -251,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
@@ -279,9 +274,8 @@
// 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),
- OkCodes: []int{204},
})
return res
}
diff --git a/openstack/networking/v2/extensions/fwaas/firewalls/requests.go b/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
index 69f3dca..12d587f 100644
--- a/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
@@ -139,21 +139,14 @@
return res
}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular firewall based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -209,10 +202,8 @@
}
// Send request to API
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -220,8 +211,6 @@
// Delete will permanently delete a particular firewall based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/fwaas/policies/requests.go b/openstack/networking/v2/extensions/fwaas/policies/requests.go
index 95081df..fe07d9a 100644
--- a/openstack/networking/v2/extensions/fwaas/policies/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/policies/requests.go
@@ -128,21 +128,14 @@
return res
}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular firewall policy based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -198,10 +191,8 @@
}
// Send request to API
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -209,9 +200,7 @@
// Delete will permanently delete a particular firewall policy based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
@@ -230,10 +219,8 @@
// Send request to API
var res commonResult
- _, res.Err = c.Request("PUT", insertURL(c, policyID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(insertURL(c, policyID), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res.Err
}
@@ -249,10 +236,8 @@
// Send request to API
var res commonResult
- _, res.Err = c.Request("PUT", removeURL(c, policyID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(removeURL(c, policyID), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res.Err
}
diff --git a/openstack/networking/v2/extensions/fwaas/rules/requests.go b/openstack/networking/v2/extensions/fwaas/rules/requests.go
index 3780106..57a0e8b 100644
--- a/openstack/networking/v2/extensions/fwaas/rules/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/rules/requests.go
@@ -163,21 +163,14 @@
return res
}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular firewall rule based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -277,10 +270,8 @@
}
// Send request to API
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -289,8 +280,6 @@
// Delete will permanently delete a particular firewall rule based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/layer3/floatingips/requests.go b/openstack/networking/v2/extensions/layer3/floatingips/requests.go
index 46f2b22..49d6f0b 100644
--- a/openstack/networking/v2/extensions/layer3/floatingips/requests.go
+++ b/openstack/networking/v2/extensions/layer3/floatingips/requests.go
@@ -107,23 +107,14 @@
TenantID: opts.TenantID,
}}
- // Send request to API
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
-
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular floating IP resource based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -159,10 +150,8 @@
// Send request to API
var res UpdateResult
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -173,8 +162,6 @@
// internal ports.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/layer3/routers/requests.go b/openstack/networking/v2/extensions/layer3/routers/requests.go
index 12640de..077a717 100755
--- a/openstack/networking/v2/extensions/layer3/routers/requests.go
+++ b/openstack/networking/v2/extensions/layer3/routers/requests.go
@@ -81,21 +81,14 @@
}
var res CreateResult
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular router based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -133,10 +126,8 @@
// Send request to API
var res UpdateResult
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -145,9 +136,7 @@
// Delete will permanently delete a particular router based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
@@ -197,10 +186,8 @@
body := request{SubnetID: opts.SubnetID, PortID: opts.PortID}
- _, res.Err = c.Request("PUT", addInterfaceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &body,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(addInterfaceURL(c, id), body, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -229,10 +216,8 @@
body := request{SubnetID: opts.SubnetID, PortID: opts.PortID}
- _, res.Err = c.Request("PUT", removeInterfaceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &body,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(removeInterfaceURL(c, id), body, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
diff --git a/openstack/networking/v2/extensions/lbaas/members/requests.go b/openstack/networking/v2/extensions/lbaas/members/requests.go
index 023a04d..848938f 100644
--- a/openstack/networking/v2/extensions/lbaas/members/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/members/requests.go
@@ -79,21 +79,14 @@
}}
var res CreateResult
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular pool member based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -116,10 +109,8 @@
// Send request to API
var res UpdateResult
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201, 202},
})
return res
}
@@ -127,8 +118,6 @@
// Delete will permanently delete a particular member based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/requests.go b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
index de6f688..71b21ef 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
@@ -176,22 +176,14 @@
AdminStateUp: opts.AdminStateUp,
}}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
-
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular health monitor based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -258,10 +250,8 @@
AdminStateUp: opts.AdminStateUp,
}}
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 202},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 202},
})
return res
@@ -270,8 +260,6 @@
// Delete will permanently delete a particular monitor based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/lbaas/pools/requests.go b/openstack/networking/v2/extensions/lbaas/pools/requests.go
index e7e6d94..2bb0acc 100644
--- a/openstack/networking/v2/extensions/lbaas/pools/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/pools/requests.go
@@ -99,21 +99,14 @@
}}
var res CreateResult
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular pool based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -145,10 +138,8 @@
// Send request to API
var res UpdateResult
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -156,9 +147,7 @@
// Delete will permanently delete a particular pool based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
@@ -178,11 +167,7 @@
reqBody := request{hm{ID: monitorID}}
var res AssociateResult
- _, res.Err = c.Request("POST", associateURL(c, poolID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(associateURL(c, poolID), reqBody, &res.Body, nil)
return res
}
@@ -191,8 +176,6 @@
// check for the health of the members of the pool.
func DisassociateMonitor(c *gophercloud.ServiceClient, poolID, monitorID string) AssociateResult {
var res AssociateResult
- _, res.Err = c.Request("DELETE", disassociateURL(c, poolID, monitorID), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(disassociateURL(c, poolID, monitorID), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/lbaas/vips/requests.go b/openstack/networking/v2/extensions/lbaas/vips/requests.go
index 5b0bfd9..6216f87 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/requests.go
@@ -178,22 +178,14 @@
reqBody.VirtualIP.Persistence = opts.Persistence
}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
-
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular virtual IP based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
@@ -249,10 +241,8 @@
}
var res UpdateResult
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 202},
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 202},
})
return res
@@ -261,8 +251,6 @@
// Delete will permanently delete a particular virtual IP based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/security/groups/requests.go b/openstack/networking/v2/extensions/security/groups/requests.go
index c07508b..55e4b3b 100644
--- a/openstack/networking/v2/extensions/security/groups/requests.go
+++ b/openstack/networking/v2/extensions/security/groups/requests.go
@@ -74,30 +74,20 @@
Description: opts.Description,
}}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
-
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular security group based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
// Delete will permanently delete a particular security group based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/extensions/security/rules/requests.go b/openstack/networking/v2/extensions/security/rules/requests.go
index 108acf6..0b2d10b 100644
--- a/openstack/networking/v2/extensions/security/rules/requests.go
+++ b/openstack/networking/v2/extensions/security/rules/requests.go
@@ -150,30 +150,20 @@
RemoteIPPrefix: opts.RemoteIPPrefix,
}}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
-
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
// Get retrieves a particular security group based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
return res
}
// Delete will permanently delete a particular security group based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/networks/requests.go b/openstack/networking/v2/networks/requests.go
index b0db67e..7be3227 100644
--- a/openstack/networking/v2/networks/requests.go
+++ b/openstack/networking/v2/networks/requests.go
@@ -79,10 +79,7 @@
// Get retrieves a specific network based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
@@ -134,12 +131,7 @@
return res
}
- // Send request to API
- _, res.Err = c.Request("POST", createURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil)
return res
}
@@ -184,10 +176,8 @@
}
// Send request to API
- _, res.Err = c.Request("PUT", updateURL(c, networkID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 201},
+ _, res.Err = c.Put(updateURL(c, networkID), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201},
})
return res
@@ -196,8 +186,6 @@
// Delete accepts a unique ID and deletes the network associated with it.
func Delete(c *gophercloud.ServiceClient, networkID string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", deleteURL(c, networkID), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(deleteURL(c, networkID), nil)
return res
}
diff --git a/openstack/networking/v2/ports/requests.go b/openstack/networking/v2/ports/requests.go
index 01d550f..781a3c3 100644
--- a/openstack/networking/v2/ports/requests.go
+++ b/openstack/networking/v2/ports/requests.go
@@ -79,10 +79,7 @@
// Get retrieves a specific port based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
@@ -155,13 +152,7 @@
return res
}
- // Response
- _, res.Err = c.Request("POST", createURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
-
+ _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil)
return res
}
@@ -220,10 +211,8 @@
return res
}
- _, res.Err = c.Request("PUT", updateURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 201},
+ _, res.Err = c.Put(updateURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201},
})
return res
}
@@ -231,8 +220,6 @@
// Delete accepts a unique ID and deletes the port associated with it.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", deleteURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(deleteURL(c, id), nil)
return res
}
diff --git a/openstack/networking/v2/subnets/requests.go b/openstack/networking/v2/subnets/requests.go
index 63ac290..6e01f05 100644
--- a/openstack/networking/v2/subnets/requests.go
+++ b/openstack/networking/v2/subnets/requests.go
@@ -78,10 +78,7 @@
// Get retrieves a specific subnet based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
@@ -171,12 +168,7 @@
return res
}
- _, res.Err = c.Request("POST", createURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
-
+ _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil)
return res
}
@@ -229,10 +221,8 @@
return res
}
- _, res.Err = c.Request("PUT", updateURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 201},
+ _, res.Err = c.Put(updateURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201},
})
return res
@@ -241,8 +231,6 @@
// Delete accepts a unique ID and deletes the subnet associated with it.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", deleteURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(deleteURL(c, id), nil)
return res
}
diff --git a/openstack/objectstorage/v1/accounts/requests.go b/openstack/objectstorage/v1/accounts/requests.go
index 3e404c3..a645115 100644
--- a/openstack/objectstorage/v1/accounts/requests.go
+++ b/openstack/objectstorage/v1/accounts/requests.go
@@ -95,7 +95,7 @@
resp, err := c.Request("POST", updateURL(c), gophercloud.RequestOpts{
MoreHeaders: h,
- OkCodes: []int{204},
+ OkCodes: []int{201, 202, 204},
})
res.Header = resp.Header
res.Err = err
diff --git a/openstack/objectstorage/v1/containers/requests.go b/openstack/objectstorage/v1/containers/requests.go
index a29d7da..bbf8cdb 100644
--- a/openstack/objectstorage/v1/containers/requests.go
+++ b/openstack/objectstorage/v1/containers/requests.go
@@ -122,9 +122,7 @@
// Delete is a function that deletes a container.
func Delete(c *gophercloud.ServiceClient, containerName string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", deleteURL(c, containerName), gophercloud.RequestOpts{
- OkCodes: []int{202, 204},
- })
+ _, res.Err = c.Delete(deleteURL(c, containerName), nil)
return res
}
@@ -180,7 +178,7 @@
resp, err := c.Request("POST", updateURL(c, containerName), gophercloud.RequestOpts{
MoreHeaders: h,
- OkCodes: []int{202, 204},
+ OkCodes: []int{201, 202, 204},
})
res.Header = resp.Header
res.Err = err
diff --git a/openstack/objectstorage/v1/objects/requests.go b/openstack/objectstorage/v1/objects/requests.go
index 30ea94c..7eedde2 100644
--- a/openstack/objectstorage/v1/objects/requests.go
+++ b/openstack/objectstorage/v1/objects/requests.go
@@ -211,7 +211,6 @@
ropts := gophercloud.RequestOpts{
RawBody: content,
MoreHeaders: h,
- OkCodes: []int{201, 202},
}
resp, err := c.Request("PUT", url, ropts)
@@ -310,9 +309,7 @@
url += query
}
- resp, err := c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ resp, err := c.Delete(url, nil)
res.Header = resp.Header
res.Err = err
return res
@@ -412,7 +409,6 @@
url := updateURL(c, containerName, objectName)
resp, err := c.Request("POST", url, gophercloud.RequestOpts{
MoreHeaders: h,
- OkCodes: []int{202},
})
res.Header = resp.Header
res.Err = err
diff --git a/openstack/orchestration/v1/buildinfo/requests.go b/openstack/orchestration/v1/buildinfo/requests.go
index 379f34f..9e03e5c 100644
--- a/openstack/orchestration/v1/buildinfo/requests.go
+++ b/openstack/orchestration/v1/buildinfo/requests.go
@@ -5,9 +5,6 @@
// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c), &res.Body, nil)
return res
}
diff --git a/openstack/orchestration/v1/stackevents/requests.go b/openstack/orchestration/v1/stackevents/requests.go
index 37eab1e..53c3916 100644
--- a/openstack/orchestration/v1/stackevents/requests.go
+++ b/openstack/orchestration/v1/stackevents/requests.go
@@ -11,7 +11,6 @@
_, res.Err = c.Request("GET", findURL(c, stackName), gophercloud.RequestOpts{
JSONResponse: &res.Body,
- OkCodes: []int{200},
})
return res
}
@@ -197,9 +196,8 @@
// Get retreives data for the given stack resource.
func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, stackName, stackID, resourceName, eventID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Get(getURL(c, stackName, stackID, resourceName, eventID), &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
diff --git a/openstack/orchestration/v1/stackresources/requests.go b/openstack/orchestration/v1/stackresources/requests.go
index 2a66edc..ee9c3c2 100644
--- a/openstack/orchestration/v1/stackresources/requests.go
+++ b/openstack/orchestration/v1/stackresources/requests.go
@@ -12,7 +12,6 @@
// Send request to API
_, res.Err = c.Request("GET", findURL(c, stackName), gophercloud.RequestOpts{
JSONResponse: &res.Body,
- OkCodes: []int{200},
})
return res
}
@@ -71,9 +70,8 @@
var res GetResult
// Send request to API
- _, res.Err = c.Request("GET", getURL(c, stackName, stackID, resourceName), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Get(getURL(c, stackName, stackID, resourceName), &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -83,9 +81,8 @@
var res MetadataResult
// Send request to API
- _, res.Err = c.Request("GET", metadataURL(c, stackName, stackID, resourceName), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Get(metadataURL(c, stackName, stackID, resourceName), &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -106,9 +103,8 @@
var res SchemaResult
// Send request to API
- _, res.Err = c.Request("GET", schemaURL(c, resourceType), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Get(schemaURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -118,9 +114,8 @@
var res TemplateResult
// Send request to API
- _, res.Err = c.Request("GET", templateURL(c, resourceType), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Get(templateURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
diff --git a/openstack/orchestration/v1/stacks/requests.go b/openstack/orchestration/v1/stacks/requests.go
index c0388c3..0dd6af2 100644
--- a/openstack/orchestration/v1/stacks/requests.go
+++ b/openstack/orchestration/v1/stacks/requests.go
@@ -111,12 +111,7 @@
return res
}
- // Send request to API
- _, res.Err = c.Request("POST", createURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil)
return res
}
@@ -221,12 +216,7 @@
return res
}
- // Send request to API
- _, res.Err = c.Request("POST", adoptURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(adoptURL(c), reqBody, &res.Body, nil)
return res
}
@@ -302,12 +292,7 @@
// Get retreives a stack based on the stack name and stack ID.
func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult {
var res GetResult
-
- // Send request to API
- _, res.Err = c.Request("GET", getURL(c, stackName, stackID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, stackName, stackID), &res.Body, nil)
return res
}
@@ -388,22 +373,14 @@
return res
}
- // Send request to API
- _, res.Err = c.Request("PUT", updateURL(c, stackName, stackID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
+ _, res.Err = c.Put(updateURL(c, stackName, stackID), reqBody, nil, nil)
return res
}
// Delete deletes a stack based on the stack name and stack ID.
func Delete(c *gophercloud.ServiceClient, stackName, stackID string) DeleteResult {
var res DeleteResult
-
- // Send request to API
- _, res.Err = c.Request("DELETE", deleteURL(c, stackName, stackID), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(deleteURL(c, stackName, stackID), nil)
return res
}
@@ -498,10 +475,8 @@
}
// Send request to API
- _, res.Err = c.Request("POST", previewURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Post(previewURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
@@ -510,9 +485,7 @@
// resources intact, and returns data describing the stack and its resources.
func Abandon(c *gophercloud.ServiceClient, stackName, stackID string) AbandonResult {
var res AbandonResult
-
- // Send request to API
- _, res.Err = c.Request("DELETE", abandonURL(c, stackName, stackID), gophercloud.RequestOpts{
+ _, res.Err = c.Delete(abandonURL(c, stackName, stackID), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
OkCodes: []int{200},
})
diff --git a/openstack/orchestration/v1/stacktemplates/requests.go b/openstack/orchestration/v1/stacktemplates/requests.go
index f57e226..ad1e468 100644
--- a/openstack/orchestration/v1/stacktemplates/requests.go
+++ b/openstack/orchestration/v1/stacktemplates/requests.go
@@ -11,7 +11,6 @@
var res GetResult
_, res.Err = c.Request("GET", getURL(c, stackName, stackID), gophercloud.RequestOpts{
JSONResponse: &res.Body,
- OkCodes: []int{200},
})
return res
}
@@ -52,10 +51,8 @@
return res
}
- _, res.Err = c.Request("POST", validateURL(c), gophercloud.RequestOpts{
- JSONBody: reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Post(validateURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
}
diff --git a/provider_client.go b/provider_client.go
index f342a5e..39fecc5 100644
--- a/provider_client.go
+++ b/provider_client.go
@@ -196,25 +196,28 @@
}
}
- // Validate the response code, if requested to do so.
- if options.OkCodes != nil {
- var ok bool
- for _, code := range options.OkCodes {
- if resp.StatusCode == code {
- ok = true
- break
- }
+ // Allow default OkCodes if none explicitly set
+ if options.OkCodes == nil {
+ options.OkCodes = defaultOkCodes(method)
+ }
+
+ // Validate the HTTP response status.
+ var ok bool
+ for _, code := range options.OkCodes {
+ if resp.StatusCode == code {
+ ok = true
+ break
}
- if !ok {
- body, _ := ioutil.ReadAll(resp.Body)
- resp.Body.Close()
- return resp, &UnexpectedResponseCodeError{
- URL: url,
- Method: method,
- Expected: options.OkCodes,
- Actual: resp.StatusCode,
- Body: body,
- }
+ }
+ if !ok {
+ body, _ := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ return resp, &UnexpectedResponseCodeError{
+ URL: url,
+ Method: method,
+ Expected: options.OkCodes,
+ Actual: resp.StatusCode,
+ Body: body,
}
}
@@ -226,3 +229,72 @@
return resp, nil
}
+
+func defaultOkCodes(method string) []int {
+ switch {
+ case method == "GET":
+ return []int{200}
+ case method == "POST":
+ return []int{201, 202}
+ case method == "PUT":
+ return []int{201, 202}
+ case method == "DELETE":
+ return []int{202, 204}
+ }
+
+ return []int{}
+}
+
+func (client *ProviderClient) Get(url string, JSONResponse *interface{}, opts *RequestOpts) (*http.Response, error) {
+ if opts == nil {
+ opts = &RequestOpts{}
+ }
+ if JSONResponse != nil {
+ opts.JSONResponse = JSONResponse
+ }
+ return client.Request("GET", url, *opts)
+}
+
+func (client *ProviderClient) Post(url string, JSONBody interface{}, JSONResponse *interface{}, opts *RequestOpts) (*http.Response, error) {
+ if opts == nil {
+ opts = &RequestOpts{}
+ }
+
+ if v, ok := (JSONBody).(io.Reader); ok {
+ opts.RawBody = v
+ } else if JSONBody != nil {
+ opts.JSONBody = JSONBody
+ }
+
+ if JSONResponse != nil {
+ opts.JSONResponse = JSONResponse
+ }
+
+ return client.Request("POST", url, *opts)
+}
+
+func (client *ProviderClient) Put(url string, JSONBody interface{}, JSONResponse *interface{}, opts *RequestOpts) (*http.Response, error) {
+ if opts == nil {
+ opts = &RequestOpts{}
+ }
+
+ if v, ok := (JSONBody).(io.Reader); ok {
+ opts.RawBody = v
+ } else if JSONBody != nil {
+ opts.JSONBody = JSONBody
+ }
+
+ if JSONResponse != nil {
+ opts.JSONResponse = JSONResponse
+ }
+
+ return client.Request("PUT", url, *opts)
+}
+
+func (client *ProviderClient) Delete(url string, opts *RequestOpts) (*http.Response, error) {
+ if opts == nil {
+ opts = &RequestOpts{}
+ }
+
+ return client.Request("DELETE", url, *opts)
+}
diff --git a/rackspace/compute/v2/networks/requests.go b/rackspace/compute/v2/networks/requests.go
index 3aefb0c..cebbffd 100644
--- a/rackspace/compute/v2/networks/requests.go
+++ b/rackspace/compute/v2/networks/requests.go
@@ -21,10 +21,7 @@
// Get retrieves a specific network based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
@@ -78,10 +75,8 @@
}
// Send request to API
- _, res.Err = c.Request("POST", createURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 201, 202},
+ _, res.Err = c.Post(createURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201, 202},
})
return res
}
@@ -89,8 +84,6 @@
// Delete accepts a unique ID and deletes the network associated with it.
func Delete(c *gophercloud.ServiceClient, networkID string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", deleteURL(c, networkID), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(deleteURL(c, networkID), nil)
return res
}
diff --git a/rackspace/compute/v2/virtualinterfaces/requests.go b/rackspace/compute/v2/virtualinterfaces/requests.go
index 3c81ef8..1ff7c5a 100644
--- a/rackspace/compute/v2/virtualinterfaces/requests.go
+++ b/rackspace/compute/v2/virtualinterfaces/requests.go
@@ -28,10 +28,8 @@
}
// Send request to API
- _, res.Err = c.Request("POST", createURL(c, instanceID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200, 201, 202},
+ _, res.Err = c.Post(createURL(c, instanceID), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 201, 202},
})
return res
}
@@ -40,7 +38,7 @@
// instanceID.
func Delete(c *gophercloud.ServiceClient, instanceID, interfaceID string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", deleteURL(c, instanceID, interfaceID), gophercloud.RequestOpts{
+ _, res.Err = c.Delete(deleteURL(c, instanceID, interfaceID), &gophercloud.RequestOpts{
OkCodes: []int{200, 204},
})
return res
diff --git a/rackspace/lb/v1/acl/requests.go b/rackspace/lb/v1/acl/requests.go
index 94d98e3..d4ce7c0 100644
--- a/rackspace/lb/v1/acl/requests.go
+++ b/rackspace/lb/v1/acl/requests.go
@@ -74,11 +74,7 @@
return res
}
- _, res.Err = client.Request("POST", rootURL(client, loadBalancerID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Post(rootURL(client, loadBalancerID), reqBody, nil, nil)
return res
}
@@ -95,19 +91,14 @@
url := rootURL(c, loadBalancerID)
url += gophercloud.IDSliceToQueryString("id", itemIDs)
- _, res.Err = c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(url, nil)
return res
}
// Delete will remove a single network item from a load balancer's access list.
func Delete(c *gophercloud.ServiceClient, lbID, itemID int) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, lbID, itemID), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = c.Delete(resourceURL(c, lbID, itemID), nil)
return res
}
@@ -115,8 +106,6 @@
// effectively resetting it and allowing all traffic.
func DeleteAll(c *gophercloud.ServiceClient, lbID int) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", rootURL(c, lbID), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = c.Delete(rootURL(c, lbID), nil)
return res
}
diff --git a/rackspace/lb/v1/lbs/requests.go b/rackspace/lb/v1/lbs/requests.go
index 49a46f6..46f5f02 100644
--- a/rackspace/lb/v1/lbs/requests.go
+++ b/rackspace/lb/v1/lbs/requests.go
@@ -227,12 +227,7 @@
return res
}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
@@ -243,9 +238,8 @@
func Get(c *gophercloud.ServiceClient, id int) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -269,21 +263,14 @@
url := rootURL(c)
url += gophercloud.IDSliceToQueryString("id", ids)
- _, res.Err = c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(url, nil)
return res
}
// Delete removes a single load balancer.
func Delete(c *gophercloud.ServiceClient, id int) DeleteResult {
var res DeleteResult
-
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
@@ -363,11 +350,7 @@
return res
}
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, nil, nil)
return res
}
@@ -394,10 +377,7 @@
func IsLoggingEnabled(client *gophercloud.ServiceClient, id int) (bool, error) {
var body interface{}
- _, err := client.Request("GET", loggingURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &body,
- OkCodes: []int{200},
- })
+ _, err := client.Get(loggingURL(client, id), &body, nil)
if err != nil {
return false, err
}
@@ -420,39 +400,22 @@
// EnableLogging will enable connection logging for a specified load balancer.
func EnableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toConnLoggingMap(true)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", loggingURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(true), nil, nil)
return res
}
// DisableLogging will disable connection logging for a specified load balancer.
func DisableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toConnLoggingMap(false)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", loggingURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(false), nil, nil)
return res
}
// GetErrorPage will retrieve the current error page for the load balancer.
func GetErrorPage(client *gophercloud.ServiceClient, id int) ErrorPageResult {
var res ErrorPageResult
-
- _, res.Err = client.Request("GET", errorPageURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = client.Get(errorPageURL(client, id), &res.Body, nil)
return res
}
@@ -464,10 +427,8 @@
type stringMap map[string]string
reqBody := map[string]stringMap{"errorpage": stringMap{"content": html}}
- _, res.Err = client.Request("PUT", errorPageURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- JSONBody: &reqBody,
- OkCodes: []int{200},
+ _, res.Err = client.Put(errorPageURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -476,23 +437,16 @@
// DeleteErrorPage will delete the current error page for the load balancer.
func DeleteErrorPage(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("DELETE", errorPageURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Delete(errorPageURL(client, id), &gophercloud.RequestOpts{
OkCodes: []int{200},
})
-
return res
}
// GetStats will retrieve detailed stats related to the load balancer's usage.
func GetStats(client *gophercloud.ServiceClient, id int) StatsResult {
var res StatsResult
-
- _, res.Err = client.Request("GET", statsURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = client.Get(statsURL(client, id), &res.Body, nil)
return res
}
@@ -507,10 +461,7 @@
func IsContentCached(client *gophercloud.ServiceClient, id int) (bool, error) {
var body interface{}
- _, err := client.Request("GET", cacheURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &body,
- OkCodes: []int{200},
- })
+ _, err := client.Get(cacheURL(client, id), &body, nil)
if err != nil {
return false, err
}
@@ -533,26 +484,14 @@
// EnableCaching will enable content-caching for the specified load balancer.
func EnableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toCachingMap(true)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", cacheURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(cacheURL(client, id), toCachingMap(true), nil, nil)
return res
}
// DisableCaching will disable content-caching for the specified load balancer.
func DisableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toCachingMap(false)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", cacheURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(cacheURL(client, id), toCachingMap(false), nil, nil)
return res
}
diff --git a/rackspace/lb/v1/monitors/requests.go b/rackspace/lb/v1/monitors/requests.go
index 917282c..d4ba276 100644
--- a/rackspace/lb/v1/monitors/requests.go
+++ b/rackspace/lb/v1/monitors/requests.go
@@ -141,33 +141,20 @@
return res
}
- _, res.Err = c.Request("PUT", rootURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Put(rootURL(c, id), reqBody, nil, nil)
return res
}
// Get is the operation responsible for showing details of a health monitor.
func Get(c *gophercloud.ServiceClient, id int) GetResult {
var res GetResult
-
- _, res.Err = c.Request("GET", rootURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = c.Get(rootURL(c, id), &res.Body, nil)
return res
}
// Delete is the operation responsible for deleting a health monitor.
func Delete(c *gophercloud.ServiceClient, id int) DeleteResult {
var res DeleteResult
-
- _, res.Err = c.Request("DELETE", rootURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(rootURL(c, id), nil)
return res
}
diff --git a/rackspace/lb/v1/nodes/requests.go b/rackspace/lb/v1/nodes/requests.go
index 86fe5d7..02af86b 100644
--- a/rackspace/lb/v1/nodes/requests.go
+++ b/rackspace/lb/v1/nodes/requests.go
@@ -112,11 +112,8 @@
return res
}
- resp, err := client.Request("POST", rootURL(client, loadBalancerID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
+ resp, err := client.Post(rootURL(client, loadBalancerID), reqBody, &res.Body, nil)
+
if err != nil {
res.Err = err
return res
@@ -145,22 +142,14 @@
url := rootURL(c, loadBalancerID)
url += gophercloud.IDSliceToQueryString("id", nodeIDs)
- _, res.Err = c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(url, nil)
return res
}
// Get is the operation responsible for showing details for a single node.
func Get(c *gophercloud.ServiceClient, lbID, nodeID int) GetResult {
var res GetResult
-
- _, res.Err = c.Request("GET", resourceURL(c, lbID, nodeID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = c.Get(resourceURL(c, lbID, nodeID), &res.Body, nil)
return res
}
@@ -213,20 +202,14 @@
return res
}
- _, res.Err = c.Request("PUT", resourceURL(c, lbID, nodeID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Put(resourceURL(c, lbID, nodeID), reqBody, nil, nil)
return res
}
// Delete is the operation responsible for permanently deleting a node.
func Delete(c *gophercloud.ServiceClient, lbID, nodeID int) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, lbID, nodeID), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = c.Delete(resourceURL(c, lbID, nodeID), nil)
return res
}
diff --git a/rackspace/lb/v1/sessions/requests.go b/rackspace/lb/v1/sessions/requests.go
index 5572407..a93d766 100644
--- a/rackspace/lb/v1/sessions/requests.go
+++ b/rackspace/lb/v1/sessions/requests.go
@@ -42,12 +42,7 @@
return res
}
- _, res.Err = c.Request("PUT", rootURL(c, lbID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, nil)
return res
}
@@ -55,12 +50,7 @@
// persistence configuration for a particular load balancer.
func Get(c *gophercloud.ServiceClient, lbID int) GetResult {
var res GetResult
-
- _, res.Err = c.Request("GET", rootURL(c, lbID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil)
return res
}
@@ -68,10 +58,6 @@
// particular load balancer.
func Disable(c *gophercloud.ServiceClient, lbID int) DisableResult {
var res DisableResult
-
- _, res.Err = c.Request("DELETE", rootURL(c, lbID), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(rootURL(c, lbID), nil)
return res
}
diff --git a/rackspace/lb/v1/ssl/requests.go b/rackspace/lb/v1/ssl/requests.go
index e9c6514..bb53ef8 100644
--- a/rackspace/lb/v1/ssl/requests.go
+++ b/rackspace/lb/v1/ssl/requests.go
@@ -85,12 +85,9 @@
return res
}
- _, res.Err = c.Request("PUT", rootURL(c, lbID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
-
return res
}
@@ -98,12 +95,7 @@
// Termination configuration for a load balancer.
func Get(c *gophercloud.ServiceClient, lbID int) GetResult {
var res GetResult
-
- _, res.Err = c.Request("GET", rootURL(c, lbID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil)
return res
}
@@ -111,11 +103,9 @@
// configuration for a load balancer.
func Delete(c *gophercloud.ServiceClient, lbID int) DeleteResult {
var res DeleteResult
-
- _, res.Err = c.Request("DELETE", rootURL(c, lbID), gophercloud.RequestOpts{
+ _, res.Err = c.Delete(rootURL(c, lbID), &gophercloud.RequestOpts{
OkCodes: []int{200},
})
-
return res
}
@@ -180,10 +170,8 @@
return res
}
- _, res.Err = c.Request("POST", certURL(c, lbID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Post(certURL(c, lbID), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -192,12 +180,7 @@
// GetCert will show the details of an existing SSL certificate.
func GetCert(c *gophercloud.ServiceClient, lbID, certID int) GetCertResult {
var res GetCertResult
-
- _, res.Err = c.Request("GET", certResourceURL(c, lbID, certID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = c.Get(certResourceURL(c, lbID, certID), &res.Body, nil)
return res
}
@@ -247,12 +230,7 @@
return res
}
- _, res.Err = c.Request("PUT", certResourceURL(c, lbID, certID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Put(certResourceURL(c, lbID, certID), reqBody, &res.Body, nil)
return res
}
@@ -261,7 +239,7 @@
func DeleteCert(c *gophercloud.ServiceClient, lbID, certID int) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", certResourceURL(c, lbID, certID), gophercloud.RequestOpts{
+ _, res.Err = c.Delete(certResourceURL(c, lbID, certID), &gophercloud.RequestOpts{
OkCodes: []int{200},
})
diff --git a/rackspace/lb/v1/throttle/requests.go b/rackspace/lb/v1/throttle/requests.go
index 2680a89..0446b97 100644
--- a/rackspace/lb/v1/throttle/requests.go
+++ b/rackspace/lb/v1/throttle/requests.go
@@ -55,12 +55,7 @@
return res
}
- _, res.Err = c.Request("PUT", rootURL(c, lbID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, nil)
return res
}
@@ -68,12 +63,7 @@
// throttling configuration for a load balancer.
func Get(c *gophercloud.ServiceClient, lbID int) GetResult {
var res GetResult
-
- _, res.Err = c.Request("GET", rootURL(c, lbID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil)
return res
}
@@ -81,10 +71,6 @@
// configuration for a load balancer.
func Delete(c *gophercloud.ServiceClient, lbID int) DeleteResult {
var res DeleteResult
-
- _, res.Err = c.Request("DELETE", rootURL(c, lbID), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(rootURL(c, lbID), nil)
return res
}
diff --git a/rackspace/lb/v1/vips/requests.go b/rackspace/lb/v1/vips/requests.go
index d52a73a..2bc924f 100644
--- a/rackspace/lb/v1/vips/requests.go
+++ b/rackspace/lb/v1/vips/requests.go
@@ -67,12 +67,7 @@
return res
}
- _, res.Err = c.Request("POST", rootURL(c, lbID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Post(rootURL(c, lbID), reqBody, &res.Body, nil)
return res
}
@@ -90,18 +85,13 @@
url := rootURL(c, loadBalancerID)
url += gophercloud.IDSliceToQueryString("id", vipIDs)
- _, res.Err = c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(url, nil)
return res
}
// Delete is the operation responsible for permanently deleting a VIP.
func Delete(c *gophercloud.ServiceClient, lbID, vipID int) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", resourceURL(c, lbID, vipID), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
+ _, res.Err = c.Delete(resourceURL(c, lbID, vipID), nil)
return res
}
diff --git a/rackspace/rackconnect/v3/cloudnetworks/requests.go b/rackspace/rackconnect/v3/cloudnetworks/requests.go
index 33f5e04..5884303 100644
--- a/rackspace/rackconnect/v3/cloudnetworks/requests.go
+++ b/rackspace/rackconnect/v3/cloudnetworks/requests.go
@@ -19,9 +19,6 @@
// based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
diff --git a/rackspace/rackconnect/v3/lbpools/requests.go b/rackspace/rackconnect/v3/lbpools/requests.go
index 4b4a103..c300c56 100644
--- a/rackspace/rackconnect/v3/lbpools/requests.go
+++ b/rackspace/rackconnect/v3/lbpools/requests.go
@@ -18,10 +18,7 @@
// based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
@@ -44,11 +41,7 @@
"id": serverID,
},
}
- _, res.Err = c.Request("POST", createNodeURL(c, poolID), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(createNodeURL(c, poolID), reqBody, &res.Body, nil)
return res
}
@@ -66,10 +59,7 @@
// based on its unique ID and the LB pool's unique ID.
func GetNode(c *gophercloud.ServiceClient, poolID, nodeID string) GetNodeResult {
var res GetNodeResult
- _, res.Err = c.Request("GET", nodeURL(c, poolID, nodeID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(nodeURL(c, poolID, nodeID), &res.Body, nil)
return res
}
@@ -77,9 +67,7 @@
// given poolID.
func DeleteNode(c *gophercloud.ServiceClient, poolID, nodeID string) DeleteNodeResult {
var res DeleteNodeResult
- _, res.Err = c.Request("DELETE", deleteNodeURL(c, poolID, nodeID), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(deleteNodeURL(c, poolID, nodeID), nil)
return res
}
@@ -87,10 +75,7 @@
// ID and the LB pool's unique ID.
func GetNodeDetails(c *gophercloud.ServiceClient, poolID, nodeID string) GetNodeDetailsResult {
var res GetNodeDetailsResult
- _, res.Err = c.Request("GET", nodeDetailsURL(c, poolID, nodeID), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(nodeDetailsURL(c, poolID, nodeID), &res.Body, nil)
return res
}
@@ -129,11 +114,7 @@
return res
}
- _, res.Err = c.Request("POST", createNodesURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(createNodesURL(c), reqBody, &res.Body, nil)
return res
}
diff --git a/rackspace/rackconnect/v3/publicips/requests.go b/rackspace/rackconnect/v3/publicips/requests.go
index 82a5295..1164260 100644
--- a/rackspace/rackconnect/v3/publicips/requests.go
+++ b/rackspace/rackconnect/v3/publicips/requests.go
@@ -22,11 +22,7 @@
"id": serverID,
},
}
- _, res.Err = c.Request("POST", createURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{201},
- })
+ _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil)
return res
}
@@ -42,18 +38,13 @@
// Get retrieves the public IP with the given id.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
+ _, res.Err = c.Get(getURL(c, id), &res.Body, nil)
return res
}
// Delete removes the public IP with the given id.
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = c.Request("DELETE", deleteURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{204},
- })
+ _, res.Err = c.Delete(deleteURL(c, id), nil)
return res
}