diff --git a/api/accounts/option.gen.go b/api/accounts/option.gen.go index 72976a3fe..a877bf58c 100644 --- a/api/accounts/option.gen.go +++ b/api/accounts/option.gen.go @@ -1,6 +1,8 @@ package accounts import ( + "strings" + "github.com/hashicorp/boundary/api" ) @@ -18,6 +20,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string } func getDefaultOptions() options { @@ -36,6 +39,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } return opts, apiOpts } @@ -57,6 +63,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + func WithAttributes(inAttributes map[string]interface{}) Option { return func(o *options) { o.postMap["attributes"] = inAttributes diff --git a/api/authmethods/option.gen.go b/api/authmethods/option.gen.go index 1705c81bc..4a910c0e5 100644 --- a/api/authmethods/option.gen.go +++ b/api/authmethods/option.gen.go @@ -2,6 +2,7 @@ package authmethods import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/authtokens/option.gen.go b/api/authtokens/option.gen.go index 18136b697..4b8a1f10b 100644 --- a/api/authtokens/option.gen.go +++ b/api/authtokens/option.gen.go @@ -2,6 +2,7 @@ package authtokens import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/groups/option.gen.go b/api/groups/option.gen.go index e3d5c5c0d..108cf72f4 100644 --- a/api/groups/option.gen.go +++ b/api/groups/option.gen.go @@ -2,6 +2,7 @@ package groups import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/hostcatalogs/option.gen.go b/api/hostcatalogs/option.gen.go index 7f9746375..62e0c15bc 100644 --- a/api/hostcatalogs/option.gen.go +++ b/api/hostcatalogs/option.gen.go @@ -2,6 +2,7 @@ package hostcatalogs import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/hosts/option.gen.go b/api/hosts/option.gen.go index 24bc93ddf..bf886feb9 100644 --- a/api/hosts/option.gen.go +++ b/api/hosts/option.gen.go @@ -1,6 +1,8 @@ package hosts import ( + "strings" + "github.com/hashicorp/boundary/api" ) @@ -18,6 +20,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string } func getDefaultOptions() options { @@ -36,6 +39,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } return opts, apiOpts } @@ -57,6 +63,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + func WithStaticHostAddress(inAddress string) Option { return func(o *options) { raw, ok := o.postMap["attributes"] diff --git a/api/hostsets/option.gen.go b/api/hostsets/option.gen.go index 73280f76b..2f72bffb5 100644 --- a/api/hostsets/option.gen.go +++ b/api/hostsets/option.gen.go @@ -1,6 +1,8 @@ package hostsets import ( + "strings" + "github.com/hashicorp/boundary/api" ) @@ -18,6 +20,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string } func getDefaultOptions() options { @@ -36,6 +39,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } return opts, apiOpts } @@ -57,6 +63,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + func WithDescription(inDescription string) Option { return func(o *options) { o.postMap["description"] = inDescription diff --git a/api/roles/option.gen.go b/api/roles/option.gen.go index 3de987b37..006d4d2f1 100644 --- a/api/roles/option.gen.go +++ b/api/roles/option.gen.go @@ -2,6 +2,7 @@ package roles import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/scopes/option.gen.go b/api/scopes/option.gen.go index aa4a13a59..f53f93978 100644 --- a/api/scopes/option.gen.go +++ b/api/scopes/option.gen.go @@ -3,6 +3,7 @@ package scopes import ( "fmt" "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -21,6 +22,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -40,6 +42,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -64,6 +69,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/sessions/option.gen.go b/api/sessions/option.gen.go index ede2dd710..f4437c78c 100644 --- a/api/sessions/option.gen.go +++ b/api/sessions/option.gen.go @@ -2,6 +2,7 @@ package sessions import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/targets/option.gen.go b/api/targets/option.gen.go index 15efdce98..cf375363d 100644 --- a/api/targets/option.gen.go +++ b/api/targets/option.gen.go @@ -2,6 +2,7 @@ package targets import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/api/users/option.gen.go b/api/users/option.gen.go index 3860ada19..e442074af 100644 --- a/api/users/option.gen.go +++ b/api/users/option.gen.go @@ -2,6 +2,7 @@ package users import ( "strconv" + "strings" "github.com/hashicorp/boundary/api" ) @@ -20,6 +21,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string withRecursive bool } @@ -39,6 +41,9 @@ func getOpts(opt ...Option) (options, []api.Option) { if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + } if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } @@ -63,6 +68,15 @@ func WithSkipCurlOutput(skip bool) Option { } } +// 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) + } +} + // WithRecursive tells the API to use recursion for listing operations on this // resource func WithRecursive(recurse bool) Option { diff --git a/internal/api/genapi/templates.go b/internal/api/genapi/templates.go index d8431f7f3..434ccad62 100644 --- a/internal/api/genapi/templates.go +++ b/internal/api/genapi/templates.go @@ -657,6 +657,7 @@ type options struct { queryMap map[string]string withAutomaticVersioning bool withSkipCurlOutput bool + withFilter string {{ if .RecursiveListing }} withRecursive bool {{ end }} } @@ -675,7 +676,10 @@ func getOpts(opt ...Option) (options, []api.Option) { var apiOpts []api.Option if opts.withSkipCurlOutput { apiOpts = append(apiOpts, api.WithSkipCurlOutput(true)) - } {{ if .RecursiveListing }} + } + if opts.withFilter != "" { + opts.queryMap["filter"] = opts.withFilter + }{{ if .RecursiveListing }} if opts.withRecursive { opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive) } {{ end }} @@ -699,6 +703,15 @@ func WithSkipCurlOutput(skip bool) Option { o.withSkipCurlOutput = true } } + +// 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) + } +} {{ if .RecursiveListing }} // WithRecursive tells the API to use recursion for listing operations on this // resource