query

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

Query

This package offers a set of predefined protobuf message types to be used as collection query parameters, which are also called collection operators. These types are:

  • infoblox.api.Filtering
  • infoblox.api.Sorting
  • infoblox.api.Pagination
  • infoblox.api.PageInfo(used in response)
  • infoblox.api.FieldSelection

Enabling collection operators in your application

In order to get collection operators in your app you need the following:

  • Add collection operator types to a request message. You're free to use any subset of them.
import "github.com/infobloxopen/atlas-app-toolkit/query/collection_operators.proto";

message MyListRequest {
    infoblox.api.Filtering filtering = 1;
    infoblox.api.Sorting sorting = 2;
    infoblox.api.Pagination pagination = 3;
    infoblox.api.FieldSelection fields = 4;
}
  • Enable gateway.ClientUnaryInterceptor and gateway.MetadataAnnotator in your gRPC gateway. This will make collection operators to be automatically parsed on gRPC gateway side. If you're using our server wrapper, you need to explicitly set only gateway.ClientUnaryInterceptor since gateway.MetadataAnnotator is enabled by default.
server.WithGateway(
  gateway.WithDialOptions(
    []grpc.DialOption{grpc.WithInsecure(), grpc.WithUnaryInterceptor(
      grpc_middleware.ChainUnaryClient(
        []grpc.UnaryClientInterceptor{gateway.ClientUnaryInterceptor...})},
      ),
  )
)

Filtering

The syntax of REST representation of infoblox.api.Filtering is the following.

REST Query Parameter Description
_filter A string expression containing JSON tags, literal values, and logical operators.

Literal values include numbers (integer and floating-point), quoted (both single- or double-quoted) literal strings, “null” , arrays with numbers (integer and floating-point) and arrays with quoted (both single- or double-quoted) literal strings. The following operators are commonly used in filter expressions.

Operator Description Example
== eq Equal
!= ne Not Equal
> gt Greater Than
>= ge Greater Than or Equal To
< lt Less Than
<= le Less Than or Equal To
and Logical AND price <= 200 and price > 3.5
~ match Matches Regex
!~ nomatch Does Not Match Regex
or Logical OR price <= 3.5 or price > 200
not Logical NOT not price <= 3.5
() Grouping (priority == 1 or city == ‘Santa Clara’) and price > 100
:= ieq Insensitive equal
in Check existence in set city in [‘Santa Clara’, ‘New York’] or price in [1,2,3]

In order to escape string literal delimiter duplicate it, e.g. for single-quoted string literals: _filter=field == 'dup single quote '' ', for double-quoted literals: _filter=field == "dup double quote "" ".

JSONB Filtering

Also our filtering support custom jsonb conditions if you use postgresql as a database. In order to use this feathure you have to use special type Jsonb. If you plan to use special jsonb filtering on a field it's type should be *dialects.Jsonb. Syntax for jsonb filtering is similar to the one you use for StringCondition and StringArrayCondition, as well as you can use operators from StringCondition and StringArrayCondition.

Example:

Consider that you have a following object where info field is a jsonb field:

{
 name: "my object",
 info: {
     Address: {
         "City": "Tacoma",
         "Country": "USA"
     }
 }
}

Filterting request with jsonb query will look like:

...?_filter=info.Address.City=='Tacoma'

if you want to compare enclosed object with json you are able to write:

...?_filter=info.Address=='{"City": "Tacoma", "Country": "USA"}'

Note: if you decide to use toolkit provided infoblox.api.Filtering proto type, then you'll not be able to use vanilla swagger schema generation, since this plugin doesn't work with recursive nature of infoblox.api.Filtering. In this case you can use our fork which has a fix for this issue. You can also use atlas-gentool which contains both versions of the plugin.

Sorting

The syntax of REST representation of infoblox.api.Sorting is the following.

Request Parameter Description Example
_order_by A comma-separated list of JSON tag names. The sort direction can be specified by a suffix separated by whitespace before the tag name. The suffix “asc” sorts the data in ascending order. The suffix “desc” sorts the data in descending order. If no suffix is specified the data is sorted in ascending order. work_address.addresss desc,first_name

Pagination

The syntax of REST representation of infoblox.api.Pagination and infoblox.api.PageInfo is the following.

Paging Mode Request Parameters Response Parameters Description
Client-driven paging _offset The integer index (zero-origin) of the offset into a collection of resources. If omitted or null the value is assumed to be “0”.
_limit The integer number of resources to be returned in the response. The service may impose maximum value. If omitted the service may impose a default value.
_offset The service may optionally* include the offset of the next page of resources. A null value indicates no more pages.
_size The service may optionally include the total number of resources being paged.
Server-driven paging _page_token The service-defined string used to identify a page of resources. A null value indicates the first page.
_page_token The service response should contain a string to indicate the next page of resources. A null value indicates no more pages.
_size The service may optionally include the total number of resources being paged.

Field Selection

The syntax of REST representation of infoblox.api.FieldSelection is the following.

Request Parameter Description Example
_fields A comma-separated list of JSON tag names. work_address.addresss,first_name

As it is not possible to completely remove all the fields(such as primitives) from proto.Message on gRPC server side, fields are additionally truncated on gRPC Gateway side. This is done by gateway.ResponseForwarder.

Field Presence

Using the toolkit's server package functionality, you can optionally enable automatic filling of a google.protobuf.FieldMask within the gRPC Gateway.

As a prerequisite, the request passing through the gateway must match the list of given HTTP methods (e.g. POST, PUT, PATCH) and contain a FieldMask at the top level.

import "google/protobuf/field_mask.proto";
message MyRequest {
  bytes data = 1;
  google.protobuf.FieldMask fields = 2;
}

To enable the functionality, use the following args in the WithGateway method:

server.WithGateway(
  gateway.WithGatewayOptions(
    runtime.WithMetadata(gateway.NewPresenceAnnotator("POST", ...)),
    ...
  ),
  gateway.WithDialOptions(
    []grpc.DialOption{grpc.WithInsecure(), grpc.WithUnaryInterceptor(
      grpc_middleware.ChainUnaryClient(
        []grpc.UnaryClientInterceptor{gateway.ClientUnaryInterceptor, gateway.PresenceClientInterceptor()}...)},
      ),
  )
)

Documentation

Overview

Package query is a generated protocol buffer package.

It is generated from these files:

github.com/infobloxopen/atlas-app-toolkit/query/collection_operators.proto

It has these top-level messages:

SortCriteria
Sorting
FieldSelection
Field
Filtering
LogicalOperator
StringCondition
NumberCondition
NullCondition
StringArrayCondition
NumberArrayCondition
Pagination
PageInfo

Index

Constants

View Source
const (
	// Default pagination limit
	DefaultLimit = 1000
)

Variables

View Source
var LogicalOperator_Type_name = map[int32]string{
	0: "AND",
	1: "OR",
}
View Source
var LogicalOperator_Type_value = map[string]int32{
	"AND": 0,
	"OR":  1,
}
View Source
var NumberArrayCondition_Type_name = map[int32]string{
	0: "IN",
}
View Source
var NumberArrayCondition_Type_value = map[string]int32{
	"IN": 0,
}
View Source
var NumberCondition_Type_name = map[int32]string{
	0: "EQ",
	1: "GT",
	2: "GE",
	3: "LT",
	4: "LE",
}
View Source
var NumberCondition_Type_value = map[string]int32{
	"EQ": 0,
	"GT": 1,
	"GE": 2,
	"LT": 3,
	"LE": 4,
}
View Source
var SortCriteria_Order_name = map[int32]string{
	0: "ASC",
	1: "DESC",
}
View Source
var SortCriteria_Order_value = map[string]int32{
	"ASC":  0,
	"DESC": 1,
}
View Source
var StringArrayCondition_Type_name = map[int32]string{
	0: "IN",
}
View Source
var StringArrayCondition_Type_value = map[string]int32{
	"IN": 0,
}
View Source
var StringCondition_Type_name = map[int32]string{
	0: "EQ",
	1: "MATCH",
	2: "GT",
	3: "GE",
	4: "LT",
	5: "LE",
	6: "IEQ",
}
View Source
var StringCondition_Type_value = map[string]int32{
	"EQ":    0,
	"MATCH": 1,
	"GT":    2,
	"GE":    3,
	"LT":    4,
	"LE":    5,
	"IEQ":   6,
}

Functions

func DecodePageToken added in v0.12.0

func DecodePageToken(ptoken string) (offset, limit int32, err error)

DecodePageToken decodes page token from the user's request. Return error if provided token is malformed or contains ivalid values, otherwise return offset, limit.

func EncodePageToken added in v0.12.0

func EncodePageToken(offset, limit int32) string

EncodePageToken encodes offset and limit to a string in application specific format (offset:limit) in base64 encoding.

func Filter

func Filter(obj interface{}, filter string) (bool, error)

Filter is a shortcut to parse a filter string using default FilteringParser implementation and call Filter on the returned filtering expression.

Types

type AndToken

type AndToken struct {
	TokenBase
}

AndToken represents logical and.

func (AndToken) String

func (t AndToken) String() string

type EOFToken

type EOFToken struct {
	TokenBase
}

EOFToken represents end of an expression.

func (EOFToken) String

func (t EOFToken) String() string

type EqToken

type EqToken struct {
	TokenBase
}

EqToken represents equals operator.

func (EqToken) String

func (t EqToken) String() string

type Field

type Field struct {
	Name string            `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Subs map[string]*Field `` /* 128-byte string literal not displayed */
}

Field represents a single field for an object. It contains fields name and also may contain a group of sub-fields for cases when a fields represents some structure.

func (*Field) Descriptor

func (*Field) Descriptor() ([]byte, []int)

func (*Field) GetName

func (m *Field) GetName() string

func (*Field) GetSubs

func (m *Field) GetSubs() map[string]*Field

func (*Field) ProtoMessage

func (*Field) ProtoMessage()

func (*Field) Reset

func (m *Field) Reset()

func (*Field) String

func (m *Field) String() string

type FieldSelection

type FieldSelection struct {
	Fields map[string]*Field `` /* 132-byte string literal not displayed */
}

FieldSelection represents a group of fields for some object. Main use case for if is to store information about object fields that need to be ratained prior to sending object as a response

func ParseFieldSelection

func ParseFieldSelection(input string, delimiter ...string) *FieldSelection

ParseFieldSelection transforms a string with comma-separated fields that comes from client to FieldSelection struct. For complex fields dot is used as a delimeter by default, but it is also possible to specify a different delimiter.

func (*FieldSelection) Add

func (f *FieldSelection) Add(field string, delimiter ...string)

Add allows to add new fields to FieldSelection

func (*FieldSelection) AllFieldStrings added in v0.18.0

func (f *FieldSelection) AllFieldStrings() []string

AllFieldStrings returns a slice of dot-notated fields

func (*FieldSelection) Delete

func (f *FieldSelection) Delete(field string, delimiter ...string) bool

Delete allows to remove fields from FieldSelection

func (*FieldSelection) Descriptor

func (*FieldSelection) Descriptor() ([]byte, []int)

func (*FieldSelection) Get

func (f *FieldSelection) Get(field string, delimiter ...string) *Field

Get allows to get specified field from FieldSelection

func (*FieldSelection) GetFields

func (m *FieldSelection) GetFields() map[string]*Field

func (*FieldSelection) GoString

func (f *FieldSelection) GoString() string

GoString converts FieldSelection to a string representation It implements fmt.GoStringer interface and returns dot-notated fields separated by commas

func (*FieldSelection) ProtoMessage

func (*FieldSelection) ProtoMessage()

func (*FieldSelection) Reset

func (m *FieldSelection) Reset()

func (*FieldSelection) String

func (m *FieldSelection) String() string

type FieldSelectionMap

type FieldSelectionMap map[string]*Field

FieldSelectionMap is a convenience type that represents map[string]*Field used in FieldSelection and Field structs

type FieldToken

type FieldToken struct {
	TokenBase
	Value string
}

FieldToken represents a reference to a value of a resource. Value is a value of the reference.

func (FieldToken) String

func (t FieldToken) String() string

type Filtering

type Filtering struct {
	// Types that are valid to be assigned to Root:
	//	*Filtering_Operator
	//	*Filtering_StringCondition
	//	*Filtering_NumberCondition
	//	*Filtering_NullCondition
	//	*Filtering_StringArrayCondition
	//	*Filtering_NumberArrayCondition
	Root isFiltering_Root `protobuf_oneof:"root"`
}

Filtering represents filtering expression. root could be either LogicalOperator or one of the supported conditions.

func ParseFiltering

func ParseFiltering(text string) (*Filtering, error)

ParseFiltering is a shortcut to parse a filtering expression using default FilteringParser implementation

func (*Filtering) Descriptor

func (*Filtering) Descriptor() ([]byte, []int)

func (*Filtering) Filter

func (m *Filtering) Filter(obj interface{}) (bool, error)

Filter evaluates underlying filtering expression against obj. If obj implements Matcher, call it's custom implementation.

func (*Filtering) GetNullCondition

func (m *Filtering) GetNullCondition() *NullCondition

func (*Filtering) GetNumberArrayCondition added in v0.15.0

func (m *Filtering) GetNumberArrayCondition() *NumberArrayCondition

func (*Filtering) GetNumberCondition

func (m *Filtering) GetNumberCondition() *NumberCondition

func (*Filtering) GetOperator

func (m *Filtering) GetOperator() *LogicalOperator

func (*Filtering) GetRoot

func (m *Filtering) GetRoot() isFiltering_Root

func (*Filtering) GetStringArrayCondition added in v0.15.0

func (m *Filtering) GetStringArrayCondition() *StringArrayCondition

func (*Filtering) GetStringCondition

func (m *Filtering) GetStringCondition() *StringCondition

func (*Filtering) ProtoMessage

func (*Filtering) ProtoMessage()

func (*Filtering) Reset

func (m *Filtering) Reset()

func (*Filtering) SetRoot

func (m *Filtering) SetRoot(r interface{}) error

SetRoot automatically wraps r into appropriate oneof structure and sets it to Root.

func (*Filtering) String

func (m *Filtering) String() string

func (*Filtering) XXX_OneofFuncs

func (*Filtering) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type FilteringExpression

type FilteringExpression interface {
	Filter(interface{}) (bool, error)
}

FilteringExpression is the interface implemented by types that represent nodes in a filtering expression AST.

type FilteringLexer

type FilteringLexer interface {
	NextToken() (Token, error)
}

FilteringLexer is impemented by lexical analyzers that are used by filtering expression parsers.

func NewFilteringLexer

func NewFilteringLexer(text string) FilteringLexer

NewFilteringLexer returns a default FilteringLexer implementation. text is a filtering expression to analyze.

type FilteringParser

type FilteringParser interface {
	Parse(string) (*Filtering, error)
}

FilteringParser is implemented by parsers of a filtering expression that conforms to REST API Syntax Specification.

func NewFilteringParser

func NewFilteringParser() FilteringParser

NewFilteringParser returns a default FilteringParser implementation.

type Filtering_NullCondition

type Filtering_NullCondition struct {
	NullCondition *NullCondition `protobuf:"bytes,4,opt,name=null_condition,json=nullCondition,oneof"`
}

func (*Filtering_NullCondition) Filter

func (m *Filtering_NullCondition) Filter(obj interface{}) (bool, error)

type Filtering_NumberArrayCondition added in v0.15.0

type Filtering_NumberArrayCondition struct {
	NumberArrayCondition *NumberArrayCondition `protobuf:"bytes,6,opt,name=number_array_condition,json=numberArrayCondition,oneof"`
}

func (*Filtering_NumberArrayCondition) Filter added in v0.15.0

func (m *Filtering_NumberArrayCondition) Filter(obj interface{}) (bool, error)

type Filtering_NumberCondition

type Filtering_NumberCondition struct {
	NumberCondition *NumberCondition `protobuf:"bytes,3,opt,name=number_condition,json=numberCondition,oneof"`
}

func (*Filtering_NumberCondition) Filter

func (m *Filtering_NumberCondition) Filter(obj interface{}) (bool, error)

type Filtering_Operator

type Filtering_Operator struct {
	Operator *LogicalOperator `protobuf:"bytes,1,opt,name=operator,oneof"`
}

func (*Filtering_Operator) Filter

func (m *Filtering_Operator) Filter(obj interface{}) (bool, error)

type Filtering_StringArrayCondition added in v0.15.0

type Filtering_StringArrayCondition struct {
	StringArrayCondition *StringArrayCondition `protobuf:"bytes,5,opt,name=string_array_condition,json=stringArrayCondition,oneof"`
}

func (*Filtering_StringArrayCondition) Filter added in v0.15.0

func (m *Filtering_StringArrayCondition) Filter(obj interface{}) (bool, error)

type Filtering_StringCondition

type Filtering_StringCondition struct {
	StringCondition *StringCondition `protobuf:"bytes,2,opt,name=string_condition,json=stringCondition,oneof"`
}

func (*Filtering_StringCondition) Filter

func (m *Filtering_StringCondition) Filter(obj interface{}) (bool, error)

type GeToken

type GeToken struct {
	TokenBase
}

GeToken represents greater than or equals operator.

func (GeToken) String

func (t GeToken) String() string

type GtToken

type GtToken struct {
	TokenBase
}

GtToken represents greater than operator.

func (GtToken) String

func (t GtToken) String() string

type InToken added in v0.15.0

type InToken struct {
	TokenBase
}

InToken represent in operation for string and numbers arrays

func (InToken) String added in v0.15.0

func (t InToken) String() string

type InsensitiveEqToken added in v0.15.0

type InsensitiveEqToken struct {
	TokenBase
}

func (InsensitiveEqToken) String added in v0.15.0

func (t InsensitiveEqToken) String() string

type LeToken

type LeToken struct {
	TokenBase
}

LeToken represents less than or equals operator.

func (LeToken) String

func (t LeToken) String() string

type LogicalOperator

type LogicalOperator struct {
	// Types that are valid to be assigned to Left:
	//	*LogicalOperator_LeftOperator
	//	*LogicalOperator_LeftStringCondition
	//	*LogicalOperator_LeftNumberCondition
	//	*LogicalOperator_LeftNullCondition
	//	*LogicalOperator_LeftStringArrayCondition
	//	*LogicalOperator_LeftNumberArrayCondition
	Left isLogicalOperator_Left `protobuf_oneof:"left"`
	// Types that are valid to be assigned to Right:
	//	*LogicalOperator_RightOperator
	//	*LogicalOperator_RightStringCondition
	//	*LogicalOperator_RightNumberCondition
	//	*LogicalOperator_RightNullCondition
	//	*LogicalOperator_RightStringArrayCondition
	//	*LogicalOperator_RightNumberArrayCondition
	Right      isLogicalOperator_Right `protobuf_oneof:"right"`
	Type       LogicalOperator_Type    `protobuf:"varint,9,opt,name=type,enum=infoblox.api.LogicalOperator_Type" json:"type,omitempty"`
	IsNegative bool                    `protobuf:"varint,10,opt,name=is_negative,json=isNegative" json:"is_negative,omitempty"`
}

LogicalOperator represents binary logical operator, either AND or OR depending on type. left and right are respectively left and right operands of the operator, could be either LogicalOperator or one of the supported conditions. is_negative is set to true if the operator is negated.

func (*LogicalOperator) Descriptor

func (*LogicalOperator) Descriptor() ([]byte, []int)

func (*LogicalOperator) Filter

func (lop *LogicalOperator) Filter(obj interface{}) (bool, error)

Filter evaluates filtering expression against obj.

func (*LogicalOperator) GetIsNegative

func (m *LogicalOperator) GetIsNegative() bool

func (*LogicalOperator) GetLeft

func (m *LogicalOperator) GetLeft() isLogicalOperator_Left

func (*LogicalOperator) GetLeftNullCondition

func (m *LogicalOperator) GetLeftNullCondition() *NullCondition

func (*LogicalOperator) GetLeftNumberArrayCondition added in v0.15.0

func (m *LogicalOperator) GetLeftNumberArrayCondition() *NumberArrayCondition

func (*LogicalOperator) GetLeftNumberCondition

func (m *LogicalOperator) GetLeftNumberCondition() *NumberCondition

func (*LogicalOperator) GetLeftOperator

func (m *LogicalOperator) GetLeftOperator() *LogicalOperator

func (*LogicalOperator) GetLeftStringArrayCondition added in v0.15.0

func (m *LogicalOperator) GetLeftStringArrayCondition() *StringArrayCondition

func (*LogicalOperator) GetLeftStringCondition

func (m *LogicalOperator) GetLeftStringCondition() *StringCondition

func (*LogicalOperator) GetRight

func (m *LogicalOperator) GetRight() isLogicalOperator_Right

func (*LogicalOperator) GetRightNullCondition

func (m *LogicalOperator) GetRightNullCondition() *NullCondition

func (*LogicalOperator) GetRightNumberArrayCondition added in v0.15.0

func (m *LogicalOperator) GetRightNumberArrayCondition() *NumberArrayCondition

func (*LogicalOperator) GetRightNumberCondition

func (m *LogicalOperator) GetRightNumberCondition() *NumberCondition

func (*LogicalOperator) GetRightOperator

func (m *LogicalOperator) GetRightOperator() *LogicalOperator

func (*LogicalOperator) GetRightStringArrayCondition added in v0.15.0

func (m *LogicalOperator) GetRightStringArrayCondition() *StringArrayCondition

func (*LogicalOperator) GetRightStringCondition

func (m *LogicalOperator) GetRightStringCondition() *StringCondition

func (*LogicalOperator) GetType

func (*LogicalOperator) ProtoMessage

func (*LogicalOperator) ProtoMessage()

func (*LogicalOperator) Reset

func (m *LogicalOperator) Reset()

func (*LogicalOperator) SetLeft

func (m *LogicalOperator) SetLeft(l interface{}) error

SetLeft automatically wraps l into appropriate oneof structure and sets it to Root.

func (*LogicalOperator) SetRight

func (m *LogicalOperator) SetRight(r interface{}) error

SetRight automatically wraps r into appropriate oneof structure and sets it to Root.

func (*LogicalOperator) String

func (m *LogicalOperator) String() string

func (*LogicalOperator) XXX_OneofFuncs

func (*LogicalOperator) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type LogicalOperator_LeftNullCondition

type LogicalOperator_LeftNullCondition struct {
	LeftNullCondition *NullCondition `protobuf:"bytes,4,opt,name=left_null_condition,json=leftNullCondition,oneof"`
}

func (*LogicalOperator_LeftNullCondition) Filter

func (m *LogicalOperator_LeftNullCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_LeftNumberArrayCondition added in v0.15.0

type LogicalOperator_LeftNumberArrayCondition struct {
	LeftNumberArrayCondition *NumberArrayCondition `protobuf:"bytes,12,opt,name=left_number_array_condition,json=leftNumberArrayCondition,oneof"`
}

func (*LogicalOperator_LeftNumberArrayCondition) Filter added in v0.15.0

func (m *LogicalOperator_LeftNumberArrayCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_LeftNumberCondition

type LogicalOperator_LeftNumberCondition struct {
	LeftNumberCondition *NumberCondition `protobuf:"bytes,3,opt,name=left_number_condition,json=leftNumberCondition,oneof"`
}

func (*LogicalOperator_LeftNumberCondition) Filter

func (m *LogicalOperator_LeftNumberCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_LeftOperator

type LogicalOperator_LeftOperator struct {
	LeftOperator *LogicalOperator `protobuf:"bytes,1,opt,name=left_operator,json=leftOperator,oneof"`
}

func (*LogicalOperator_LeftOperator) Filter

func (m *LogicalOperator_LeftOperator) Filter(obj interface{}) (bool, error)

type LogicalOperator_LeftStringArrayCondition added in v0.15.0

type LogicalOperator_LeftStringArrayCondition struct {
	LeftStringArrayCondition *StringArrayCondition `protobuf:"bytes,11,opt,name=left_string_array_condition,json=leftStringArrayCondition,oneof"`
}

func (*LogicalOperator_LeftStringArrayCondition) Filter added in v0.15.0

func (m *LogicalOperator_LeftStringArrayCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_LeftStringCondition

type LogicalOperator_LeftStringCondition struct {
	LeftStringCondition *StringCondition `protobuf:"bytes,2,opt,name=left_string_condition,json=leftStringCondition,oneof"`
}

func (*LogicalOperator_LeftStringCondition) Filter

func (m *LogicalOperator_LeftStringCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_RightNullCondition

type LogicalOperator_RightNullCondition struct {
	RightNullCondition *NullCondition `protobuf:"bytes,8,opt,name=right_null_condition,json=rightNullCondition,oneof"`
}

func (*LogicalOperator_RightNullCondition) Filter

func (m *LogicalOperator_RightNullCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_RightNumberArrayCondition added in v0.15.0

type LogicalOperator_RightNumberArrayCondition struct {
	RightNumberArrayCondition *NumberArrayCondition `protobuf:"bytes,14,opt,name=right_number_array_condition,json=rightNumberArrayCondition,oneof"`
}

func (*LogicalOperator_RightNumberArrayCondition) Filter added in v0.15.0

func (m *LogicalOperator_RightNumberArrayCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_RightNumberCondition

type LogicalOperator_RightNumberCondition struct {
	RightNumberCondition *NumberCondition `protobuf:"bytes,7,opt,name=right_number_condition,json=rightNumberCondition,oneof"`
}

func (*LogicalOperator_RightNumberCondition) Filter

func (m *LogicalOperator_RightNumberCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_RightOperator

type LogicalOperator_RightOperator struct {
	RightOperator *LogicalOperator `protobuf:"bytes,5,opt,name=right_operator,json=rightOperator,oneof"`
}

func (*LogicalOperator_RightOperator) Filter

func (m *LogicalOperator_RightOperator) Filter(obj interface{}) (bool, error)

type LogicalOperator_RightStringArrayCondition added in v0.15.0

type LogicalOperator_RightStringArrayCondition struct {
	RightStringArrayCondition *StringArrayCondition `protobuf:"bytes,13,opt,name=right_string_array_condition,json=rightStringArrayCondition,oneof"`
}

func (*LogicalOperator_RightStringArrayCondition) Filter added in v0.15.0

func (m *LogicalOperator_RightStringArrayCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_RightStringCondition

type LogicalOperator_RightStringCondition struct {
	RightStringCondition *StringCondition `protobuf:"bytes,6,opt,name=right_string_condition,json=rightStringCondition,oneof"`
}

func (*LogicalOperator_RightStringCondition) Filter

func (m *LogicalOperator_RightStringCondition) Filter(obj interface{}) (bool, error)

type LogicalOperator_Type

type LogicalOperator_Type int32
const (
	LogicalOperator_AND LogicalOperator_Type = 0
	LogicalOperator_OR  LogicalOperator_Type = 1
)

func (LogicalOperator_Type) EnumDescriptor

func (LogicalOperator_Type) EnumDescriptor() ([]byte, []int)

func (LogicalOperator_Type) String

func (x LogicalOperator_Type) String() string

type LparenToken

type LparenToken struct {
	TokenBase
}

LparenToken represents left parenthesis.

func (LparenToken) String

func (t LparenToken) String() string

type LtToken

type LtToken struct {
	TokenBase
}

LtToken represents less than operator.

func (LtToken) String

func (t LtToken) String() string

type MatchToken

type MatchToken struct {
	TokenBase
}

MatchToken represents regular expression match.

func (MatchToken) String

func (t MatchToken) String() string

type Matcher

type Matcher interface {
	Match(*Filtering) (bool, error)
}

Matcher is implemented by structs that require custom filtering logic.

type NeToken

type NeToken struct {
	TokenBase
}

NeToken represents not equals operator.

func (NeToken) String

func (t NeToken) String() string

type NmatchToken

type NmatchToken struct {
	TokenBase
}

NmatchToken represents negation of regular expression match.

func (NmatchToken) String

func (t NmatchToken) String() string

type NotToken

type NotToken struct {
	TokenBase
}

NotToken represents logical not.

func (NotToken) String

func (t NotToken) String() string

type NullCondition

type NullCondition struct {
	FieldPath  []string `protobuf:"bytes,1,rep,name=field_path,json=fieldPath" json:"field_path,omitempty"`
	IsNegative bool     `protobuf:"varint,2,opt,name=is_negative,json=isNegative" json:"is_negative,omitempty"`
}

NullCondition represents a condition with a null literal, e.g. field == null. field_path is a reference to a value of a resource. is_negative is set to true if the condition is negated.

func (*NullCondition) Descriptor

func (*NullCondition) Descriptor() ([]byte, []int)

func (*NullCondition) Filter

func (c *NullCondition) Filter(obj interface{}) (bool, error)

Filter evaluates null condition against obj. If obj is a proto message, then 'protobuf' tag is used to map FieldPath to obj's struct fields, otherwise 'json' tag is used.

func (*NullCondition) GetFieldPath

func (m *NullCondition) GetFieldPath() []string

func (*NullCondition) GetIsNegative

func (m *NullCondition) GetIsNegative() bool

func (*NullCondition) ProtoMessage

func (*NullCondition) ProtoMessage()

func (*NullCondition) Reset

func (m *NullCondition) Reset()

func (*NullCondition) String

func (m *NullCondition) String() string

type NullToken

type NullToken struct {
	TokenBase
}

NullToken represents null literal.

func (NullToken) String

func (t NullToken) String() string

type NumberArrayCondition added in v0.15.0

type NumberArrayCondition struct {
	FieldPath  []string                  `protobuf:"bytes,1,rep,name=field_path,json=fieldPath" json:"field_path,omitempty"`
	Values     []float64                 `protobuf:"fixed64,2,rep,packed,name=values" json:"values,omitempty"`
	Type       NumberArrayCondition_Type `protobuf:"varint,3,opt,name=type,enum=infoblox.api.NumberArrayCondition_Type" json:"type,omitempty"`
	IsNegative bool                      `protobuf:"varint,4,opt,name=is_negative,json=isNegative" json:"is_negative,omitempty"`
}

NumberArrayCondition represents a condition with string arrays, e.g. field in [1, 5, 7] field_path is a reference to a value of a resource. is_negative is set to true if the condition is negated

func (*NumberArrayCondition) Descriptor added in v0.15.0

func (*NumberArrayCondition) Descriptor() ([]byte, []int)

func (*NumberArrayCondition) Filter added in v0.15.0

func (c *NumberArrayCondition) Filter(obj interface{}) (bool, error)

func (*NumberArrayCondition) GetFieldPath added in v0.15.0

func (m *NumberArrayCondition) GetFieldPath() []string

func (*NumberArrayCondition) GetIsNegative added in v0.15.0

func (m *NumberArrayCondition) GetIsNegative() bool

func (*NumberArrayCondition) GetType added in v0.15.0

func (*NumberArrayCondition) GetValues added in v0.15.0

func (m *NumberArrayCondition) GetValues() []float64

func (*NumberArrayCondition) ProtoMessage added in v0.15.0

func (*NumberArrayCondition) ProtoMessage()

func (*NumberArrayCondition) Reset added in v0.15.0

func (m *NumberArrayCondition) Reset()

func (*NumberArrayCondition) String added in v0.15.0

func (m *NumberArrayCondition) String() string

type NumberArrayCondition_Type added in v0.15.0

type NumberArrayCondition_Type int32
const (
	NumberArrayCondition_IN NumberArrayCondition_Type = 0
)

func (NumberArrayCondition_Type) EnumDescriptor added in v0.15.0

func (NumberArrayCondition_Type) EnumDescriptor() ([]byte, []int)

func (NumberArrayCondition_Type) String added in v0.15.0

func (x NumberArrayCondition_Type) String() string

type NumberArrayToken added in v0.15.0

type NumberArrayToken struct {
	TokenBase
	Values []float64
}

NumberArrayToken represent number array e.g. [1,2,5]

func (NumberArrayToken) String added in v0.15.0

func (t NumberArrayToken) String() string

type NumberCondition

type NumberCondition struct {
	FieldPath  []string             `protobuf:"bytes,1,rep,name=field_path,json=fieldPath" json:"field_path,omitempty"`
	Value      float64              `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"`
	Type       NumberCondition_Type `protobuf:"varint,3,opt,name=type,enum=infoblox.api.NumberCondition_Type" json:"type,omitempty"`
	IsNegative bool                 `protobuf:"varint,4,opt,name=is_negative,json=isNegative" json:"is_negative,omitempty"`
}

NumberCondition represents a condition with a number literal, e.g. field > 3. field_path is a reference to a value of a resource. value is the number literal. type is a type of the condition. is_negative is set to true if the condition is negated.

func (*NumberCondition) Descriptor

func (*NumberCondition) Descriptor() ([]byte, []int)

func (*NumberCondition) Filter

func (c *NumberCondition) Filter(obj interface{}) (bool, error)

Filter evaluates number condition against obj. If obj is a proto message, then 'protobuf' tag is used to map FieldPath to obj's struct fields, otherwise 'json' tag is used.

func (*NumberCondition) GetFieldPath

func (m *NumberCondition) GetFieldPath() []string

func (*NumberCondition) GetIsNegative

func (m *NumberCondition) GetIsNegative() bool

func (*NumberCondition) GetType

func (*NumberCondition) GetValue

func (m *NumberCondition) GetValue() float64

func (*NumberCondition) ProtoMessage

func (*NumberCondition) ProtoMessage()

func (*NumberCondition) Reset

func (m *NumberCondition) Reset()

func (*NumberCondition) String

func (m *NumberCondition) String() string

type NumberCondition_Type

type NumberCondition_Type int32
const (
	NumberCondition_EQ NumberCondition_Type = 0
	NumberCondition_GT NumberCondition_Type = 1
	NumberCondition_GE NumberCondition_Type = 2
	NumberCondition_LT NumberCondition_Type = 3
	NumberCondition_LE NumberCondition_Type = 4
)

func (NumberCondition_Type) EnumDescriptor

func (NumberCondition_Type) EnumDescriptor() ([]byte, []int)

func (NumberCondition_Type) String

func (x NumberCondition_Type) String() string

type NumberToken

type NumberToken struct {
	TokenBase
	Value float64
}

NumberToken represents a number literal. Value is a value of the literal.

func (NumberToken) String

func (t NumberToken) String() string

type OrToken

type OrToken struct {
	TokenBase
}

OrToken represents logical or.

func (OrToken) String

func (t OrToken) String() string

type PageInfo

type PageInfo struct {
	// The service response should contain a string to indicate
	// the next page of resources.
	// A null value indicates no more pages.
	PageToken string `protobuf:"bytes,1,opt,name=page_token,json=pageToken" json:"page_token,omitempty"`
	// The service may optionally include the total number of resources being paged.
	Size int32 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"`
	// The service may optionally include the offset of the next page of resources.
	// A null value indicates no more pages.
	Offset int32 `protobuf:"varint,3,opt,name=offset" json:"offset,omitempty"`
}

PageInfo represents both server-driven and client-driven pagination response. Server-driven pagination is a model in which the server returns some amount of data along with an token indicating there is more data and where subsequent queries can get the next page of data. Client-driven pagination is a model in which rows are addressable by offset and page size (limit).

func (*PageInfo) Descriptor

func (*PageInfo) Descriptor() ([]byte, []int)

func (*PageInfo) GetOffset

func (m *PageInfo) GetOffset() int32

func (*PageInfo) GetPageToken

func (m *PageInfo) GetPageToken() string

func (*PageInfo) GetSize

func (m *PageInfo) GetSize() int32

func (*PageInfo) NoMore

func (p *PageInfo) NoMore() bool

NoMore reports whether page info indicates no more pages are available

func (*PageInfo) ProtoMessage

func (*PageInfo) ProtoMessage()

func (*PageInfo) Reset

func (m *PageInfo) Reset()

func (*PageInfo) SetLastOffset

func (p *PageInfo) SetLastOffset()

SetLastOffset sets page info to indicate no more pages are available

func (*PageInfo) SetLastToken

func (p *PageInfo) SetLastToken()

SetLastToken sets page info to indicate no more pages are available

func (*PageInfo) String

func (m *PageInfo) String() string

type Pagination

type Pagination struct {
	// The service-defined string used to identify a page of resources.
	// A null value indicates the first page.
	PageToken string `protobuf:"bytes,1,opt,name=page_token,json=pageToken" json:"page_token,omitempty"`
	// The integer index of the offset into a collection of resources.
	// If omitted or null the value is assumed to be "0".
	Offset int32 `protobuf:"varint,2,opt,name=offset" json:"offset,omitempty"`
	// The integer number of resources to be returned in the response.
	// The service may impose maximum value.
	// If omitted the service may impose a default value.
	Limit int32 `protobuf:"varint,3,opt,name=limit" json:"limit,omitempty"`
}

Pagination represents both server-driven and client-driven pagination request. Server-driven pagination is a model in which the server returns some amount of data along with an token indicating there is more data and where subsequent queries can get the next page of data. Client-driven pagination is a model in which rows are addressable by offset and page size (limit).

func ParsePagination

func ParsePagination(limit, offset, ptoken string) (*Pagination, error)

Pagination parses string representation of pagination limit, offset. Returns error if limit or offset has invalid syntax or out of range.

func (*Pagination) DefaultLimit

func (p *Pagination) DefaultLimit(dl ...int32) int32

DefaultLimit returns DefaultLimit if limit was not specified otherwise returns either requested or specified one.

func (*Pagination) Descriptor

func (*Pagination) Descriptor() ([]byte, []int)

func (*Pagination) FirstPage

func (p *Pagination) FirstPage() bool

FirstPage returns true if requested first page

func (*Pagination) GetLimit

func (m *Pagination) GetLimit() int32

func (*Pagination) GetOffset

func (m *Pagination) GetOffset() int32

func (*Pagination) GetPageToken

func (m *Pagination) GetPageToken() string

func (*Pagination) ProtoMessage

func (*Pagination) ProtoMessage()

func (*Pagination) Reset

func (m *Pagination) Reset()

func (*Pagination) String

func (m *Pagination) String() string

type RparenToken

type RparenToken struct {
	TokenBase
}

RparenToken represents right parenthesis.

func (RparenToken) String

func (t RparenToken) String() string

type SortCriteria

type SortCriteria struct {
	// Tag is a JSON tag.
	Tag   string             `protobuf:"bytes,1,opt,name=tag" json:"tag,omitempty"`
	Order SortCriteria_Order `protobuf:"varint,2,opt,name=order,enum=infoblox.api.SortCriteria_Order" json:"order,omitempty"`
}

SortCriteria represents sort criteria

func (*SortCriteria) Descriptor

func (*SortCriteria) Descriptor() ([]byte, []int)

func (*SortCriteria) GetOrder

func (m *SortCriteria) GetOrder() SortCriteria_Order

func (*SortCriteria) GetTag

func (m *SortCriteria) GetTag() string

func (SortCriteria) GoString

func (c SortCriteria) GoString() string

GoString implements fmt.GoStringer interface return string representation of a sort criteria in next form: "<tag_name> (ASC|DESC)".

func (SortCriteria) IsAsc

func (c SortCriteria) IsAsc() bool

IsAsc returns true if sort criteria has ascending sort order, otherwise false.

func (SortCriteria) IsDesc

func (c SortCriteria) IsDesc() bool

IsDesc returns true if sort criteria has descending sort order, otherwise false.

func (*SortCriteria) ProtoMessage

func (*SortCriteria) ProtoMessage()

func (*SortCriteria) Reset

func (m *SortCriteria) Reset()

func (*SortCriteria) String

func (m *SortCriteria) String() string

type SortCriteria_Order

type SortCriteria_Order int32

Order is a sort order.

const (
	// ascending sort order
	SortCriteria_ASC SortCriteria_Order = 0
	// descending sort order
	SortCriteria_DESC SortCriteria_Order = 1
)

func (SortCriteria_Order) EnumDescriptor

func (SortCriteria_Order) EnumDescriptor() ([]byte, []int)

func (SortCriteria_Order) String

func (x SortCriteria_Order) String() string

type Sorting

type Sorting struct {
	Criterias []*SortCriteria `protobuf:"bytes,1,rep,name=criterias" json:"criterias,omitempty"`
}

Sorting represents list of sort criterias.

func ParseSorting

func ParseSorting(s string) (*Sorting, error)

ParseSorting parses raw string that represent sort criteria into a Sorting data structure. Provided string is supposed to be in accordance with the sorting collection operator from REST API Syntax. See: https://github.com/infobloxopen/atlas-app-toolkit#sorting

func (*Sorting) Descriptor

func (*Sorting) Descriptor() ([]byte, []int)

func (*Sorting) GetCriterias

func (m *Sorting) GetCriterias() []*SortCriteria

func (Sorting) GoString

func (s Sorting) GoString() string

GoString implements fmt.GoStringer interface Returns string representation of sorting in next form: "<name> (ASC|DESC) [, <tag_name> (ASC|DESC)]"

func (*Sorting) ProtoMessage

func (*Sorting) ProtoMessage()

func (*Sorting) Reset

func (m *Sorting) Reset()

func (*Sorting) String

func (m *Sorting) String() string

type StringArrayCondition added in v0.15.0

type StringArrayCondition struct {
	FieldPath  []string                  `protobuf:"bytes,1,rep,name=field_path,json=fieldPath" json:"field_path,omitempty"`
	Values     []string                  `protobuf:"bytes,2,rep,name=values" json:"values,omitempty"`
	Type       StringArrayCondition_Type `protobuf:"varint,3,opt,name=type,enum=infoblox.api.StringArrayCondition_Type" json:"type,omitempty"`
	IsNegative bool                      `protobuf:"varint,4,opt,name=is_negative,json=isNegative" json:"is_negative,omitempty"`
}

StringArrayCondition represents a condition with string arrays, e.g. field in ['hello','world'] field_path is a reference to a value of a resource. is_negative is set to true if the condition is negated

func (*StringArrayCondition) Descriptor added in v0.15.0

func (*StringArrayCondition) Descriptor() ([]byte, []int)

func (*StringArrayCondition) Filter added in v0.15.0

func (c *StringArrayCondition) Filter(obj interface{}) (bool, error)

func (*StringArrayCondition) GetFieldPath added in v0.15.0

func (m *StringArrayCondition) GetFieldPath() []string

func (*StringArrayCondition) GetIsNegative added in v0.15.0

func (m *StringArrayCondition) GetIsNegative() bool

func (*StringArrayCondition) GetType added in v0.15.0

func (*StringArrayCondition) GetValues added in v0.15.0

func (m *StringArrayCondition) GetValues() []string

func (*StringArrayCondition) ProtoMessage added in v0.15.0

func (*StringArrayCondition) ProtoMessage()

func (*StringArrayCondition) Reset added in v0.15.0

func (m *StringArrayCondition) Reset()

func (*StringArrayCondition) String added in v0.15.0

func (m *StringArrayCondition) String() string

type StringArrayCondition_Type added in v0.15.0

type StringArrayCondition_Type int32
const (
	StringArrayCondition_IN StringArrayCondition_Type = 0
)

func (StringArrayCondition_Type) EnumDescriptor added in v0.15.0

func (StringArrayCondition_Type) EnumDescriptor() ([]byte, []int)

func (StringArrayCondition_Type) String added in v0.15.0

func (x StringArrayCondition_Type) String() string

type StringArrayToken added in v0.15.0

type StringArrayToken struct {
	TokenBase
	Values []string
}

NumberArrayToken represent number array e.g. [1,2,5]

func (StringArrayToken) String added in v0.15.0

func (t StringArrayToken) String() string

type StringCondition

type StringCondition struct {
	FieldPath  []string             `protobuf:"bytes,1,rep,name=field_path,json=fieldPath" json:"field_path,omitempty"`
	Value      string               `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
	Type       StringCondition_Type `protobuf:"varint,3,opt,name=type,enum=infoblox.api.StringCondition_Type" json:"type,omitempty"`
	IsNegative bool                 `protobuf:"varint,4,opt,name=is_negative,json=isNegative" json:"is_negative,omitempty"`
}

StringCondition represents a condition with a string literal, e.g. field == 'string'. field_path is a reference to a value of a resource. value is the string literal. type is a type of the condition. is_negative is set to true if the condition is negated.

func (*StringCondition) Descriptor

func (*StringCondition) Descriptor() ([]byte, []int)

func (*StringCondition) Filter

func (c *StringCondition) Filter(obj interface{}) (bool, error)

Filter evaluates string condition against obj. If obj is a proto message, then 'protobuf' tag is used to map FieldPath to obj's struct fields, otherwise 'json' tag is used.

func (*StringCondition) GetFieldPath

func (m *StringCondition) GetFieldPath() []string

func (*StringCondition) GetIsNegative

func (m *StringCondition) GetIsNegative() bool

func (*StringCondition) GetType

func (*StringCondition) GetValue

func (m *StringCondition) GetValue() string

func (*StringCondition) ProtoMessage

func (*StringCondition) ProtoMessage()

func (*StringCondition) Reset

func (m *StringCondition) Reset()

func (*StringCondition) String

func (m *StringCondition) String() string

type StringCondition_Type

type StringCondition_Type int32
const (
	StringCondition_EQ    StringCondition_Type = 0
	StringCondition_MATCH StringCondition_Type = 1
	StringCondition_GT    StringCondition_Type = 2
	StringCondition_GE    StringCondition_Type = 3
	StringCondition_LT    StringCondition_Type = 4
	StringCondition_LE    StringCondition_Type = 5
	StringCondition_IEQ   StringCondition_Type = 6
)

func (StringCondition_Type) EnumDescriptor

func (StringCondition_Type) EnumDescriptor() ([]byte, []int)

func (StringCondition_Type) String

func (x StringCondition_Type) String() string

type StringToken

type StringToken struct {
	TokenBase
	Value string
}

StringToken represents a string literal. Value is a value of the literal.

func (StringToken) String

func (t StringToken) String() string

type Token

type Token interface {
	Token()
}

Token is impelemented by all supported tokens in a filtering expression.

type TokenBase

type TokenBase struct{}

TokenBase is used as a base type for all types which are tokens.

func (TokenBase) Token

func (t TokenBase) Token()

Token distinguishes tokens from other types.

type TypeMismatchError

type TypeMismatchError struct {
	ReqType   string
	FieldPath []string
}

TypeMismatchError representes a type that is required for a value under FieldPath.

func (*TypeMismatchError) Error

func (e *TypeMismatchError) Error() string

type UnexpectedSymbolError

type UnexpectedSymbolError struct {
	S   rune
	Pos int
}

UnexpectedSymbolError describes symbol S in position Pos that was not appropriate according to REST API Syntax Specification.

func (*UnexpectedSymbolError) Error

func (e *UnexpectedSymbolError) Error() string

type UnexpectedTokenError

type UnexpectedTokenError struct {
	T Token
}

UnexpectedTokenError describes a token that was not appropriate according to REST API Syntax Specification.

func (*UnexpectedTokenError) Error

func (e *UnexpectedTokenError) Error() string

type UnsupportedOperatorError

type UnsupportedOperatorError struct {
	Type string
	Op   string
}

UnsupportedOperatorError represents an operator that is not supported by a particular field type.

func (*UnsupportedOperatorError) Error

func (e *UnsupportedOperatorError) Error() string

Jump to

Keyboard shortcuts

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