This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
requests.go
53 lines (47 loc) · 1.55 KB
/
requests.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
45
46
47
48
49
50
51
52
53
package dependencies
import (
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/pagination"
)
// ListOpts allows to filter list data using given parameters.
type ListOpts struct {
// Dependency type, which support public, private, and all, default to all.
// public
// private
// all
DependencyType string `q:"dependency_type"`
// Runtime of function.
Runtime string `q:"runtime"`
// Name of the dependency.
Name string `q:"name"`
// Final record queried last time. Default value: 0.
Marker string `q:"marker"`
// Maximum number of dependencies that can be obtained in a query, default to 400.
Limit string `q:"limit"`
}
// ListOptsBuilder is an interface which to support request query build of
// the dependent package search.
type ListOptsBuilder interface {
ToListQuery() (string, error)
}
// ToListQuery is a method which to build a request query by the ListOpts.
func (opts ListOpts) ToListQuery() (string, error) {
q, err := golangsdk.BuildQueryString(opts)
return q.String(), err
}
// List is a method to obtain an array of one or more dependent packages according to the query parameters.
func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager {
url := rootURL(client)
if opts != nil {
query, err := opts.ToListQuery()
if err != nil {
return pagination.Pager{Err: err}
}
url += query
}
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
p := DependencyPage{pagination.MarkerPageBase{PageResult: r}}
p.MarkerPageBase.Owner = p
return p
})
}