Modifying JSON keys because the documentation lied to me
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/requests.go b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
index dcdb0cc..572ea80 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
@@ -202,7 +202,7 @@
}
type request struct {
- Monitor monitor `json:"healthmonitor"`
+ Monitor monitor `json:"health_monitor"`
}
reqBody := request{Monitor: monitor{
@@ -283,7 +283,7 @@
}
type request struct {
- Monitor monitor `json:"healthmonitor"`
+ Monitor monitor `json:"health_monitor"`
}
reqBody := request{Monitor: monitor{
@@ -302,7 +302,7 @@
MoreHeaders: c.Provider.AuthenticatedHeaders(),
ReqBody: &reqBody,
Results: &res.Resp,
- OkCodes: []int{202},
+ OkCodes: []int{200, 202},
})
return res
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go b/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go
index 3124729..6ee37ce 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go
@@ -22,14 +22,14 @@
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/lb/healthmonitors", rootURL(serviceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/lb/health_monitors", rootURL(serviceClient()))
}
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.Mux.HandleFunc("/v2.0/lb/healthmonitors", func(w http.ResponseWriter, r *http.Request) {
+ th.Mux.HandleFunc("/v2.0/lb/health_monitors", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", tokenID)
@@ -38,7 +38,7 @@
fmt.Fprintf(w, `
{
- "healthmonitors":[
+ "health_monitors":[
{
"admin_state_up":true,
"tenant_id":"83657cfcdfe44cd5920adaf26c48ceea",
@@ -113,14 +113,14 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- th.Mux.HandleFunc("/v2.0/lb/healthmonitors", func(w http.ResponseWriter, r *http.Request) {
+ th.Mux.HandleFunc("/v2.0/lb/health_monitors", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
th.TestHeader(t, r, "X-Auth-Token", tokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
{
- "healthmonitor":{
+ "health_monitor":{
"type":"HTTP",
"tenant_id":"453105b9-1754-413f-aab1-55f1af620750",
"delay":20,
@@ -137,7 +137,7 @@
fmt.Fprintf(w, `
{
- "healthmonitor":{
+ "health_monitor":{
"id":"f3eeab00-8367-4524-b662-55e64d4cacb5",
"tenant_id":"453105b9-1754-413f-aab1-55f1af620750",
"type":"HTTP",
@@ -171,7 +171,7 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- th.Mux.HandleFunc("/v2.0/lb/healthmonitors/f3eeab00-8367-4524-b662-55e64d4cacb5", func(w http.ResponseWriter, r *http.Request) {
+ th.Mux.HandleFunc("/v2.0/lb/health_monitors/f3eeab00-8367-4524-b662-55e64d4cacb5", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", tokenID)
@@ -180,7 +180,7 @@
fmt.Fprintf(w, `
{
- "healthmonitor":{
+ "health_monitor":{
"id":"f3eeab00-8367-4524-b662-55e64d4cacb5",
"tenant_id":"453105b9-1754-413f-aab1-55f1af620750",
"type":"HTTP",
@@ -217,14 +217,14 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- th.Mux.HandleFunc("/v2.0/lb/healthmonitors/b05e44b5-81f9-4551-b474-711a722698f7", func(w http.ResponseWriter, r *http.Request) {
+ th.Mux.HandleFunc("/v2.0/lb/health_monitors/b05e44b5-81f9-4551-b474-711a722698f7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
th.TestHeader(t, r, "X-Auth-Token", tokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
{
- "healthmonitor":{
+ "health_monitor":{
"delay": 3,
"timeout": 20,
"max_retries": 10,
@@ -239,7 +239,7 @@
fmt.Fprintf(w, `
{
- "healthmonitor": {
+ "health_monitor": {
"admin_state_up": true,
"tenant_id": "4fd44f30292945e481c7b8a0c8908869",
"delay": 3,
@@ -275,7 +275,7 @@
th.SetupHTTP()
defer th.TeardownHTTP()
- th.Mux.HandleFunc("/v2.0/lb/healthmonitors/b05e44b5-81f9-4551-b474-711a722698f7", func(w http.ResponseWriter, r *http.Request) {
+ th.Mux.HandleFunc("/v2.0/lb/health_monitors/b05e44b5-81f9-4551-b474-711a722698f7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
th.TestHeader(t, r, "X-Auth-Token", tokenID)
w.WriteHeader(http.StatusNoContent)
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/results.go b/openstack/networking/v2/extensions/lbaas/monitors/results.go
index 44c1fff..5804b08 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/results.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/results.go
@@ -79,7 +79,7 @@
Rel string `mapstructure:"rel"`
}
type resp struct {
- Links []link `mapstructure:"healthmonitors_links"`
+ Links []link `mapstructure:"health_monitors_links"`
}
var r resp
@@ -115,7 +115,7 @@
// a generic collection is mapped into a relevant slice.
func ExtractMonitors(page pagination.Page) ([]Monitor, error) {
var resp struct {
- Monitors []Monitor `mapstructure:"healthmonitors" json:"healthmonitors"`
+ Monitors []Monitor `mapstructure:"health_monitor" json:"health_monitor"`
}
err := mapstructure.Decode(page.(MonitorPage).Body, &resp)
@@ -137,7 +137,7 @@
}
var res struct {
- Monitor *Monitor `json:"healthmonitor" mapstructure:"healthmonitor"`
+ Monitor *Monitor `json:"health_monitor" mapstructure:"health_monitor"`
}
err := mapstructure.Decode(r.Resp, &res)
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/urls.go b/openstack/networking/v2/extensions/lbaas/monitors/urls.go
index b6eeb24..e4b2afc 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/urls.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/urls.go
@@ -5,7 +5,7 @@
const (
version = "v2.0"
rootPath = "lb"
- resourcePath = "healthmonitors"
+ resourcePath = "health_monitors"
)
func rootURL(c *gophercloud.ServiceClient) string {
diff --git a/openstack/networking/v2/extensions/lbaas/pools/requests.go b/openstack/networking/v2/extensions/lbaas/pools/requests.go
index 9ce2672..bfdbefe 100644
--- a/openstack/networking/v2/extensions/lbaas/pools/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/pools/requests.go
@@ -122,8 +122,8 @@
// load balancer pool.
func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
type pool struct {
- Name string `json:"name,"`
- TenantID string `json:"tenant_id"`
+ Name string `json:"name"`
+ TenantID string `json:"tenant_id,omitempty"`
Protocol string `json:"protocol"`
SubnetID string `json:"subnet_id"`
LBMethod string `json:"lb_method"`
diff --git a/openstack/networking/v2/extensions/lbaas/vips/requests.go b/openstack/networking/v2/extensions/lbaas/vips/requests.go
index 31ed975..c2e27f9 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/requests.go
@@ -302,7 +302,7 @@
MoreHeaders: c.Provider.AuthenticatedHeaders(),
ReqBody: &reqBody,
Results: &res.Resp,
- OkCodes: []int{202},
+ OkCodes: []int{200, 202},
})
return res