Change HTTP methods for OpenStack Compute
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 c29d46f..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,19 +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,
- })
-
+ _, 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{})
-
+ _, 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 1fad93a..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,16 +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,
- })
+ _, 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{})
+ _, res.Err = client.Delete(deleteURL(client, id), nil)
return res
}
@@ -79,9 +75,7 @@
addFloatingIp["address"] = fip
reqBody := map[string]interface{}{"addFloatingIp": addFloatingIp}
- _, res.Err = client.Request("POST", associateURL(client, serverId), gophercloud.RequestOpts{
- JSONBody: reqBody,
- })
+ _, res.Err = client.Post(associateURL(client, serverId), reqBody, nil, nil)
return res
}
@@ -93,8 +87,6 @@
removeFloatingIp["address"] = fip
reqBody := map[string]interface{}{"removeFloatingIp": removeFloatingIp}
- _, res.Err = client.Request("POST", disassociateURL(client, serverId), gophercloud.RequestOpts{
- JSONBody: reqBody,
- })
+ _, 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 1ab7274..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,15 +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,
- })
+ _, 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{})
+ _, 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 f8d88d3..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,20 +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,
- })
-
+ _, 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{})
-
+ _, result.Err = client.Delete(resourceURL(client, id), nil)
return result
}
@@ -231,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
@@ -243,9 +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{})
-
+ _, result.Err = client.Delete(resourceRuleURL(client, id), nil)
return result
}
@@ -259,23 +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),
- })
-
+ _, 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),
- })
-
+ _, 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 89bc248..0e090e6 100644
--- a/openstack/compute/v2/extensions/startstop/requests.go
+++ b/openstack/compute/v2/extensions/startstop/requests.go
@@ -9,25 +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,
- })
-
+ _, 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,
- })
-
+ _, 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 99cd1ae..3ec13d3 100644
--- a/openstack/compute/v2/extensions/tenantnetworks/requests.go
+++ b/openstack/compute/v2/extensions/tenantnetworks/requests.go
@@ -17,8 +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,
- })
+ _, 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 62de27c..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,15 +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,
- })
+ _, 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{})
+ _, res.Err = client.Delete(deleteURL(client, serverId, aId), nil)
return res
}