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

Fix Action in ecl/managed_load_balancer/v1/load_balancers/requests #49

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 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.12.x, 1.13.x]
go-version: [1.17.x, 1.18.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}

Expand Down
2 changes: 0 additions & 2 deletions v2/ecl/managed_load_balancer/v1/certificates/doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package certificates contains functionality for working with ECL Managed Load Balancer resources.

Example to list certificates
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/certificates/requests.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package certificates

import (
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/certificates/results.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package certificates

import (
Expand Down
2 changes: 0 additions & 2 deletions v2/ecl/managed_load_balancer/v1/certificates/testing/doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package testing contains certificate unit tests
*/
package testing
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package testing

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package testing

import (
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/certificates/urls.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package certificates

import (
Expand Down
2 changes: 0 additions & 2 deletions v2/ecl/managed_load_balancer/v1/health_monitors/doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package health_monitors contains functionality for working with ECL Managed Load Balancer resources.

Example to list health monitors
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/health_monitors/requests.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package health_monitors

import (
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/health_monitors/results.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package health_monitors

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package testing contains health monitor unit tests
*/
package testing
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package testing

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package testing

import (
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/health_monitors/urls.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package health_monitors

import (
Expand Down
2 changes: 0 additions & 2 deletions v2/ecl/managed_load_balancer/v1/listeners/doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package listeners contains functionality for working with ECL Managed Load Balancer resources.

Example to list listeners
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/listeners/requests.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package listeners

import (
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/listeners/results.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package listeners

import (
Expand Down
2 changes: 0 additions & 2 deletions v2/ecl/managed_load_balancer/v1/listeners/testing/doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package testing contains listener unit tests
*/
package testing
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/listeners/testing/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package testing

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package testing

import (
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/listeners/urls.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package listeners

import (
Expand Down
31 changes: 26 additions & 5 deletions v2/ecl/managed_load_balancer/v1/load_balancers/doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package load_balancers contains functionality for working with ECL Managed Load Balancer resources.

Example to list load balancers
Expand Down Expand Up @@ -117,20 +115,43 @@ Example to delete a load balancer

Example to perform apply-configurations action on a load balancer

actionOpts := load_balancers.ActionOpts{
ApplyConfigurations: true,
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := load_balancers.ApplyConfigurations(managedLoadBalancerClient, id).ExtractErr()
err := load_balancers.Action(cli, id, actionOpts).ExtractErr()
if err != nil {
panic(err)
}

Example to perform system-update action on a load balancer

systemUpdateOpts := load_balancers.SystemUpdateOpts{
systemUpdate := load_balancers.ActionOptsSystemUpdate{
SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb",
}
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 apply-configurations and system-update action on a load balancer

systemUpdate := load_balancers.ActionOptsSystemUpdate{
SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb",
}
actionOpts := load_balancers.ActionOpts{
ApplyConfigurations: true,
SystemUpdate: &systemUpdate,
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := load_balancers.SystemUpdate(managedLoadBalancerClient, id, systemUpdateOpts).ExtractErr()
err := load_balancers.Action(cli, id, actionOpts).ExtractErr()
if err != nil {
panic(err)
}
Expand Down
60 changes: 32 additions & 28 deletions v2/ecl/managed_load_balancer/v1/load_balancers/requests.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package load_balancers

import (
Expand Down Expand Up @@ -302,42 +299,49 @@ func Delete(c *eclcloud.ServiceClient, id string) (r DeleteResult) {
Action Load Balancer
*/

// ApplyConfigurations performs action on a existing load balancer.
func ApplyConfigurations(c *eclcloud.ServiceClient, id string) (r ActionResult) {
b := map[string]interface{}{"apply-configurations": nil}
_, r.Err = c.Post(actionURL(c, id), b, nil, &eclcloud.RequestOpts{
OkCodes: []int{204},
})

return
}

// SystemUpdateOpts represents options used to perform action on a existing load balancer.
type SystemUpdateOpts struct {
// ActionOptsSystemUpdate represents system-update information in the load balancer action.
type ActionOptsSystemUpdate struct {

// - ID of the system update that will be applied to the load balancer
SystemUpdateID string `json:"system_update_id"`
}

// ToLoadBalancerSystemUpdateMap builds a request body from SystemUpdateOpts.
func (opts SystemUpdateOpts) ToLoadBalancerSystemUpdateMap() (map[string]interface{}, error) {
return eclcloud.BuildRequestBody(opts, "system-update")
}
// ActionOpts represents options used to perform action on a existing load balancer.
type ActionOpts struct {

// - Added or changed configurations of the load balancer and related resources will be applied
ApplyConfigurations bool `json:"apply-configurations,omitempty"`

// SystemUpdateOptsBuilder allows extensions to add additional parameters to the SystemUpdate request.
type SystemUpdateOptsBuilder interface {
ToLoadBalancerSystemUpdateMap() (map[string]interface{}, error)
// - Apply the system update to the load balancer
SystemUpdate *ActionOptsSystemUpdate `json:"system-update,omitempty"`
}

// SystemUpdate accepts a SystemUpdateOpts struct and performs action on a existing load balancer using the values provided.
func SystemUpdate(c *eclcloud.ServiceClient, id string, opts SystemUpdateOptsBuilder) (r ActionResult) {
b, err := opts.ToLoadBalancerSystemUpdateMap()
if err != nil {
r.Err = err
// ToLoadBalancerActionMap builds a request body from ActionOpts.
func (opts ActionOpts) ToLoadBalancerActionMap() map[string]interface{} {
optsMap := make(map[string]interface{})

return
if opts.ApplyConfigurations {
optsMap["apply-configurations"] = nil
}

if opts.SystemUpdate != nil {
optsMap["system-update"] = map[string]interface{}{
"system_update_id": opts.SystemUpdate.SystemUpdateID,
}
}

return optsMap
}

// ActionOptsBuilder allows extensions to add additional parameters to the Action request.
type ActionOptsBuilder interface {
ToLoadBalancerActionMap() map[string]interface{}
}

// Action accepts a ActionOpts struct and performs action on a existing load balancer using the values provided.
func Action(c *eclcloud.ServiceClient, id string, opts ActionOptsBuilder) (r ActionResult) {
b := opts.ToLoadBalancerActionMap()

_, r.Err = c.Post(actionURL(c, id), b, nil, &eclcloud.RequestOpts{
OkCodes: []int{204},
})
Expand Down
3 changes: 0 additions & 3 deletions v2/ecl/managed_load_balancer/v1/load_balancers/results.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package load_balancers

import (
Expand Down
2 changes: 0 additions & 2 deletions v2/ecl/managed_load_balancer/v1/load_balancers/testing/doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb

Package testing contains load balancer unit tests
*/
package testing
17 changes: 11 additions & 6 deletions v2/ecl/managed_load_balancer/v1/load_balancers/testing/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
*/
package testing

import (
Expand Down Expand Up @@ -418,18 +415,26 @@ var applyConfigurationsRequest = fmt.Sprintf(`
"apply-configurations": null
}`)

var cancelConfigurationsRequest = fmt.Sprintf(`
var systemUpdateRequest = fmt.Sprintf(`
{
"cancel-configurations": null
"system-update": {
"system_update_id": "31746df7-92f9-4b5e-ad05-59f6684a54eb"
}
}`)

var systemUpdateRequest = fmt.Sprintf(`
var applyConfigurationsAndSystemUpdateRequest = fmt.Sprintf(`
{
"apply-configurations": null,
"system-update": {
"system_update_id": "31746df7-92f9-4b5e-ad05-59f6684a54eb"
}
}`)

var cancelConfigurationsRequest = fmt.Sprintf(`
{
"cancel-configurations": null
}`)

var createStagedRequest = fmt.Sprintf(`
{
"load_balancer": {
Expand Down
Loading
Loading