Files
threshold/api/groups/option.gen.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

156 lines
4.2 KiB
Go
Raw Normal View History

// Code generated by "make api"; DO NOT EDIT.
// Copyright IBM Corp. 2020, 2026
2020-08-07 12:55:02 -04:00
// SPDX-License-Identifier: MPL-2.0
2023-02-02 17:15:17 -08:00
2020-08-07 12:55:02 -04:00
package groups
import (
2021-01-25 19:37:40 -05:00
"strconv"
"strings"
2021-01-25 19:37:40 -05:00
2020-08-10 17:15:02 -04:00
"github.com/hashicorp/boundary/api"
2020-08-07 12:55:02 -04:00
)
// Option is a func that sets optional attributes for a call. This does not need
// to be used directly, but instead option arguments are built from the
// functions in this package. WithX options set a value to that given in the
// argument; DefaultX options indicate that the value should be set to its
2024-02-16 08:30:16 -05:00
// default. When an API call is made options are processed in the order they
2020-08-07 12:55:02 -04:00
// appear in the function call, so for a given argument X, a succession of WithX
// or DefaultX calls will result in the last call taking effect.
type Option func(*options)
type options struct {
2024-09-12 15:56:33 -04:00
postMap map[string]any
queryMap map[string]string
withAutomaticVersioning bool
withSkipCurlOutput bool
withFilter string
withListToken string
withClientDirectedPagination bool
withPageSize uint32
2024-09-13 15:59:49 -04:00
withResourcePathOverride string
2024-09-12 15:56:33 -04:00
withRecursive bool
2020-08-07 12:55:02 -04:00
}
func getDefaultOptions() options {
return options{
2024-09-04 11:40:43 -04:00
postMap: make(map[string]any),
queryMap: make(map[string]string),
2020-08-07 12:55:02 -04:00
}
}
func getOpts(opt ...Option) (options, []api.Option) {
opts := getDefaultOptions()
for _, o := range opt {
2021-04-08 20:54:32 -04:00
if o != nil {
o(&opts)
}
2020-08-07 12:55:02 -04:00
}
var apiOpts []api.Option
if opts.withSkipCurlOutput {
apiOpts = append(apiOpts, api.WithSkipCurlOutput(true))
}
if opts.withFilter != "" {
opts.queryMap["filter"] = opts.withFilter
}
2023-11-24 19:24:31 -08:00
if opts.withListToken != "" {
opts.queryMap["list_token"] = opts.withListToken
2023-10-23 16:49:32 -07:00
}
2021-01-25 19:37:40 -05:00
if opts.withRecursive {
opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive)
}
2024-09-12 15:56:33 -04:00
if opts.withPageSize != 0 {
opts.queryMap["page_size"] = strconv.FormatUint(uint64(opts.withPageSize), 10)
}
2020-08-07 12:55:02 -04:00
return opts, apiOpts
}
// If set, and if the version is zero during an update, the API will perform a
// fetch to get the current version of the resource and populate it during the
// update call. This is convenient but opens up the possibility for subtle
// order-of-modification issues, so use carefully.
func WithAutomaticVersioning(enable bool) Option {
2020-08-07 12:55:02 -04:00
return func(o *options) {
o.withAutomaticVersioning = enable
2020-08-07 12:55:02 -04:00
}
}
// WithSkipCurlOutput tells the API to not use the current call for cURL output.
// Useful for when we need to look up versions.
func WithSkipCurlOutput(skip bool) Option {
return func(o *options) {
2024-09-04 11:40:43 -04:00
o.withSkipCurlOutput = skip
}
}
2023-11-24 19:24:31 -08:00
// WithListToken tells the API to use the provided list token
2023-10-23 16:49:32 -07:00
// for listing operations on this resource.
2023-11-24 19:24:31 -08:00
func WithListToken(listToken string) Option {
2023-10-23 16:49:32 -07:00
return func(o *options) {
2023-11-24 19:24:31 -08:00
o.withListToken = listToken
2023-10-23 16:49:32 -07:00
}
}
// 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.
func WithFilter(filter string) Option {
return func(o *options) {
o.withFilter = strings.TrimSpace(filter)
}
}
2024-09-12 15:56:33 -04:00
// 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
}
}
2024-09-13 15:59:49 -04:00
// WithResourcePathOverride tells the API to use the provided resource path
func WithResourcePathOverride(path string) Option {
return func(o *options) {
o.withResourcePathOverride = path
}
}
2021-01-25 19:37:40 -05:00
// WithRecursive tells the API to use recursion for listing operations on this
// resource
func WithRecursive(recurse bool) Option {
return func(o *options) {
2024-09-04 11:40:43 -04:00
o.withRecursive = recurse
2021-01-25 19:37:40 -05:00
}
}
2020-08-07 12:55:02 -04:00
func WithDescription(inDescription string) Option {
return func(o *options) {
o.postMap["description"] = inDescription
2020-08-07 12:55:02 -04:00
}
}
func DefaultDescription() Option {
return func(o *options) {
o.postMap["description"] = nil
2020-08-07 12:55:02 -04:00
}
}
func WithName(inName string) Option {
return func(o *options) {
o.postMap["name"] = inName
2020-08-07 12:55:02 -04:00
}
}
func DefaultName() Option {
return func(o *options) {
o.postMap["name"] = nil
2020-08-07 12:55:02 -04:00
}
}