api: add automatic list pagination

Updates all List endpoints to automatically paginate
through results to preserve backwards compatibility.
Adding support for user controllable pagination could
be considered at a later time.
This commit is contained in:
Johan Brandhorst-Satzkorn committed 2024-01-05 07:43:20 -08:00
1 parent 9ce5a14ef0
commit ef3bdfd5eb
39 files changed
+2139 -41

No files matched your search

+12
View File
@@ -25,6 +25,7 @@ type options struct {
withAutomaticVersioning bool
withSkipCurlOutput bool
withFilter string
withRefreshToken string
withRecursive bool
}
@@ -49,6 +50,9 @@ func getOpts(opt ...Option) (options, []api.Option) {
if opts.withFilter != "" {
opts.queryMap["filter"] = opts.withFilter
}
if opts.withRefreshToken != "" {
opts.queryMap["refresh_token"] = opts.withRefreshToken
}
if opts.withRecursive {
opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive)
}
@@ -63,6 +67,14 @@ func WithSkipCurlOutput(skip bool) Option {
}
}
// WithRefreshToken tells the API to use the provided refresh token
// for listing operations on this resource.
func WithRefreshToken(refreshToken string) Option {
return func(o *options) {
o.withRefreshToken = refreshToken
}
}
// WithRecursive tells the API to use recursion for listing operations on this
// resource
func WithRecursive(recurse bool) Option {