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
}
func getDefaultOptions() options {
@@ -48,6 +49,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
}
return opts, apiOpts
}
@@ -69,6 +73,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.