github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/apigw/v2/api/ManageApi.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 ManageOpts struct { 10 GatewayID string `json:"-"` 11 Action string `json:"action" required:"true"` 12 EnvID string `json:"env_id" required:"true"` 13 ApiID string `json:"api_id" required:"true"` 14 Description string `json:"remark,omitempty"` 15 } 16 17 func ManageApi(client *golangsdk.ServiceClient, opts ManageOpts) (*ManageApiResp, error) { 18 b, err := build.RequestBody(opts, "") 19 if err != nil { 20 return nil, err 21 } 22 23 raw, err := client.Post(client.ServiceURL("apigw", "instances", opts.GatewayID, "apis", "action"), b, nil, &golangsdk.RequestOpts{ 24 OkCodes: []int{201}, 25 }) 26 if err != nil { 27 return nil, err 28 } 29 30 var res ManageApiResp 31 32 err = extract.Into(raw.Body, &res) 33 return &res, err 34 } 35 36 type ManageApiResp struct { 37 PublishID string `json:"publish_id"` 38 ApiID string `json:"api_id"` 39 ApiName string `json:"api_name"` 40 EnvID string `json:"env_id"` 41 Description string `json:"remark"` 42 VersionID string `json:"version_id"` 43 PublishTime string `json:"publish_time"` 44 }