Skip to content

Commit 787f284

Browse files
committed
Use PUTs for CIS resource update calls
1 parent 7223a22 commit 787f284

File tree

7 files changed

+16
-21
lines changed

7 files changed

+16
-21
lines changed

api/cis/cisv1/dns.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (r *dns) CreateDns(cisId string, zoneId string, dnsBody DnsBody) (*DnsRecor
112112
func (r *dns) UpdateDns(cisId string, zoneId string, dnsId string, dnsBody DnsBody) (*DnsRecord, error) {
113113
dnsResult := DnsResult{}
114114
rawURL := fmt.Sprintf("/v1/%s/zones/%s/dns_records/%s", cisId, zoneId, dnsId)
115-
_, err := r.client.Post(rawURL, &dnsBody, &dnsResult)
115+
_, err := r.client.Put(rawURL, &dnsBody, &dnsResult)
116116
if err != nil {
117117
return nil, err
118118
}

api/cis/cisv1/dns_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import (
88
"github.com/IBM-Cloud/bluemix-go/client"
99
bluemixHttp "github.com/IBM-Cloud/bluemix-go/http"
1010
"github.com/IBM-Cloud/bluemix-go/session"
11-
12-
"github.com/onsi/gomega/ghttp"
13-
1411
. "github.com/onsi/ginkgo"
1512
. "github.com/onsi/gomega"
13+
"github.com/onsi/gomega/ghttp"
1614
)
1715

1816
var _ = Describe("Dns", func() {
@@ -320,7 +318,7 @@ var _ = Describe("Dns", func() {
320318
`),
321319
),
322320
ghttp.CombineHandlers(
323-
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
321+
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
324322
ghttp.RespondWith(http.StatusCreated, `
325323
{
326324
"result": {
@@ -376,7 +374,7 @@ var _ = Describe("Dns", func() {
376374
server = ghttp.NewServer()
377375
server.AppendHandlers(
378376
ghttp.CombineHandlers(
379-
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/0f4740fc36065f8a9343c7ed9445f2a4/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
377+
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/0f4740fc36065f8a9343c7ed9445f2a4/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
380378
ghttp.RespondWith(http.StatusInternalServerError, `Failed to update Dns`),
381379
),
382380
)

api/cis/cisv1/glbs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (r *glbs) CreateGlb(cisId string, zoneId string, glbBody GlbBody) (*Glb, er
115115
func (r *glbs) UpdateGlb(cisId string, zoneId string, glbId string, glbBody GlbBody) (*Glb, error) {
116116
glbResult := GlbResult{}
117117
rawURL := fmt.Sprintf("/v1/%s/zones/%s/load_balancers/%s", cisId, zoneId, glbId)
118-
_, err := r.client.Post(rawURL, &glbBody, &glbResult)
118+
_, err := r.client.Put(rawURL, &glbBody, &glbResult)
119119
if err != nil {
120120
return nil, err
121121
}

api/cis/cisv1/glbs_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import (
88
"github.com/IBM-Cloud/bluemix-go/client"
99
bluemixHttp "github.com/IBM-Cloud/bluemix-go/http"
1010
"github.com/IBM-Cloud/bluemix-go/session"
11-
12-
"github.com/onsi/gomega/ghttp"
13-
1411
. "github.com/onsi/ginkgo"
1512
. "github.com/onsi/gomega"
13+
"github.com/onsi/gomega/ghttp"
1614
)
1715

1816
var _ = Describe("Glbs", func() {
@@ -353,7 +351,7 @@ var _ = Describe("Glbs", func() {
353351
`),
354352
),
355353
ghttp.CombineHandlers(
356-
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
354+
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
357355
ghttp.VerifyJSON(`{"proxied": true, "name": "www.example.com", "session_affinity": "none", "fallback_pool": "4112ba6c2974ec43886f90736968e888", "default_pools": ["6563ebae141638f92ebbdc4a821bef8c", "4112ba6c2974ec43886f90736968e838"]}`),
358356
ghttp.RespondWith(http.StatusCreated, `
359357
{
@@ -428,7 +426,7 @@ var _ = Describe("Glbs", func() {
428426
server = ghttp.NewServer()
429427
server.AppendHandlers(
430428
ghttp.CombineHandlers(
431-
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
429+
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
432430
ghttp.RespondWith(http.StatusInternalServerError, `Failed to create Glb`),
433431
),
434432
)

api/cis/cisv1/monitors.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ type MonitorResult struct {
3737
}
3838

3939
type MonitorBody struct {
40-
ExpCodes string `json:"expected_codes"`
41-
ExpBody string `json:"expected_body"`
42-
Path string `json:"path"`
40+
Description string `json:"description"`
41+
ExpCodes string `json:"expected_codes"`
42+
ExpBody string `json:"expected_body"`
43+
Path string `json:"path"`
4344
// Headers ommited TBC
4445
MonType string `json:"type,omitempty"`
4546
Method string `json:"method,omitempty"`

api/cis/cisv1/pools.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (r *pools) CreatePool(cisId string, poolBody PoolBody) (*Pool, error) {
126126
func (r *pools) UpdatePool(cisId string, poolId string, poolBody PoolBody) (*Pool, error) {
127127
poolResult := PoolResult{}
128128
rawURL := fmt.Sprintf("/v1/%s/load_balancers/pools/%s", cisId, poolId)
129-
_, err := r.client.Post(rawURL, &poolBody, &poolResult)
129+
_, err := r.client.Put(rawURL, &poolBody, &poolResult)
130130
if err != nil {
131131
return nil, err
132132
}

api/cis/cisv1/pools_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import (
88
"github.com/IBM-Cloud/bluemix-go/client"
99
bluemixHttp "github.com/IBM-Cloud/bluemix-go/http"
1010
"github.com/IBM-Cloud/bluemix-go/session"
11-
12-
"github.com/onsi/gomega/ghttp"
13-
1411
. "github.com/onsi/ginkgo"
1512
. "github.com/onsi/gomega"
13+
"github.com/onsi/gomega/ghttp"
1614
)
1715

1816
var _ = Describe("Pools", func() {
@@ -416,7 +414,7 @@ var _ = Describe("Pools", func() {
416414
`),
417415
),
418416
ghttp.CombineHandlers(
419-
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
417+
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
420418
ghttp.RespondWith(http.StatusCreated, `
421419
{
422420
"result": {
@@ -506,7 +504,7 @@ var _ = Describe("Pools", func() {
506504
server = ghttp.NewServer()
507505
server.AppendHandlers(
508506
ghttp.CombineHandlers(
509-
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
507+
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
510508
ghttp.RespondWith(http.StatusInternalServerError, `Failed to create Pool`),
511509
),
512510
)

0 commit comments

Comments
 (0)