Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PUTs for CIS resource update calls #195

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/cis/cisv1/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *dns) CreateDns(cisId string, zoneId string, dnsBody DnsBody) (*DnsRecor
func (r *dns) UpdateDns(cisId string, zoneId string, dnsId string, dnsBody DnsBody) (*DnsRecord, error) {
dnsResult := DnsResult{}
rawURL := fmt.Sprintf("/v1/%s/zones/%s/dns_records/%s", cisId, zoneId, dnsId)
_, err := r.client.Post(rawURL, &dnsBody, &dnsResult)
_, err := r.client.Put(rawURL, &dnsBody, &dnsResult)
if err != nil {
return nil, err
}
Expand Down
8 changes: 3 additions & 5 deletions api/cis/cisv1/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import (
"github.com/IBM-Cloud/bluemix-go/client"
bluemixHttp "github.com/IBM-Cloud/bluemix-go/http"
"github.com/IBM-Cloud/bluemix-go/session"

"github.com/onsi/gomega/ghttp"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Dns", func() {
Expand Down Expand Up @@ -320,7 +318,7 @@ var _ = Describe("Dns", func() {
`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
ghttp.RespondWith(http.StatusCreated, `
{
"result": {
Expand Down Expand Up @@ -376,7 +374,7 @@ var _ = Describe("Dns", func() {
server = ghttp.NewServer()
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/0f4740fc36065f8a9343c7ed9445f2a4/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/0f4740fc36065f8a9343c7ed9445f2a4/dns_records/0f4740fc36065f8a9343c7ed9445f2a4"),
ghttp.RespondWith(http.StatusInternalServerError, `Failed to update Dns`),
),
)
Expand Down
2 changes: 1 addition & 1 deletion api/cis/cisv1/glbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (r *glbs) CreateGlb(cisId string, zoneId string, glbBody GlbBody) (*Glb, er
func (r *glbs) UpdateGlb(cisId string, zoneId string, glbId string, glbBody GlbBody) (*Glb, error) {
glbResult := GlbResult{}
rawURL := fmt.Sprintf("/v1/%s/zones/%s/load_balancers/%s", cisId, zoneId, glbId)
_, err := r.client.Post(rawURL, &glbBody, &glbResult)
_, err := r.client.Put(rawURL, &glbBody, &glbResult)
if err != nil {
return nil, err
}
Expand Down
8 changes: 3 additions & 5 deletions api/cis/cisv1/glbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import (
"github.com/IBM-Cloud/bluemix-go/client"
bluemixHttp "github.com/IBM-Cloud/bluemix-go/http"
"github.com/IBM-Cloud/bluemix-go/session"

"github.com/onsi/gomega/ghttp"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Glbs", func() {
Expand Down Expand Up @@ -353,7 +351,7 @@ var _ = Describe("Glbs", func() {
`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
ghttp.VerifyJSON(`{"proxied": true, "name": "www.example.com", "session_affinity": "none", "fallback_pool": "4112ba6c2974ec43886f90736968e888", "default_pools": ["6563ebae141638f92ebbdc4a821bef8c", "4112ba6c2974ec43886f90736968e838"]}`),
ghttp.RespondWith(http.StatusCreated, `
{
Expand Down Expand Up @@ -428,7 +426,7 @@ var _ = Describe("Glbs", func() {
server = ghttp.NewServer()
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/zones/3fefc35e7decadb111dcf85d723a4f20/load_balancers/07085e0ea3c40225dcab6aff04cf64d9"),
ghttp.RespondWith(http.StatusInternalServerError, `Failed to create Glb`),
),
)
Expand Down
7 changes: 4 additions & 3 deletions api/cis/cisv1/monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ type MonitorResult struct {
}

type MonitorBody struct {
ExpCodes string `json:"expected_codes"`
ExpBody string `json:"expected_body"`
Path string `json:"path"`
Description string `json:"description"`
ExpCodes string `json:"expected_codes"`
ExpBody string `json:"expected_body"`
Path string `json:"path"`
// Headers ommited TBC
MonType string `json:"type,omitempty"`
Method string `json:"method,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion api/cis/cisv1/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (r *pools) CreatePool(cisId string, poolBody PoolBody) (*Pool, error) {
func (r *pools) UpdatePool(cisId string, poolId string, poolBody PoolBody) (*Pool, error) {
poolResult := PoolResult{}
rawURL := fmt.Sprintf("/v1/%s/load_balancers/pools/%s", cisId, poolId)
_, err := r.client.Post(rawURL, &poolBody, &poolResult)
_, err := r.client.Put(rawURL, &poolBody, &poolResult)
if err != nil {
return nil, err
}
Expand Down
8 changes: 3 additions & 5 deletions api/cis/cisv1/pools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import (
"github.com/IBM-Cloud/bluemix-go/client"
bluemixHttp "github.com/IBM-Cloud/bluemix-go/http"
"github.com/IBM-Cloud/bluemix-go/session"

"github.com/onsi/gomega/ghttp"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Pools", func() {
Expand Down Expand Up @@ -416,7 +414,7 @@ var _ = Describe("Pools", func() {
`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
ghttp.RespondWith(http.StatusCreated, `
{
"result": {
Expand Down Expand Up @@ -506,7 +504,7 @@ var _ = Describe("Pools", func() {
server = ghttp.NewServer()
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
ghttp.VerifyRequest(http.MethodPut, "/v1/crn:v1:staging:public:iam::::apikey:ApiKey-62fefdd1-4557-4c7d-8a1c-f6da7ee2ff3a/load_balancers/pools/4112ba6c2974ec43886f90736968e838"),
ghttp.RespondWith(http.StatusInternalServerError, `Failed to create Pool`),
),
)
Expand Down