diff --git a/command/operator_api.go b/command/operator_api.go index fe6d16d55..dc9bb8200 100644 --- a/command/operator_api.go +++ b/command/operator_api.go @@ -59,6 +59,9 @@ Operator API Specific Options: if the -token flag is explicitly used, the token will also be included in the output. + -filter + Specifies an expression used to filter query results. + -H
Adds an additional HTTP header to the request. May be specified more than once. These headers take precedent over automatically ones such as @@ -95,11 +98,13 @@ func (*OperatorAPICommand) Name() string { return "operator api" } func (c *OperatorAPICommand) Run(args []string) int { var dryrun bool + var filter string headerFlags := newHeaderFlags() flags := c.Meta.FlagSet(c.Name(), FlagSetClient) flags.Usage = func() { c.Ui.Output(c.Help()) } flags.BoolVar(&dryrun, "dryrun", false, "") + flags.StringVar(&filter, "filter", "", "") flags.BoolVar(&c.verboseFlag, "verbose", false, "") flags.StringVar(&c.method, "X", "", "") flags.Var(headerFlags, "H", "") @@ -160,6 +165,13 @@ func (c *OperatorAPICommand) Run(args []string) int { return 2 } + // Set Filter query param + if filter != "" { + q := path.Query() + q.Set("filter", filter) + path.RawQuery = q.Encode() + } + if dryrun { out, err := c.apiToCurl(config, headerFlags.headers, path) if err != nil {