github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/instances/Upgrade.go (about)

     1  package instances
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type UpgradeOpts struct {
    10  	// Operation name.
    11  	// upgrade: Upgrade the	software version of the dedicated WAF engine
    12  	Action string `json:"action"`
    13  }
    14  
    15  // Upgrade will upgrade instance software.
    16  func Upgrade(client *golangsdk.ServiceClient, id string) (*Instance, error) {
    17  	b, err := build.RequestBody(UpgradeOpts{
    18  		Action: "upgrade",
    19  	}, "")
    20  	if err != nil {
    21  		return nil, err
    22  	}
    23  
    24  	// POST /v1/{project_id}/premium-waf/instance
    25  	raw, err := client.Post(client.ServiceURL("premium-waf", "instance", id, "action"), b,
    26  		nil, &golangsdk.RequestOpts{
    27  			OkCodes: []int{200},
    28  		})
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  
    33  	var res Instance
    34  	return &res, extract.Into(raw.Body, &res)
    35  }