github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/koogallery/v1/assets/requests.go (about) 1 package assets 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 ) 6 7 type AssetsOpts struct { 8 AssetId string `q:"asset_id"` 9 DeployedType string `q:"deployed_type"` 10 Region string `q:"region"` 11 AssetVersion string `q:"asset_version"` 12 QueryAll bool `q:"query_all"` 13 } 14 15 type AssetsBuilder interface { 16 ToAssetsListQuery() (string, error) 17 } 18 19 func (opts AssetsOpts) ToAssetsListQuery() (string, error) { 20 q, err := golangsdk.BuildQueryString(opts) 21 if err != nil { 22 return "", err 23 } 24 return q.String(), err 25 } 26 27 func List(client *golangsdk.ServiceClient, opts AssetsBuilder) (r ListAssetsResult) { 28 url := listURL(client) 29 if opts != nil { 30 query, err := opts.ToAssetsListQuery() 31 if err != nil { 32 r.Err = err 33 return 34 } 35 url += query 36 } 37 38 _, r.Err = client.Get(url, &r.Body, &golangsdk.RequestOpts{ 39 OkCodes: []int{200}, 40 }) 41 return 42 }