masks

package
v0.0.0-...-084e4ab Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFieldUpdateOptions = []FieldUpdaterOption{
	WithUpdateMaskFieldName("update_mask"),
}

Functions

func RemovePrefix

func RemovePrefix(prefix string, mask *fieldmaskpb.FieldMask) *fieldmaskpb.FieldMask

Types

type FieldUpdater

type FieldUpdater struct {
	// contains filtered or unexported fields
}

func NewFieldUpdater

func NewFieldUpdater(opts ...FieldUpdaterOption) *FieldUpdater

func (*FieldUpdater) Merge

func (f *FieldUpdater) Merge(dst, src proto.Message)

Merge copies the values in src into dst based on the configured field masks.

func (*FieldUpdater) Validate

func (f *FieldUpdater) Validate(m proto.Message) error

type FieldUpdaterOption

type FieldUpdaterOption func(*FieldUpdater)

func WithResetMask

func WithResetMask(resetMask *fieldmaskpb.FieldMask) FieldUpdaterOption

WithResetMask configures the FieldUpdater to clear the values mentioned in the mask.

func WithResetPaths

func WithResetPaths(paths ...string) FieldUpdaterOption

WithResetPaths is like WithResetMask but accepts paths.

func WithUpdateMask

func WithUpdateMask(updateMask *fieldmaskpb.FieldMask) FieldUpdaterOption

WithUpdateMask configures the FieldUpdater to only apply values for the mentioned fields. A nil updateMask represents all writable fields.

func WithUpdateMaskFieldName

func WithUpdateMaskFieldName(name string) FieldUpdaterOption

WithUpdateMaskFieldName configures the name of the field that holds the update mask. Will be used when constructing error messages. Defaults to "update_mask".

func WithWritableFields

func WithWritableFields(writableFields *fieldmaskpb.FieldMask) FieldUpdaterOption

WithWritableFields configures the FieldUpdater to validate that no non-writable fields are being written. A nil writableFields means all fields are writable.

type ResponseFilter

type ResponseFilter struct {
	// contains filtered or unexported fields
}

ResponseFilter provides utilities for applying FieldMasks to responses.

func NewResponseFilter

func NewResponseFilter(opts ...ResponseFilterOption) *ResponseFilter

NewResponseFilter creates a new ResponseFilter with the given options applied.

func (*ResponseFilter) Filter

func (r *ResponseFilter) Filter(msg proto.Message)

Filter resets all fields in msg that are not requested via the WithFieldMask option. If no field mask is configured, will not modify the msg. This changes the original message.

func (*ResponseFilter) FilterClone

func (r *ResponseFilter) FilterClone(msg proto.Message) proto.Message

FilterClone is like Filter but clones and returns a new msg instead of modifying the original.

func (*ResponseFilter) Validate

func (r *ResponseFilter) Validate(msg proto.Message) error

type ResponseFilterOption

type ResponseFilterOption func(*ResponseFilter)

func WithFieldMaskPaths

func WithFieldMaskPaths(paths ...string) ResponseFilterOption

Jump to

Keyboard shortcuts

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