Paginate targets in cache (#5101)
* Update Go API to support pagination * Implement pagination of targets in cache (cherry picked from commit cd25fad42f325fc050b7ea3bec3336780d2b5e16)
This commit is contained in:
1 parent
2a87dcad48
commit
3a4ee032d9
62 files changed
+3875
-1533
No files matched your search
@@ -6,6 +6,7 @@ package billing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
@@ -21,12 +22,14 @@ import (
|
||||
type Option func(*options)
|
||||
|
||||
type options struct {
|
||||
postMap map[string]any
|
||||
queryMap map[string]string
|
||||
withAutomaticVersioning bool
|
||||
withSkipCurlOutput bool
|
||||
withFilter string
|
||||
withListToken string
|
||||
postMap map[string]any
|
||||
queryMap map[string]string
|
||||
withAutomaticVersioning bool
|
||||
withSkipCurlOutput bool
|
||||
withFilter string
|
||||
withListToken string
|
||||
withClientDirectedPagination bool
|
||||
withPageSize uint32
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
@@ -53,6 +56,9 @@ func getOpts(opt ...Option) (options, []api.Option) {
|
||||
if opts.withListToken != "" {
|
||||
opts.queryMap["list_token"] = opts.withListToken
|
||||
}
|
||||
if opts.withPageSize != 0 {
|
||||
opts.queryMap["page_size"] = strconv.FormatUint(uint64(opts.withPageSize), 10)
|
||||
}
|
||||
return opts, apiOpts
|
||||
}
|
||||
|
||||
@@ -91,6 +97,21 @@ func WithFilter(filter string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithClientDirectedPagination tells the List function to return only the first
|
||||
// page, if more pages are available
|
||||
func WithClientDirectedPagination(with bool) Option {
|
||||
return func(o *options) {
|
||||
o.withClientDirectedPagination = with
|
||||
}
|
||||
}
|
||||
|
||||
// WithPageSize controls the size of pages used during List
|
||||
func WithPageSize(with uint32) Option {
|
||||
return func(o *options) {
|
||||
o.withPageSize = with
|
||||
}
|
||||
}
|
||||
|
||||
func WithEndTime(inEndTime string) Option {
|
||||
return func(o *options) {
|
||||
o.queryMap["end_time"] = fmt.Sprintf("%v", inEndTime)
|
||||
|
||||
Reference in new issue
Block a user