fieldmask

package
v0.0.0-...-c824f4b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

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

View Source
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

func IgnoreNonUpdatableOption(p *Parser) error

IgnoreNonUpdatableOption is an option function that sets the ignore non updatable option for the parser.

Types

type OptionFn

type OptionFn func(p *Parser) error

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

func (*Parser) Reset

func (p *Parser) Reset(msg proto.Message, opts ...OptionFn) error

Reset the parser.

Jump to

Keyboard shortcuts

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