github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/apigw/v2/api/SwitchApiVersion.go (about)

     1  package api
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type VersionApiOpts struct {
    10  	GatewayID string `json:"-"`
    11  	ApiID     string `json:"-"`
    12  	VersionID string `json:"version_id" required:"true"`
    13  }
    14  
    15  func SwitchVersion(client *golangsdk.ServiceClient, opts VersionApiOpts) (*ManageApiResp, error) {
    16  	b, err := build.RequestBody(opts, "")
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  
    21  	raw, err := client.Put(client.ServiceURL("apigw", "instances", opts.GatewayID, "apis", "publish", opts.ApiID), b, nil, &golangsdk.RequestOpts{
    22  		OkCodes: []int{200},
    23  	})
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	var res ManageApiResp
    29  
    30  	err = extract.Into(raw.Body, &res)
    31  	return &res, err
    32  }