github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/apigw/v2/app/Create.go (about) 1 package app 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 CreateOpts struct { 10 GatewayID string `json:"-"` 11 Name string `json:"name" required:"true"` 12 Description string `json:"remark,omitempty"` 13 AppKey string `json:"app_key,omitempty"` 14 AppSecret string `json:"app_secret,omitempty"` 15 } 16 17 func Create(client *golangsdk.ServiceClient, opts CreateOpts) (*AppResp, 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, "apps"), b, nil, &golangsdk.RequestOpts{ 24 OkCodes: []int{201}, 25 }) 26 if err != nil { 27 return nil, err 28 } 29 30 var res AppResp 31 32 err = extract.Into(raw.Body, &res) 33 return &res, err 34 } 35 36 type AppResp struct { 37 ID string `json:"id"` 38 Name string `json:"name"` 39 Description string `json:"remark"` 40 Creator string `json:"creator"` 41 UpdateTime string `json:"update_time"` 42 AppKey string `json:"app_key"` 43 AppSecret string `json:"app_secret"` 44 RegisterTime string `json:"register_time"` 45 Status int `json:"status"` 46 AppType string `json:"app_type"` 47 BindNum int `json:"bind_num"` 48 }