diff --git a/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go b/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go index 2d40e690..0348fd02 100644 --- a/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go +++ b/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go @@ -140,6 +140,38 @@ Example to perform system-update action on a load balancer panic(err) } +Example to perform system-update action with rollback on a load balancer + + rollback := true + systemUpdate := load_balancers.ActionOptsSystemUpdate{ + SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb", + Rollback: &rollback, + } + actionOpts := load_balancers.ActionOpts{ + SystemUpdate: &systemUpdate, + } + + id := "497f6eca-6276-4993-bfeb-53cbbbba6f08" + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + if err != nil { + panic(err) + } + +Example to perform change-plan action on a load balancer + + changePlan := load_balancers.ActionOptsChangePlan{ + PlanID: "00713021-9aea-41da-9a88-87760c08fa72", + } + actionOpts := load_balancers.ActionOpts{ + ChangePlan: &changePlan, + } + + id := "497f6eca-6276-4993-bfeb-53cbbbba6f08" + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + if err != nil { + panic(err) + } + Example to perform apply-configurations and system-update action on a load balancer systemUpdate := load_balancers.ActionOptsSystemUpdate{ diff --git a/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go b/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go index 7d578c0e..c9f90538 100644 --- a/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go +++ b/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go @@ -321,6 +321,17 @@ type ActionOptsSystemUpdate struct { // - ID of the system update that will be applied to the load balancer SystemUpdateID string `json:"system_update_id"` + + // - Rollback the load balancer to the version prior to the specified system update + // - The target system update must allow rollback (is_rollback_allowed: true) + Rollback *bool `json:"rollback,omitempty"` +} + +// ActionOptsChangePlan represents change-plan information in the load balancer action. +type ActionOptsChangePlan struct { + + // - ID of the plan that the load balancer will be changed to + PlanID string `json:"plan_id"` } // ActionOpts represents options used to perform action on a existing load balancer. @@ -331,6 +342,9 @@ type ActionOpts struct { // - Apply the system update to the load balancer SystemUpdate *ActionOptsSystemUpdate `json:"system-update,omitempty"` + + // - Change the plan of the load balancer + ChangePlan *ActionOptsChangePlan `json:"change-plan,omitempty"` } // ToLoadBalancerActionMap builds a request body from ActionOpts. @@ -342,9 +356,21 @@ func (opts ActionOpts) ToLoadBalancerActionMap() map[string]interface{} { } if opts.SystemUpdate != nil { - optsMap["system-update"] = map[string]interface{}{ + systemUpdateMap := map[string]interface{}{ "system_update_id": opts.SystemUpdate.SystemUpdateID, } + + if opts.SystemUpdate.Rollback != nil { + systemUpdateMap["rollback"] = *opts.SystemUpdate.Rollback + } + + optsMap["system-update"] = systemUpdateMap + } + + if opts.ChangePlan != nil { + optsMap["change-plan"] = map[string]interface{}{ + "plan_id": opts.ChangePlan.PlanID, + } } return optsMap diff --git a/v2/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go b/v2/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go index 64539b66..0321b316 100644 --- a/v2/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go +++ b/v2/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go @@ -422,6 +422,14 @@ var systemUpdateRequest = fmt.Sprintf(` } }`) +var systemUpdateWithRollbackRequest = fmt.Sprintf(` +{ + "system-update": { + "system_update_id": "31746df7-92f9-4b5e-ad05-59f6684a54eb", + "rollback": true + } +}`) + var applyConfigurationsAndSystemUpdateRequest = fmt.Sprintf(` { "apply-configurations": null, @@ -430,6 +438,13 @@ var applyConfigurationsAndSystemUpdateRequest = fmt.Sprintf(` } }`) +var changePlanRequest = fmt.Sprintf(` +{ + "change-plan": { + "plan_id": "00713021-9aea-41da-9a88-87760c08fa72" + } +}`) + var cancelConfigurationsRequest = fmt.Sprintf(` { "cancel-configurations": null diff --git a/v2/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go b/v2/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go index 22cf0666..e6be42a5 100644 --- a/v2/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go +++ b/v2/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go @@ -268,6 +268,68 @@ func TestSystemUpdateLoadBalancer(t *testing.T) { th.AssertNoErr(t, err) } +func TestSystemUpdateWithRollbackLoadBalancer(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc( + fmt.Sprintf("/v1.0/load_balancers/%s/action", id), + 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, systemUpdateWithRollbackRequest) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusNoContent) + }) + + cli := ServiceClient() + rollback := true + systemUpdate := load_balancers.ActionOptsSystemUpdate{ + SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb", + Rollback: &rollback, + } + actionOpts := load_balancers.ActionOpts{ + SystemUpdate: &systemUpdate, + } + + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + + th.AssertNoErr(t, err) +} + +func TestChangePlanLoadBalancer(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc( + fmt.Sprintf("/v1.0/load_balancers/%s/action", id), + 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, changePlanRequest) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusNoContent) + }) + + cli := ServiceClient() + changePlan := load_balancers.ActionOptsChangePlan{ + PlanID: "00713021-9aea-41da-9a88-87760c08fa72", + } + actionOpts := load_balancers.ActionOpts{ + ChangePlan: &changePlan, + } + + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + + th.AssertNoErr(t, err) +} + func TestApplyConfigurationsAndSystemUpdateLoadBalancer(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() diff --git a/v2/ecl/managed_load_balancer/v1/system_updates/requests.go b/v2/ecl/managed_load_balancer/v1/system_updates/requests.go index caea0bf2..9f58859a 100644 --- a/v2/ecl/managed_load_balancer/v1/system_updates/requests.go +++ b/v2/ecl/managed_load_balancer/v1/system_updates/requests.go @@ -36,6 +36,9 @@ type ListOpts struct { // - Whether the system update can be applied to the load balancer Applicable bool `q:"applicable"` + // - Whether the system update allows rollback + IsRollbackAllowed bool `q:"is_rollback_allowed"` + // - If `true` is set, only the latest resource is displayed Latest bool `q:"latest"` } diff --git a/v2/ecl/managed_load_balancer/v1/system_updates/results.go b/v2/ecl/managed_load_balancer/v1/system_updates/results.go index d6ca5d2e..843a4318 100644 --- a/v2/ecl/managed_load_balancer/v1/system_updates/results.go +++ b/v2/ecl/managed_load_balancer/v1/system_updates/results.go @@ -49,6 +49,9 @@ type SystemUpdate struct { // - Whether the system update can be applied to the load balancer Applicable bool `json:"applicable"` + + // - Whether the system update allows rollback + IsRollbackAllowed bool `json:"is_rollback_allowed"` } // ExtractInto interprets any commonResult as a system update, if possible. diff --git a/v2/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go b/v2/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go index bdfb572e..c0e39156 100644 --- a/v2/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go +++ b/v2/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go @@ -20,7 +20,8 @@ var listResponse = fmt.Sprintf(` "limit_datetime": "2022-10-11 12:59:59", "current_revision": 1, "next_revision": 2, - "applicable": true + "applicable": true, + "is_rollback_allowed": true } ] }`) @@ -37,6 +38,7 @@ func listResult() []system_updates.SystemUpdate { systemUpdate1.CurrentRevision = 1 systemUpdate1.NextRevision = 2 systemUpdate1.Applicable = true + systemUpdate1.IsRollbackAllowed = true return []system_updates.SystemUpdate{systemUpdate1} } @@ -52,7 +54,8 @@ var showResponse = fmt.Sprintf(` "limit_datetime": "2022-10-11 12:59:59", "current_revision": 1, "next_revision": 2, - "applicable": true + "applicable": true, + "is_rollback_allowed": true } }`) @@ -68,6 +71,7 @@ func showResult() *system_updates.SystemUpdate { systemUpdate.CurrentRevision = 1 systemUpdate.NextRevision = 2 systemUpdate.Applicable = true + systemUpdate.IsRollbackAllowed = true return &systemUpdate } diff --git a/v3/ecl/managed_load_balancer/v1/load_balancers/doc.go b/v3/ecl/managed_load_balancer/v1/load_balancers/doc.go index 2d40e690..0348fd02 100644 --- a/v3/ecl/managed_load_balancer/v1/load_balancers/doc.go +++ b/v3/ecl/managed_load_balancer/v1/load_balancers/doc.go @@ -140,6 +140,38 @@ Example to perform system-update action on a load balancer panic(err) } +Example to perform system-update action with rollback on a load balancer + + rollback := true + systemUpdate := load_balancers.ActionOptsSystemUpdate{ + SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb", + Rollback: &rollback, + } + actionOpts := load_balancers.ActionOpts{ + SystemUpdate: &systemUpdate, + } + + id := "497f6eca-6276-4993-bfeb-53cbbbba6f08" + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + if err != nil { + panic(err) + } + +Example to perform change-plan action on a load balancer + + changePlan := load_balancers.ActionOptsChangePlan{ + PlanID: "00713021-9aea-41da-9a88-87760c08fa72", + } + actionOpts := load_balancers.ActionOpts{ + ChangePlan: &changePlan, + } + + id := "497f6eca-6276-4993-bfeb-53cbbbba6f08" + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + if err != nil { + panic(err) + } + Example to perform apply-configurations and system-update action on a load balancer systemUpdate := load_balancers.ActionOptsSystemUpdate{ diff --git a/v3/ecl/managed_load_balancer/v1/load_balancers/requests.go b/v3/ecl/managed_load_balancer/v1/load_balancers/requests.go index d5508525..4ae9dafd 100644 --- a/v3/ecl/managed_load_balancer/v1/load_balancers/requests.go +++ b/v3/ecl/managed_load_balancer/v1/load_balancers/requests.go @@ -321,6 +321,17 @@ type ActionOptsSystemUpdate struct { // - ID of the system update that will be applied to the load balancer SystemUpdateID string `json:"system_update_id"` + + // - Rollback the load balancer to the version prior to the specified system update + // - The target system update must allow rollback (is_rollback_allowed: true) + Rollback *bool `json:"rollback,omitempty"` +} + +// ActionOptsChangePlan represents change-plan information in the load balancer action. +type ActionOptsChangePlan struct { + + // - ID of the plan that the load balancer will be changed to + PlanID string `json:"plan_id"` } // ActionOpts represents options used to perform action on a existing load balancer. @@ -331,6 +342,9 @@ type ActionOpts struct { // - Apply the system update to the load balancer SystemUpdate *ActionOptsSystemUpdate `json:"system-update,omitempty"` + + // - Change the plan of the load balancer + ChangePlan *ActionOptsChangePlan `json:"change-plan,omitempty"` } // ToLoadBalancerActionMap builds a request body from ActionOpts. @@ -342,9 +356,21 @@ func (opts ActionOpts) ToLoadBalancerActionMap() map[string]interface{} { } if opts.SystemUpdate != nil { - optsMap["system-update"] = map[string]interface{}{ + systemUpdateMap := map[string]interface{}{ "system_update_id": opts.SystemUpdate.SystemUpdateID, } + + if opts.SystemUpdate.Rollback != nil { + systemUpdateMap["rollback"] = *opts.SystemUpdate.Rollback + } + + optsMap["system-update"] = systemUpdateMap + } + + if opts.ChangePlan != nil { + optsMap["change-plan"] = map[string]interface{}{ + "plan_id": opts.ChangePlan.PlanID, + } } return optsMap diff --git a/v3/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go b/v3/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go index f86a90ad..2cb28734 100644 --- a/v3/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go +++ b/v3/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go @@ -422,6 +422,14 @@ var systemUpdateRequest = fmt.Sprintf(` } }`) +var systemUpdateWithRollbackRequest = fmt.Sprintf(` +{ + "system-update": { + "system_update_id": "31746df7-92f9-4b5e-ad05-59f6684a54eb", + "rollback": true + } +}`) + var applyConfigurationsAndSystemUpdateRequest = fmt.Sprintf(` { "apply-configurations": null, @@ -430,6 +438,13 @@ var applyConfigurationsAndSystemUpdateRequest = fmt.Sprintf(` } }`) +var changePlanRequest = fmt.Sprintf(` +{ + "change-plan": { + "plan_id": "00713021-9aea-41da-9a88-87760c08fa72" + } +}`) + var cancelConfigurationsRequest = fmt.Sprintf(` { "cancel-configurations": null diff --git a/v3/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go b/v3/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go index 512d9a69..767aebf9 100644 --- a/v3/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go +++ b/v3/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go @@ -268,6 +268,68 @@ func TestSystemUpdateLoadBalancer(t *testing.T) { th.AssertNoErr(t, err) } +func TestSystemUpdateWithRollbackLoadBalancer(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc( + fmt.Sprintf("/v1.0/load_balancers/%s/action", id), + 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, systemUpdateWithRollbackRequest) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusNoContent) + }) + + cli := ServiceClient() + rollback := true + systemUpdate := load_balancers.ActionOptsSystemUpdate{ + SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb", + Rollback: &rollback, + } + actionOpts := load_balancers.ActionOpts{ + SystemUpdate: &systemUpdate, + } + + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + + th.AssertNoErr(t, err) +} + +func TestChangePlanLoadBalancer(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc( + fmt.Sprintf("/v1.0/load_balancers/%s/action", id), + 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, changePlanRequest) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusNoContent) + }) + + cli := ServiceClient() + changePlan := load_balancers.ActionOptsChangePlan{ + PlanID: "00713021-9aea-41da-9a88-87760c08fa72", + } + actionOpts := load_balancers.ActionOpts{ + ChangePlan: &changePlan, + } + + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + + th.AssertNoErr(t, err) +} + func TestApplyConfigurationsAndSystemUpdateLoadBalancer(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() diff --git a/v3/ecl/managed_load_balancer/v1/system_updates/requests.go b/v3/ecl/managed_load_balancer/v1/system_updates/requests.go index 48bd683b..fb6ff2f7 100644 --- a/v3/ecl/managed_load_balancer/v1/system_updates/requests.go +++ b/v3/ecl/managed_load_balancer/v1/system_updates/requests.go @@ -36,6 +36,9 @@ type ListOpts struct { // - Whether the system update can be applied to the load balancer Applicable bool `q:"applicable"` + // - Whether the system update allows rollback + IsRollbackAllowed bool `q:"is_rollback_allowed"` + // - If `true` is set, only the latest resource is displayed Latest bool `q:"latest"` } diff --git a/v3/ecl/managed_load_balancer/v1/system_updates/results.go b/v3/ecl/managed_load_balancer/v1/system_updates/results.go index e2c8878c..de2fa8a7 100644 --- a/v3/ecl/managed_load_balancer/v1/system_updates/results.go +++ b/v3/ecl/managed_load_balancer/v1/system_updates/results.go @@ -49,6 +49,9 @@ type SystemUpdate struct { // - Whether the system update can be applied to the load balancer Applicable bool `json:"applicable"` + + // - Whether the system update allows rollback + IsRollbackAllowed bool `json:"is_rollback_allowed"` } // ExtractInto interprets any commonResult as a system update, if possible. diff --git a/v3/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go b/v3/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go index c9959459..2235c92d 100644 --- a/v3/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go +++ b/v3/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go @@ -20,7 +20,8 @@ var listResponse = fmt.Sprintf(` "limit_datetime": "2022-10-11 12:59:59", "current_revision": 1, "next_revision": 2, - "applicable": true + "applicable": true, + "is_rollback_allowed": true } ] }`) @@ -37,6 +38,7 @@ func listResult() []system_updates.SystemUpdate { systemUpdate1.CurrentRevision = 1 systemUpdate1.NextRevision = 2 systemUpdate1.Applicable = true + systemUpdate1.IsRollbackAllowed = true return []system_updates.SystemUpdate{systemUpdate1} } @@ -52,7 +54,8 @@ var showResponse = fmt.Sprintf(` "limit_datetime": "2022-10-11 12:59:59", "current_revision": 1, "next_revision": 2, - "applicable": true + "applicable": true, + "is_rollback_allowed": true } }`) @@ -68,6 +71,7 @@ func showResult() *system_updates.SystemUpdate { systemUpdate.CurrentRevision = 1 systemUpdate.NextRevision = 2 systemUpdate.Applicable = true + systemUpdate.IsRollbackAllowed = true return &systemUpdate } diff --git a/v4/ecl/managed_load_balancer/v1/load_balancers/doc.go b/v4/ecl/managed_load_balancer/v1/load_balancers/doc.go index 2d40e690..0348fd02 100644 --- a/v4/ecl/managed_load_balancer/v1/load_balancers/doc.go +++ b/v4/ecl/managed_load_balancer/v1/load_balancers/doc.go @@ -140,6 +140,38 @@ Example to perform system-update action on a load balancer panic(err) } +Example to perform system-update action with rollback on a load balancer + + rollback := true + systemUpdate := load_balancers.ActionOptsSystemUpdate{ + SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb", + Rollback: &rollback, + } + actionOpts := load_balancers.ActionOpts{ + SystemUpdate: &systemUpdate, + } + + id := "497f6eca-6276-4993-bfeb-53cbbbba6f08" + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + if err != nil { + panic(err) + } + +Example to perform change-plan action on a load balancer + + changePlan := load_balancers.ActionOptsChangePlan{ + PlanID: "00713021-9aea-41da-9a88-87760c08fa72", + } + actionOpts := load_balancers.ActionOpts{ + ChangePlan: &changePlan, + } + + id := "497f6eca-6276-4993-bfeb-53cbbbba6f08" + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + if err != nil { + panic(err) + } + Example to perform apply-configurations and system-update action on a load balancer systemUpdate := load_balancers.ActionOptsSystemUpdate{ diff --git a/v4/ecl/managed_load_balancer/v1/load_balancers/requests.go b/v4/ecl/managed_load_balancer/v1/load_balancers/requests.go index 961e2a8c..04d7da5f 100644 --- a/v4/ecl/managed_load_balancer/v1/load_balancers/requests.go +++ b/v4/ecl/managed_load_balancer/v1/load_balancers/requests.go @@ -321,6 +321,17 @@ type ActionOptsSystemUpdate struct { // - ID of the system update that will be applied to the load balancer SystemUpdateID string `json:"system_update_id"` + + // - Rollback the load balancer to the version prior to the specified system update + // - The target system update must allow rollback (is_rollback_allowed: true) + Rollback *bool `json:"rollback,omitempty"` +} + +// ActionOptsChangePlan represents change-plan information in the load balancer action. +type ActionOptsChangePlan struct { + + // - ID of the plan that the load balancer will be changed to + PlanID string `json:"plan_id"` } // ActionOpts represents options used to perform action on a existing load balancer. @@ -331,6 +342,9 @@ type ActionOpts struct { // - Apply the system update to the load balancer SystemUpdate *ActionOptsSystemUpdate `json:"system-update,omitempty"` + + // - Change the plan of the load balancer + ChangePlan *ActionOptsChangePlan `json:"change-plan,omitempty"` } // ToLoadBalancerActionMap builds a request body from ActionOpts. @@ -342,9 +356,21 @@ func (opts ActionOpts) ToLoadBalancerActionMap() map[string]interface{} { } if opts.SystemUpdate != nil { - optsMap["system-update"] = map[string]interface{}{ + systemUpdateMap := map[string]interface{}{ "system_update_id": opts.SystemUpdate.SystemUpdateID, } + + if opts.SystemUpdate.Rollback != nil { + systemUpdateMap["rollback"] = *opts.SystemUpdate.Rollback + } + + optsMap["system-update"] = systemUpdateMap + } + + if opts.ChangePlan != nil { + optsMap["change-plan"] = map[string]interface{}{ + "plan_id": opts.ChangePlan.PlanID, + } } return optsMap diff --git a/v4/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go b/v4/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go index 1c579682..2a02c590 100644 --- a/v4/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go +++ b/v4/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go @@ -422,6 +422,14 @@ var systemUpdateRequest = fmt.Sprintf(` } }`) +var systemUpdateWithRollbackRequest = fmt.Sprintf(` +{ + "system-update": { + "system_update_id": "31746df7-92f9-4b5e-ad05-59f6684a54eb", + "rollback": true + } +}`) + var applyConfigurationsAndSystemUpdateRequest = fmt.Sprintf(` { "apply-configurations": null, @@ -430,6 +438,13 @@ var applyConfigurationsAndSystemUpdateRequest = fmt.Sprintf(` } }`) +var changePlanRequest = fmt.Sprintf(` +{ + "change-plan": { + "plan_id": "00713021-9aea-41da-9a88-87760c08fa72" + } +}`) + var cancelConfigurationsRequest = fmt.Sprintf(` { "cancel-configurations": null diff --git a/v4/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go b/v4/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go index 8382d4ec..84529052 100644 --- a/v4/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go +++ b/v4/ecl/managed_load_balancer/v1/load_balancers/testing/requests_test.go @@ -268,6 +268,68 @@ func TestSystemUpdateLoadBalancer(t *testing.T) { th.AssertNoErr(t, err) } +func TestSystemUpdateWithRollbackLoadBalancer(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc( + fmt.Sprintf("/v1.0/load_balancers/%s/action", id), + 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, systemUpdateWithRollbackRequest) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusNoContent) + }) + + cli := ServiceClient() + rollback := true + systemUpdate := load_balancers.ActionOptsSystemUpdate{ + SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb", + Rollback: &rollback, + } + actionOpts := load_balancers.ActionOpts{ + SystemUpdate: &systemUpdate, + } + + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + + th.AssertNoErr(t, err) +} + +func TestChangePlanLoadBalancer(t *testing.T) { + th.SetupHTTP() + defer th.TeardownHTTP() + + th.Mux.HandleFunc( + fmt.Sprintf("/v1.0/load_balancers/%s/action", id), + 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, changePlanRequest) + + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(http.StatusNoContent) + }) + + cli := ServiceClient() + changePlan := load_balancers.ActionOptsChangePlan{ + PlanID: "00713021-9aea-41da-9a88-87760c08fa72", + } + actionOpts := load_balancers.ActionOpts{ + ChangePlan: &changePlan, + } + + err := load_balancers.Action(cli, id, actionOpts).ExtractErr() + + th.AssertNoErr(t, err) +} + func TestApplyConfigurationsAndSystemUpdateLoadBalancer(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() diff --git a/v4/ecl/managed_load_balancer/v1/system_updates/requests.go b/v4/ecl/managed_load_balancer/v1/system_updates/requests.go index 2d0e2974..a853dd78 100644 --- a/v4/ecl/managed_load_balancer/v1/system_updates/requests.go +++ b/v4/ecl/managed_load_balancer/v1/system_updates/requests.go @@ -36,6 +36,9 @@ type ListOpts struct { // - Whether the system update can be applied to the load balancer Applicable bool `q:"applicable"` + // - Whether the system update allows rollback + IsRollbackAllowed bool `q:"is_rollback_allowed"` + // - If `true` is set, only the latest resource is displayed Latest bool `q:"latest"` } diff --git a/v4/ecl/managed_load_balancer/v1/system_updates/results.go b/v4/ecl/managed_load_balancer/v1/system_updates/results.go index f6751d14..36a5d39e 100644 --- a/v4/ecl/managed_load_balancer/v1/system_updates/results.go +++ b/v4/ecl/managed_load_balancer/v1/system_updates/results.go @@ -49,6 +49,9 @@ type SystemUpdate struct { // - Whether the system update can be applied to the load balancer Applicable bool `json:"applicable"` + + // - Whether the system update allows rollback + IsRollbackAllowed bool `json:"is_rollback_allowed"` } // ExtractInto interprets any commonResult as a system update, if possible. diff --git a/v4/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go b/v4/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go index efc5b5fc..6c94824f 100644 --- a/v4/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go +++ b/v4/ecl/managed_load_balancer/v1/system_updates/testing/fixtures.go @@ -20,7 +20,8 @@ var listResponse = fmt.Sprintf(` "limit_datetime": "2022-10-11 12:59:59", "current_revision": 1, "next_revision": 2, - "applicable": true + "applicable": true, + "is_rollback_allowed": true } ] }`) @@ -37,6 +38,7 @@ func listResult() []system_updates.SystemUpdate { systemUpdate1.CurrentRevision = 1 systemUpdate1.NextRevision = 2 systemUpdate1.Applicable = true + systemUpdate1.IsRollbackAllowed = true return []system_updates.SystemUpdate{systemUpdate1} } @@ -52,7 +54,8 @@ var showResponse = fmt.Sprintf(` "limit_datetime": "2022-10-11 12:59:59", "current_revision": 1, "next_revision": 2, - "applicable": true + "applicable": true, + "is_rollback_allowed": true } }`) @@ -68,6 +71,7 @@ func showResult() *system_updates.SystemUpdate { systemUpdate.CurrentRevision = 1 systemUpdate.NextRevision = 2 systemUpdate.Applicable = true + systemUpdate.IsRollbackAllowed = true return &systemUpdate }