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

     1  package special_policy
     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 UpdateOpts struct {
    10  	GatewayID       string `json:"-"`
    11  	ThrottleID      string `json:"-"`
    12  	SpecialPolicyID string `json:"strategy_id" required:"true"`
    13  	CallLimits      int    `json:"call_limits" required:"true"`
    14  }
    15  
    16  func Update(client *golangsdk.ServiceClient, opts UpdateOpts) (*ThrottlingResp, error) {
    17  	b, err := build.RequestBody(opts, "")
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  
    22  	raw, err := client.Put(client.ServiceURL("apigw", "instances", opts.GatewayID, "throttles", opts.ThrottleID,
    23  		"throttle-specials", opts.SpecialPolicyID),
    24  		b, nil, &golangsdk.RequestOpts{
    25  			OkCodes: []int{200},
    26  		})
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  
    31  	var res ThrottlingResp
    32  
    33  	err = extract.Into(raw.Body, &res)
    34  	return &res, err
    35  }