-
Notifications
You must be signed in to change notification settings - Fork 7
/
ManageApi.go
44 lines (37 loc) · 1.2 KB
/
ManageApi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package api
import (
golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
)
type ManageOpts struct {
GatewayID string `json:"-"`
Action string `json:"action" required:"true"`
EnvID string `json:"env_id" required:"true"`
ApiID string `json:"api_id" required:"true"`
Description string `json:"remark,omitempty"`
}
func ManageApi(client *golangsdk.ServiceClient, opts ManageOpts) (*ManageApiResp, error) {
b, err := build.RequestBody(opts, "")
if err != nil {
return nil, err
}
raw, err := client.Post(client.ServiceURL("apigw", "instances", opts.GatewayID, "apis", "action"), b, nil, &golangsdk.RequestOpts{
OkCodes: []int{201},
})
if err != nil {
return nil, err
}
var res ManageApiResp
err = extract.Into(raw.Body, &res)
return &res, err
}
type ManageApiResp struct {
PublishID string `json:"publish_id"`
ApiID string `json:"api_id"`
ApiName string `json:"api_name"`
EnvID string `json:"env_id"`
Description string `json:"remark"`
VersionID string `json:"version_id"`
PublishTime string `json:"publish_time"`
}