Documentation ¶
Overview ¶
Package fieldmask provides API utilities for working with field masks. It allows to parse field masks from input parameters, validate them and translate into an expression.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidField is an error that is returned when a field is invalid or is not found. ErrInvalidField = errors.New("invalid field") // ErrInternalError is an internal error done during interpretation. ErrInternalError = errors.New("internal error") // ErrInvalidSyntax is an error returned by the parser when the field mask // has invalid syntax. ErrInvalidSyntax = errors.New("invalid syntax") )
Functions ¶
func IgnoreNonUpdatableOption ¶
IgnoreNonUpdatableOption is an option function that sets the ignore non updatable option for the parser.
Types ¶
type OptionFn ¶
OptionFn is an option function for the Parser.
func ErrHandlerOption ¶
func ErrHandlerOption(fn scanner.ErrorHandler) OptionFn
ErrHandlerOption is an option function that sets the error handler for the parser.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is a field mask to expression parser. It allows to match the google.protobuf.FieldMask with a message descriptor fields. As a result it produces an expression that can be used to patch the message.
func (*Parser) ParseSelectExpr ¶
func (p *Parser) ParseSelectExpr(fm *fieldmaskpb.FieldMask) (*expr.MessageSelectExpr, error)
ParseSelectExpr parses a select expression from the field mask. All the common sub paths are consolidated into a single sub MessageSelectExpr for
func (*Parser) ParseUpdateExpr ¶
func (p *Parser) ParseUpdateExpr(msg proto.Message, mask *fieldmaskpb.FieldMask) (*expr.UpdateExpr, error)
ParseUpdateExpr parses a field mask, and extracts field values to update from the given message. Parsed field mask Update expressions, can be used to update selected fields of a message. If selected field is a map with a wildstar selector i.e: path: "map_field.*.field_name" This will evaluate to all keys in the mapi_field value