github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/apigw/v2/app_auth/GetUnboundApis.go (about) 1 package app_auth 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 ListUnboundOpts struct { 12 GatewayID string `json:"-"` 13 AppID string `q:"app_id" required:"true"` 14 EnvID string `q:"env_id" required:"true"` 15 GroupID string `q:"group_id"` 16 ApiID string `q:"api_id"` 17 ApiName string `q:"api_name"` 18 } 19 20 func ListAPIUnBound(client *golangsdk.ServiceClient, opts ListUnboundOpts) ([]ApiOutline, error) { 21 q, err := golangsdk.BuildQueryString(&opts) 22 if err != nil { 23 return nil, err 24 } 25 pages, err := pagination.Pager{ 26 Client: client, 27 InitialURL: client.ServiceURL("apigw", "instances", opts.GatewayID, "app-auths", 28 "unbinded-apis") + q.String(), 29 CreatePage: func(r pagination.NewPageResult) pagination.NewPage { 30 return BindingPage{NewSinglePageBase: pagination.NewSinglePageBase{NewPageResult: r}} 31 }, 32 }.NewAllPages() 33 34 if err != nil { 35 return nil, err 36 } 37 return ExtractApiOutline(pages) 38 } 39 40 func ExtractApiOutline(r pagination.NewPage) ([]ApiOutline, error) { 41 var s struct { 42 Bindings []ApiOutline `json:"apis"` 43 } 44 err := extract.Into(bytes.NewReader((r.(BindingPage)).Body), &s) 45 return s.Bindings, err 46 } 47 48 type ApiOutline struct { 49 AuthType string `json:"auth_type"` 50 RunEnvName string `json:"run_env_name"` 51 GroupName string `json:"group_name"` 52 PublishID string `json:"publish_id"` 53 GroupID string `json:"group_id"` 54 Name string `json:"name"` 55 Description string `json:"remark"` 56 RunEnvID string `json:"run_env_id"` 57 ID string `json:"id"` 58 ReqUri string `json:"req_uri"` 59 }