github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/apigw/v2/key/ListAPIUnboundKeys.go (about) 1 package key 2 3 import ( 4 "bytes" 5 6 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 7 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 8 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 9 ) 10 11 type ListUnbindOpts struct { 12 GatewayID string `json:"-"` 13 ApiID string `q:"api_id"` 14 SignID string `q:"sign_id"` 15 SignName string `q:"sign_name"` 16 EnvID string `q:"env_id"` 17 } 18 19 func ListUnboundKeys(client *golangsdk.ServiceClient, opts ListUnbindOpts) ([]ApiForSign, error) { 20 q, err := golangsdk.BuildQueryString(&opts) 21 if err != nil { 22 return nil, err 23 } 24 pages, err := pagination.Pager{ 25 Client: client, 26 InitialURL: client.ServiceURL("apigw", "instances", opts.GatewayID, "sign-bindings", 27 "unbinded-apis") + q.String(), 28 CreatePage: func(r pagination.NewPageResult) pagination.NewPage { 29 return BindingPage{NewSinglePageBase: pagination.NewSinglePageBase{NewPageResult: r}} 30 }, 31 }.NewAllPages() 32 33 if err != nil { 34 return nil, err 35 } 36 return ExtractApis(pages) 37 } 38 39 func ExtractApis(r pagination.NewPage) ([]ApiForSign, error) { 40 var s struct { 41 Apis []ApiForSign `json:"apis"` 42 } 43 err := extract.Into(bytes.NewReader((r.(BindingPage)).Body), &s) 44 return s.Apis, err 45 } 46 47 type ApiForSign struct { 48 AuthType string `json:"auth_type"` 49 RunEnvName string `json:"run_env_name"` 50 GroupName string `json:"group_name"` 51 PublishID string `json:"publish_id"` 52 GroupID string `json:"group_id"` 53 Name string `json:"name"` 54 Description string `json:"Remark"` 55 RunEnvID string `json:"run_env_id"` 56 ID string `json:"id"` 57 ReqURI string `json:"req_uri"` 58 Type int `json:"type"` 59 SignatureName string `json:"signature_name"` 60 }