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:
1 parent
9ce5a14ef0
commit
ef3bdfd5eb
39 files changed
+2139
-41
No files matched your search
@@ -26,6 +26,7 @@ type options struct {
|
||||
withAutomaticVersioning bool
|
||||
withSkipCurlOutput bool
|
||||
withFilter string
|
||||
withRefreshToken string
|
||||
withRecursive bool
|
||||
}
|
||||
|
||||
@@ -50,6 +51,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)
|
||||
}
|
||||
@@ -74,6 +78,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
|
||||
}
|
||||
}
|
||||
|
||||
// WithFilter tells the API to filter the items returned using the provided
|
||||
// filter term. The filter should be in a format supported by
|
||||
// hashicorp/go-bexpr.
|
||||
|
||||
Reference in new issue
Block a user