Documentation ¶
Overview ¶
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)
Index ¶
- type F
- func (fl *F) And(rest *F) *F
- func (fl *F) AndEqualBool(fieldName string, v bool) *F
- func (fl *F) AndEqualInt(fieldName string, v int) *F
- func (fl *F) AndNotEqualBool(fieldName string, v bool) *F
- func (fl *F) AndNotEqualInt(fieldName string, v int) *F
- func (fl *F) AndNotRegexp(fieldName, v string) *F
- func (fl *F) AndRegexp(fieldName, v string) *F
- func (fl *F) Match(obj interface{}) bool
- func (fl *F) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 NotEqualBool ¶
NotEqualBool returns a filter for fieldName ne v.
func NotEqualInt ¶
NotEqualInt returns a filter for fieldName ne v.
func (*F) AndEqualBool ¶
AndEqualBool adds a field = bool predicate.
func (*F) AndEqualInt ¶
AndEqualInt adds a field = int predicate.
func (*F) AndNotEqualBool ¶
AndNotEqualBool adds a field != bool predicate.
func (*F) AndNotEqualInt ¶
AndNotEqualInt adds a field != int predicate.
func (*F) AndNotRegexp ¶
AndNotRegexp adds a field !~ string predicate.