v0.0.0-...-d88c8b5 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 6 Imported by: 0



Package filter encapsulates the filter argument to compute API calls.

// List all global addresses (no filter).
c.GlobalAddresses().List(ctx, filter.None)

// List global addresses filtering for name matching "abc.*".
c.GlobalAddresses().List(ctx, filter.Regexp("name", "abc.*"))

// List on multiple conditions.
f := filter.Regexp("name", "homer.*").AndNotRegexp("name", "homers")
c.GlobalAddresses().List(ctx, f)



This section is empty.


This section is empty.


This section is empty.


type F

type F struct {
	// contains filtered or unexported fields

F is a filter to be used with List() operations.

From the compute API description:

Sets a filter {expression} for filtering listed resources. Your {expression} must be in the format: field_name comparison_string literal_string.

The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field.

For example, to filter for instances that do not have a name of example-instance, you would use name ne example-instance.

You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values.

To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters.

var (
	// None indicates that the List result set should not be filter (i.e.
	// return all values).
	None *F

func EqualBool

func EqualBool(fieldName string, v bool) *F

EqualBool returns a filter for fieldName eq v.

func EqualInt

func EqualInt(fieldName string, v int) *F

EqualInt returns a filter for fieldName eq v.

func NotEqualBool

func NotEqualBool(fieldName string, v bool) *F

NotEqualBool returns a filter for fieldName ne v.

func NotEqualInt

func NotEqualInt(fieldName string, v int) *F

NotEqualInt returns a filter for fieldName ne v.

func NotRegexp

func NotRegexp(fieldName, v string) *F

NotRegexp returns a filter for fieldName ne regexp v.

func Regexp

func Regexp(fieldName, v string) *F

Regexp returns a filter for fieldName eq regexp v.

func (*F) And

func (fl *F) And(rest *F) *F

And joins two filters together.

func (*F) AndEqualBool

func (fl *F) AndEqualBool(fieldName string, v bool) *F

AndEqualBool adds a field = bool predicate.

func (*F) AndEqualInt

func (fl *F) AndEqualInt(fieldName string, v int) *F

AndEqualInt adds a field = int predicate.

func (*F) AndNotEqualBool

func (fl *F) AndNotEqualBool(fieldName string, v bool) *F

AndNotEqualBool adds a field != bool predicate.

func (*F) AndNotEqualInt

func (fl *F) AndNotEqualInt(fieldName string, v int) *F

AndNotEqualInt adds a field != int predicate.

func (*F) AndNotRegexp

func (fl *F) AndNotRegexp(fieldName, v string) *F

AndNotRegexp adds a field !~ string predicate.

func (*F) AndRegexp

func (fl *F) AndRegexp(fieldName, v string) *F

AndRegexp adds a field ~ string predicate.

func (*F) Match

func (fl *F) Match(obj interface{}) bool

Match returns true if the F as specifies matches the given object. This is used by the Mock implementations to perform filtering and SHOULD NOT be used in production code as it is not well-tested to be equivalent to the actual compute API.

func (*F) String

func (fl *F) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL