Documentation
¶
Overview ¶
Package crud implements backend-neutral CRUD request preparation.
Index ¶
- Constants
- func ComputeContextFingerprint(input ContextFingerprintInput) [sha256.Size]byte
- type ConfiguredOrderTerm
- type ContextFingerprintInput
- type CursorValue
- func (value CursorValue) BoolValue() (bool, bool)
- func (value CursorValue) BytesValue() ([]byte, bool)
- func (value CursorValue) DoubleValue() (float64, bool)
- func (value CursorValue) DurationValue() (*durationpb.Duration, bool)
- func (value CursorValue) Int64Value() (int64, bool)
- func (value CursorValue) IsNull() bool
- func (value CursorValue) LogicalType() LogicalType
- func (value CursorValue) StringValue() (string, bool)
- func (value CursorValue) TimestampValue() (time.Time, bool)
- func (value CursorValue) Uint64Value() (uint64, bool)
- type DeleteOptions
- type FieldPlan
- type FilterExpression
- type FilterLimitOption
- func MaxFilterBytes(value int) FilterLimitOption
- func MaxFilterDepth(value int) FilterLimitOption
- func MaxFilterNodes(value int) FilterLimitOption
- func MaxFilterORTerms(value int) FilterLimitOption
- func WithoutMaxFilterBytes() FilterLimitOption
- func WithoutMaxFilterDepth() FilterLimitOption
- func WithoutMaxFilterNodes() FilterLimitOption
- func WithoutMaxFilterORTerms() FilterLimitOption
- type FilterLimits
- type FilterNode
- type FilterNodeKind
- type FilterOperator
- type FilterValue
- func (v FilterValue) BoolValue() (bool, bool)
- func (v FilterValue) DoubleValue() (float64, bool)
- func (v FilterValue) DurationValue() (*durationpb.Duration, bool)
- func (v FilterValue) EnumNumber() (protoreflect.EnumNumber, bool)
- func (v FilterValue) EnumSymbol() (string, bool)
- func (v FilterValue) Int64Value() (int64, bool)
- func (v FilterValue) Kind() FilterValueKind
- func (v FilterValue) StringMatch() (StringMatch, bool)
- func (v FilterValue) TimestampValue() (time.Time, bool)
- func (v FilterValue) Uint64Value() (uint64, bool)
- type FilterValueKind
- type FinalOrder
- type FinalOrderTerm
- type ImmutableComparison
- type ListConfigOption
- type ListInput
- type ListOptions
- type ListPreparer
- type ListPreparerOption
- type ListQuery
- func (query ListQuery) Collection() string
- func (query ListQuery) EncodePageToken(fingerprint [sha256.Size]byte, cursor []*crudpb.CursorValue) (string, error)
- func (query ListQuery) Filter() FilterExpression
- func (query ListQuery) IncludeTotal() bool
- func (query ListQuery) OrderBy() OrderExpression
- func (query ListQuery) PageSize() int32
- func (query ListQuery) PageTokenPayload() *crudpb.PageTokenPayload
- func (query ListQuery) ResourceType() string
- func (query ListQuery) Skip() int64
- type ListResource
- type ListResult
- type ListSettings
- type LogicalType
- type OrderAssembler
- type OrderBinding
- type OrderBindingResolver
- type OrderDirection
- type OrderExpression
- type OrderLimitOption
- type OrderLimits
- type OrderTerm
- type PageTokenCodec
- type PreparedCreate
- type PreparedUpdate
- func (prepared PreparedUpdate[R]) ImmutableComparisons() []ImmutableComparison
- func (prepared PreparedUpdate[R]) Options() UpdateOptions
- func (prepared PreparedUpdate[R]) Resource() R
- func (prepared PreparedUpdate[R]) ValidateImmutable(current R) error
- func (prepared PreparedUpdate[R]) WriteMask() *fieldmaskpb.FieldMask
- type ResourceName
- type ResourceNameMatcher
- type ResourcePlan
- func (p *ResourcePlan[R]) Descriptor() protoreflect.MessageDescriptor
- func (p *ResourcePlan[R]) Field(path string) (FieldPlan, bool)
- func (p *ResourcePlan[R]) Identifier() protoreflect.FieldDescriptor
- func (plan *ResourcePlan[R]) NormalizeWriteMask(resource R, mask *fieldmaskpb.FieldMask) (WriteMask, error)
- func (p *ResourcePlan[R]) ParseName(value string) (ResourceName, error)
- func (p *ResourcePlan[R]) Patterns() []string
- func (plan *ResourcePlan[R]) PrepareCreate(resource R) (PreparedCreate[R], error)
- func (plan *ResourcePlan[R]) PrepareUpdate(resource R, mask *fieldmaskpb.FieldMask, options UpdateOptions) (PreparedUpdate[R], error)
- func (p *ResourcePlan[R]) QueryablePaths() []string
- func (p *ResourcePlan[R]) ResourceType() string
- func (plan *ResourcePlan[R]) ToResponse(resource R) (R, error)
- func (plan *ResourcePlan[R]) ToResponses(resources []R) ([]R, error)
- func (p *ResourcePlan[R]) WritablePaths() []string
- type StringMatch
- type StringMatchKind
- type UnsignedPageTokenCodec
- type UpdateOptions
- type WriteMask
Constants ¶
const CurrentPageTokenVersion uint32 = 1
CurrentPageTokenVersion is the only payload version understood by this release.
Variables ¶
This section is empty.
Functions ¶
func ComputeContextFingerprint ¶
func ComputeContextFingerprint(input ContextFingerprintInput) [sha256.Size]byte
ComputeContextFingerprint hashes length-delimited canonical query components.
Types ¶
type ConfiguredOrderTerm ¶
type ConfiguredOrderTerm struct {
// contains filtered or unexported fields
}
ConfiguredOrderTerm is one repository-declared default or cursor-key term.
func NewConfiguredOrderTerm ¶
func NewConfiguredOrderTerm(binding OrderBinding, direction OrderDirection) ConfiguredOrderTerm
NewConfiguredOrderTerm pairs a binding with its repository-declared direction.
type ContextFingerprintInput ¶
type ContextFingerprintInput struct {
ResourceType string
Collection string
Filter FilterExpression
Order FinalOrder
ScopeFingerprint []byte
}
ContextFingerprintInput contains the complete canonical List context. IncludeTotal is intentionally absent because Count does not affect membership or ordering.
type CursorValue ¶
type CursorValue struct {
// contains filtered or unexported fields
}
CursorValue is one validated, backend-neutral cursor value.
func ValidatePageTokenPayload ¶
func ValidatePageTokenPayload( payload *crudpb.PageTokenPayload, expectedFingerprint [sha256.Size]byte, order FinalOrder, ) ([]CursorValue, error)
ValidatePageTokenPayload validates context and positional cursor types before database access.
func (CursorValue) BoolValue ¶
func (value CursorValue) BoolValue() (bool, bool)
BoolValue returns a bool cursor.
func (CursorValue) BytesValue ¶
func (value CursorValue) BytesValue() ([]byte, bool)
BytesValue returns a copy of a bytes cursor.
func (CursorValue) DoubleValue ¶
func (value CursorValue) DoubleValue() (float64, bool)
DoubleValue returns a finite floating-point cursor.
func (CursorValue) DurationValue ¶
func (value CursorValue) DurationValue() (*durationpb.Duration, bool)
DurationValue returns a copy of a duration cursor.
func (CursorValue) Int64Value ¶
func (value CursorValue) Int64Value() (int64, bool)
Int64Value returns a signed integer or enum cursor.
func (CursorValue) IsNull ¶
func (value CursorValue) IsNull() bool
IsNull reports whether this value represents a backend NULL.
func (CursorValue) LogicalType ¶
func (value CursorValue) LogicalType() LogicalType
LogicalType returns the expected canonical type.
func (CursorValue) StringValue ¶
func (value CursorValue) StringValue() (string, bool)
StringValue returns a string cursor.
func (CursorValue) TimestampValue ¶
func (value CursorValue) TimestampValue() (time.Time, bool)
TimestampValue returns a timestamp cursor with its original storage offset.
func (CursorValue) Uint64Value ¶
func (value CursorValue) Uint64Value() (uint64, bool)
Uint64Value returns an unsigned integer cursor.
type DeleteOptions ¶
DeleteOptions contains normalized AIP delete controls without business behavior.
type FieldPlan ¶
type FieldPlan struct {
// contains filtered or unexported fields
}
FieldPlan describes one canonical field path in a resource plan.
func (FieldPlan) Descriptor ¶
func (f FieldPlan) Descriptor() protoreflect.FieldDescriptor
Descriptor returns the leaf field descriptor.
func (FieldPlan) HasBehavior ¶
func (f FieldPlan) HasBehavior(behavior annotations.FieldBehavior) bool
HasBehavior reports whether the field declares the provided AIP behavior.
type FilterExpression ¶
type FilterExpression struct {
// contains filtered or unexported fields
}
FilterExpression is an immutable, typed, normalized AIP filter.
func (FilterExpression) Depth ¶
func (f FilterExpression) Depth() int
Depth returns the maximum AST depth.
func (FilterExpression) Empty ¶
func (f FilterExpression) Empty() bool
Empty reports whether no filter was provided.
func (FilterExpression) NodeCount ¶
func (f FilterExpression) NodeCount() int
NodeCount returns the number of AST nodes.
func (FilterExpression) ORTerms ¶
func (f FilterExpression) ORTerms() int
ORTerms returns the total number of alternatives in OR expressions.
func (FilterExpression) Root ¶
func (f FilterExpression) Root() FilterNode
Root returns the root filter node.
func (FilterExpression) String ¶
func (f FilterExpression) String() string
String returns the canonical normalized filter text.
type FilterLimitOption ¶
type FilterLimitOption func(*FilterLimits) error
FilterLimitOption configures FilterLimits during construction.
func MaxFilterBytes ¶
func MaxFilterBytes(value int) FilterLimitOption
MaxFilterBytes sets the maximum UTF-8 byte length of a filter.
func MaxFilterDepth ¶
func MaxFilterDepth(value int) FilterLimitOption
MaxFilterDepth sets the maximum logical and parenthesis depth.
func MaxFilterNodes ¶
func MaxFilterNodes(value int) FilterLimitOption
MaxFilterNodes sets the maximum parsed filter node count.
func MaxFilterORTerms ¶
func MaxFilterORTerms(value int) FilterLimitOption
MaxFilterORTerms sets the maximum OR term count.
func WithoutMaxFilterBytes ¶
func WithoutMaxFilterBytes() FilterLimitOption
WithoutMaxFilterBytes explicitly disables the filter byte limit.
func WithoutMaxFilterDepth ¶
func WithoutMaxFilterDepth() FilterLimitOption
WithoutMaxFilterDepth explicitly disables the filter depth limit.
func WithoutMaxFilterNodes ¶
func WithoutMaxFilterNodes() FilterLimitOption
WithoutMaxFilterNodes explicitly disables the filter node limit.
func WithoutMaxFilterORTerms ¶
func WithoutMaxFilterORTerms() FilterLimitOption
WithoutMaxFilterORTerms explicitly disables the filter OR term limit.
type FilterLimits ¶
type FilterLimits struct {
// contains filtered or unexported fields
}
FilterLimits contains immutable filter input and structure limits.
func DefaultFilterLimits ¶
func DefaultFilterLimits() FilterLimits
DefaultFilterLimits returns the framework filter limits.
func NewFilterLimits ¶
func NewFilterLimits(options ...FilterLimitOption) (FilterLimits, error)
NewFilterLimits returns filter limits initialized from framework defaults.
func UnlimitedFilterLimits ¶
func UnlimitedFilterLimits() FilterLimits
UnlimitedFilterLimits explicitly disables every framework filter limit.
func (FilterLimits) MaxBytes ¶
func (limits FilterLimits) MaxBytes() (int, bool)
MaxBytes returns the byte limit and whether it is enabled.
func (FilterLimits) MaxDepth ¶
func (limits FilterLimits) MaxDepth() (int, bool)
MaxDepth returns the depth limit and whether it is enabled.
func (FilterLimits) MaxNodes ¶
func (limits FilterLimits) MaxNodes() (int, bool)
MaxNodes returns the node limit and whether it is enabled.
func (FilterLimits) MaxORTerms ¶
func (limits FilterLimits) MaxORTerms() (int, bool)
MaxORTerms returns the OR term limit and whether it is enabled.
type FilterNode ¶
type FilterNode struct {
// contains filtered or unexported fields
}
func (FilterNode) Children ¶
func (n FilterNode) Children() []FilterNode
Children returns a copy of logical child nodes.
func (FilterNode) Field ¶
func (n FilterNode) Field() (FieldPlan, bool)
Field returns the referenced resource field and whether this node has one.
func (FilterNode) Operator ¶
func (n FilterNode) Operator() FilterOperator
Operator returns the comparison or has operator.
func (FilterNode) Value ¶
func (n FilterNode) Value() FilterValue
Value returns the node's typed literal.
type FilterNodeKind ¶
type FilterNodeKind uint8
FilterNodeKind identifies one immutable filter AST node.
const ( FilterNodeInvalid FilterNodeKind = iota FilterNodeComparison FilterNodeAnd FilterNodeOr FilterNodeHas )
type FilterOperator ¶
type FilterOperator string
FilterOperator is a supported AIP filter operator.
const ( FilterOperatorEqual FilterOperator = "=" FilterOperatorNotEqual FilterOperator = "!=" FilterOperatorLess FilterOperator = "<" FilterOperatorLessEqual FilterOperator = "<=" FilterOperatorGreater FilterOperator = ">" FilterOperatorGreaterEqual FilterOperator = ">=" FilterOperatorHas FilterOperator = ":" )
type FilterValue ¶
type FilterValue struct {
// contains filtered or unexported fields
}
FilterValue is one immutable, descriptor-checked filter literal.
func (FilterValue) BoolValue ¶
func (v FilterValue) BoolValue() (bool, bool)
BoolValue returns a bool literal.
func (FilterValue) DoubleValue ¶
func (v FilterValue) DoubleValue() (float64, bool)
DoubleValue returns a finite floating-point literal.
func (FilterValue) DurationValue ¶
func (v FilterValue) DurationValue() (*durationpb.Duration, bool)
DurationValue returns a copy of a protobuf duration literal.
func (FilterValue) EnumNumber ¶
func (v FilterValue) EnumNumber() (protoreflect.EnumNumber, bool)
EnumNumber returns the descriptor-resolved enum number.
func (FilterValue) EnumSymbol ¶ added in v0.8.6
func (v FilterValue) EnumSymbol() (string, bool)
EnumSymbol returns the descriptor-resolved enum symbol.
func (FilterValue) Int64Value ¶
func (v FilterValue) Int64Value() (int64, bool)
Int64Value returns a signed integer literal.
func (FilterValue) Kind ¶
func (v FilterValue) Kind() FilterValueKind
Kind returns the literal kind.
func (FilterValue) StringMatch ¶ added in v0.8.6
func (v FilterValue) StringMatch() (StringMatch, bool)
StringMatch returns a typed string comparison value.
func (FilterValue) TimestampValue ¶
func (v FilterValue) TimestampValue() (time.Time, bool)
TimestampValue returns a timestamp literal.
func (FilterValue) Uint64Value ¶
func (v FilterValue) Uint64Value() (uint64, bool)
Uint64Value returns an unsigned integer literal.
type FilterValueKind ¶
type FilterValueKind uint8
FilterValueKind identifies a typed filter literal.
const ( FilterValueInvalid FilterValueKind = iota FilterValueNull FilterValueString FilterValueBool FilterValueEnum FilterValueInt64 FilterValueUint64 FilterValueDouble FilterValueTimestamp FilterValueDuration )
type FinalOrder ¶
type FinalOrder struct {
// contains filtered or unexported fields
}
FinalOrder is the immutable complete sort order used by adapters and tokens.
func (FinalOrder) Terms ¶
func (order FinalOrder) Terms() []FinalOrderTerm
Terms returns a copy of the complete order terms.
type FinalOrderTerm ¶
type FinalOrderTerm struct {
// contains filtered or unexported fields
}
FinalOrderTerm contains one resolved backend binding and comparison contract.
func (FinalOrderTerm) Binding ¶
func (term FinalOrderTerm) Binding() OrderBinding
Binding returns the resolved backend-neutral binding.
func (FinalOrderTerm) Direction ¶
func (term FinalOrderTerm) Direction() OrderDirection
Direction returns the final direction.
func (FinalOrderTerm) NullsLast ¶
func (term FinalOrderTerm) NullsLast() bool
NullsLast reports the fixed nullable comparison rule.
type ImmutableComparison ¶
type ImmutableComparison struct {
// contains filtered or unexported fields
}
ImmutableComparison describes one direct or ancestor-selected immutable value comparison.
func (ImmutableComparison) Direct ¶
func (comparison ImmutableComparison) Direct() bool
Direct reports whether the immutable path itself was selected.
func (ImmutableComparison) Path ¶
func (comparison ImmutableComparison) Path() string
Path returns the immutable resource field path.
type ListConfigOption ¶
type ListConfigOption func(*ListSettings) error
ListConfigOption modifies a ListSettings value during construction.
func WithDefaultPageSize ¶
func WithDefaultPageSize(value int32) ListConfigOption
WithDefaultPageSize overrides the default page size.
func WithFilterLimits ¶
func WithFilterLimits(limits FilterLimits) ListConfigOption
WithFilterLimits overrides the resolved filter limits.
func WithMaxPageSize ¶
func WithMaxPageSize(value int32) ListConfigOption
WithMaxPageSize overrides the page-size cap.
func WithOrderLimits ¶
func WithOrderLimits(limits OrderLimits) ListConfigOption
WithOrderLimits overrides the resolved order_by limits.
func WithoutMaxPageSize ¶
func WithoutMaxPageSize() ListConfigOption
WithoutMaxPageSize explicitly disables the page-size cap.
type ListInput ¶
type ListInput struct {
Collection string
PageSize int32
PageToken string
Skip int64
Filter string
OrderBy string
IncludeTotal bool
}
ListInput contains standard List request fields before parsing.
type ListOptions ¶
type ListOptions struct {
ShowDeleted bool
}
ListOptions contains normalized AIP list controls without business behavior.
type ListPreparer ¶
type ListPreparer struct {
// contains filtered or unexported fields
}
func NewListPreparer ¶
func NewListPreparer(options ...ListPreparerOption) (*ListPreparer, error)
NewListPreparer constructs an immutable preparer and validates every config.
func (*ListPreparer) PrepareList ¶
func (preparer *ListPreparer) PrepareList(resource ListResource, input ListInput) (ListQuery, error)
PrepareList applies resolved base pagination settings and parses a typed filter.
func (*ListPreparer) SettingsFor ¶
func (preparer *ListPreparer) SettingsFor(resourceType string) ListSettings
SettingsFor resolves resource overrides over application and framework defaults.
type ListPreparerOption ¶
type ListPreparerOption func(*listPreparerBuilder) error
ListPreparerOption configures a ListPreparer during construction.
func WithApplicationDefaults ¶
func WithApplicationDefaults(options ...ListConfigOption) ListPreparerOption
WithApplicationDefaults applies overrides above the framework defaults.
func WithPageTokenCodec ¶
func WithPageTokenCodec(codec PageTokenCodec) ListPreparerOption
WithPageTokenCodec replaces the default unsigned page-token transport.
func WithResourceOverrides ¶
func WithResourceOverrides(resourceType string, options ...ListConfigOption) ListPreparerOption
WithResourceOverrides applies the highest-priority overrides for a resource.
type ListQuery ¶
type ListQuery struct {
// contains filtered or unexported fields
}
func (ListQuery) Collection ¶
Collection returns the normalized collection target input.
func (ListQuery) EncodePageToken ¶
func (query ListQuery) EncodePageToken( fingerprint [sha256.Size]byte, cursor []*crudpb.CursorValue, ) (string, error)
EncodePageToken serializes a continuation cursor with the same codec used by PrepareList.
func (ListQuery) Filter ¶
func (query ListQuery) Filter() FilterExpression
Filter returns the parsed backend-neutral filter.
func (ListQuery) IncludeTotal ¶
IncludeTotal reports whether Count was requested.
func (ListQuery) OrderBy ¶
func (query ListQuery) OrderBy() OrderExpression
OrderBy returns the parsed client order expression.
func (ListQuery) PageTokenPayload ¶
func (query ListQuery) PageTokenPayload() *crudpb.PageTokenPayload
PageTokenPayload returns a clone of the decoded payload, or nil when no token was supplied.
func (ListQuery) ResourceType ¶
ResourceType returns the resource type associated with the query.
type ListResource ¶
type ListResource interface {
ResourceType() string
}
ListResource identifies one resource plan or generated query contract.
type ListResult ¶
type ListResult[T any] struct { // contains filtered or unexported fields }
ListResult is one immutable adapter result with optional total-size presence.
func NewListResult ¶
func NewListResult[T any]( query ListQuery, items []T, nextPageToken string, totalSize *int64, ) (ListResult[T], error)
NewListResult enforces include_total and total_size presence as one contract.
func (ListResult[T]) Items ¶
func (result ListResult[T]) Items() []T
Items returns a copy of the page items and clones protobuf messages.
func (ListResult[T]) NextPageToken ¶
func (result ListResult[T]) NextPageToken() string
NextPageToken returns the opaque continuation token, or empty on the last page.
func (ListResult[T]) TotalSize ¶
func (result ListResult[T]) TotalSize() (int64, bool)
TotalSize returns the count and its explicit presence.
type ListSettings ¶
type ListSettings struct {
// contains filtered or unexported fields
}
ListSettings is an immutable resolved list configuration.
func (ListSettings) DefaultPageSize ¶
func (settings ListSettings) DefaultPageSize() int32
DefaultPageSize returns the page size used when the request uses zero.
func (ListSettings) FilterLimits ¶
func (settings ListSettings) FilterLimits() FilterLimits
FilterLimits returns the resolved filter limits.
func (ListSettings) MaxPageSize ¶
func (settings ListSettings) MaxPageSize() (int32, bool)
MaxPageSize returns the page-size cap and whether it is enabled.
func (ListSettings) OrderLimits ¶
func (settings ListSettings) OrderLimits() OrderLimits
OrderLimits returns the resolved order_by limits.
type LogicalType ¶
type LogicalType string
LogicalType identifies the canonical Proto comparison and cursor type.
const ( LogicalString LogicalType = "string" LogicalBool LogicalType = "bool" LogicalEnum LogicalType = "enum" LogicalInt32 LogicalType = "int32" LogicalInt64 LogicalType = "int64" LogicalUint32 LogicalType = "uint32" LogicalUint64 LogicalType = "uint64" LogicalFloat32 LogicalType = "float32" LogicalFloat64 LogicalType = "float64" LogicalBytes LogicalType = "bytes" LogicalTimestamp LogicalType = "timestamp" LogicalDuration LogicalType = "duration" )
type OrderAssembler ¶
type OrderAssembler struct {
// contains filtered or unexported fields
}
OrderAssembler resolves client order terms and appends a complete unique cursor key.
func NewOrderAssembler ¶
func NewOrderAssembler( resolver OrderBindingResolver, defaults []ConfiguredOrderTerm, cursorKeys []ConfiguredOrderTerm, ) (*OrderAssembler, error)
NewOrderAssembler validates immutable repository order configuration.
func (*OrderAssembler) Resolve ¶
func (assembler *OrderAssembler) Resolve(client OrderExpression) (FinalOrder, error)
Resolve applies client order or the repository default, then appends missing cursor-key terms.
type OrderBinding ¶
type OrderBinding struct {
// contains filtered or unexported fields
}
OrderBinding identifies one stable backend sort key without exposing backend APIs.
func NewOrderBinding ¶
func NewOrderBinding(key, fieldPath string, nullable bool, profileID string) (OrderBinding, error)
NewOrderBinding constructs one immutable backend-neutral order binding.
func NewTypedOrderBinding ¶
func NewTypedOrderBinding( key, fieldPath string, nullable bool, profileID string, logicalType LogicalType, ) (OrderBinding, error)
NewTypedOrderBinding constructs one immutable binding with an explicit cursor logical type.
func (OrderBinding) FieldPath ¶
func (binding OrderBinding) FieldPath() string
FieldPath returns the public resource field path, or empty for an internal key.
func (OrderBinding) Key ¶
func (binding OrderBinding) Key() string
Key returns the adapter-local stable binding identity.
func (OrderBinding) LogicalType ¶
func (binding OrderBinding) LogicalType() LogicalType
LogicalType returns the canonical cursor type.
func (OrderBinding) Nullable ¶
func (binding OrderBinding) Nullable() bool
Nullable reports whether the backend value can be NULL.
func (OrderBinding) ProfileID ¶
func (binding OrderBinding) ProfileID() string
ProfileID returns the stable, versioned comparison profile identifier.
type OrderBindingResolver ¶
type OrderBindingResolver interface {
ResolveOrderBinding(FieldPlan) (OrderBinding, bool)
}
OrderBindingResolver maps public resource fields to backend sort bindings.
type OrderDirection ¶
type OrderDirection uint8
OrderDirection identifies ascending or descending sort order.
const ( OrderAscending OrderDirection = iota OrderDescending )
type OrderExpression ¶
type OrderExpression struct {
// contains filtered or unexported fields
}
OrderExpression is an immutable normalized client order_by expression.
func (OrderExpression) Empty ¶
func (order OrderExpression) Empty() bool
Empty reports whether the client omitted order_by.
func (OrderExpression) String ¶
func (order OrderExpression) String() string
String returns canonical AIP-132 text. Ascending directions are omitted.
func (OrderExpression) TermCount ¶
func (order OrderExpression) TermCount() int
TermCount returns the number of client order terms.
func (OrderExpression) Terms ¶
func (order OrderExpression) Terms() []OrderTerm
Terms returns a copy of the client order terms.
type OrderLimitOption ¶
type OrderLimitOption func(*OrderLimits) error
OrderLimitOption configures OrderLimits during construction.
func MaxOrderBytes ¶
func MaxOrderBytes(value int) OrderLimitOption
MaxOrderBytes sets the maximum UTF-8 byte length of order_by.
func MaxOrderTerms ¶
func MaxOrderTerms(value int) OrderLimitOption
MaxOrderTerms sets the maximum client order term count.
func WithoutMaxOrderBytes ¶
func WithoutMaxOrderBytes() OrderLimitOption
WithoutMaxOrderBytes explicitly disables the order_by byte limit.
func WithoutMaxOrderTerms ¶
func WithoutMaxOrderTerms() OrderLimitOption
WithoutMaxOrderTerms explicitly disables the order_by term limit.
type OrderLimits ¶
type OrderLimits struct {
// contains filtered or unexported fields
}
OrderLimits contains immutable order_by input limits.
func DefaultOrderLimits ¶
func DefaultOrderLimits() OrderLimits
DefaultOrderLimits returns the framework order_by limits.
func NewOrderLimits ¶
func NewOrderLimits(options ...OrderLimitOption) (OrderLimits, error)
NewOrderLimits returns order limits initialized from framework defaults.
func UnlimitedOrderLimits ¶
func UnlimitedOrderLimits() OrderLimits
UnlimitedOrderLimits explicitly disables every framework order_by limit.
func (OrderLimits) MaxBytes ¶
func (limits OrderLimits) MaxBytes() (int, bool)
MaxBytes returns the byte limit and whether it is enabled.
func (OrderLimits) MaxTerms ¶
func (limits OrderLimits) MaxTerms() (int, bool)
MaxTerms returns the term limit and whether it is enabled.
type OrderTerm ¶
type OrderTerm struct {
// contains filtered or unexported fields
}
OrderTerm is one descriptor-resolved order expression term.
func (OrderTerm) Direction ¶
func (term OrderTerm) Direction() OrderDirection
Direction returns the term direction.
type PageTokenCodec ¶
type PageTokenCodec interface {
Encode(*crudpb.PageTokenPayload) (string, error)
Decode(string) (*crudpb.PageTokenPayload, error)
}
PageTokenCodec is the replaceable opaque transport for the fixed PageTokenPayload.
type PreparedCreate ¶
PreparedCreate contains a filtered resource safe to pass beyond the service boundary.
func (PreparedCreate[R]) Resource ¶
func (prepared PreparedCreate[R]) Resource() R
Resource returns a clone of the filtered create resource.
type PreparedUpdate ¶
PreparedUpdate contains filtered mutable values, a leaf WriteMask, immutable comparisons and options.
func (PreparedUpdate[R]) ImmutableComparisons ¶
func (prepared PreparedUpdate[R]) ImmutableComparisons() []ImmutableComparison
ImmutableComparisons returns immutable compare metadata without mutable value aliases.
func (PreparedUpdate[R]) Options ¶
func (prepared PreparedUpdate[R]) Options() UpdateOptions
Options returns normalized AIP options. Their business semantics remain in biz.
func (PreparedUpdate[R]) Resource ¶
func (prepared PreparedUpdate[R]) Resource() R
Resource returns a clone containing only mutable values selected by WriteMask.
func (PreparedUpdate[R]) ValidateImmutable ¶
func (prepared PreparedUpdate[R]) ValidateImmutable(current R) error
ValidateImmutable compares prepared immutable intentions against the current resource.
func (PreparedUpdate[R]) WriteMask ¶
func (prepared PreparedUpdate[R]) WriteMask() *fieldmaskpb.FieldMask
WriteMask returns a clone of the normalized mutable leaf mask.
type ResourceName ¶
type ResourceName struct {
// contains filtered or unexported fields
}
ResourceName contains one matched pattern and its variable values.
func (ResourceName) Pattern ¶
func (name ResourceName) Pattern() string
Pattern returns the matched declared pattern.
func (ResourceName) Variable ¶
func (name ResourceName) Variable(variable string) (string, bool)
Variable returns one matched variable value.
func (ResourceName) Variables ¶
func (name ResourceName) Variables() map[string]string
Variables returns a copy of the matched variable values.
type ResourceNameMatcher ¶
type ResourceNameMatcher struct {
// contains filtered or unexported fields
}
ResourceNameMatcher parses and formats one resource type's declared patterns.
func NewResourceNameMatcher ¶
func NewResourceNameMatcher(patterns ...string) (*ResourceNameMatcher, error)
NewResourceNameMatcher validates and compiles resource patterns once.
func (*ResourceNameMatcher) Format ¶
func (matcher *ResourceNameMatcher) Format(pattern string, variables map[string]string) (string, error)
Format builds a canonical, unescaped relative resource name.
func (*ResourceNameMatcher) Parse ¶
func (matcher *ResourceNameMatcher) Parse(value string) (ResourceName, error)
Parse matches a canonical, unescaped relative resource name.
type ResourcePlan ¶
ResourcePlan is the immutable runtime description of one AIP resource.
func MustBuildResourcePlan ¶
func MustBuildResourcePlan[R proto.Message](descriptor protoreflect.MessageDescriptor) *ResourcePlan[R]
MustBuildResourcePlan builds an immutable resource plan or panics on an invalid descriptor or generic resource type.
func (*ResourcePlan[R]) Descriptor ¶
func (p *ResourcePlan[R]) Descriptor() protoreflect.MessageDescriptor
Descriptor returns the resource message descriptor.
func (*ResourcePlan[R]) Field ¶
func (p *ResourcePlan[R]) Field(path string) (FieldPlan, bool)
Field returns the plan for a canonical protobuf snake_case field path.
func (*ResourcePlan[R]) Identifier ¶
func (p *ResourcePlan[R]) Identifier() protoreflect.FieldDescriptor
Identifier returns the unique IDENTIFIER field descriptor.
func (*ResourcePlan[R]) NormalizeWriteMask ¶
func (plan *ResourcePlan[R]) NormalizeWriteMask(resource R, mask *fieldmaskpb.FieldMask) (WriteMask, error)
NormalizeWriteMask validates explicit FieldMask paths or derives an implicit top-level mask.
func (*ResourcePlan[R]) ParseName ¶
func (p *ResourcePlan[R]) ParseName(value string) (ResourceName, error)
ParseName validates a canonical resource name against the plan patterns.
func (*ResourcePlan[R]) Patterns ¶
func (p *ResourcePlan[R]) Patterns() []string
Patterns returns a copy of the declared google.api.resource patterns.
func (*ResourcePlan[R]) PrepareCreate ¶
func (plan *ResourcePlan[R]) PrepareCreate(resource R) (PreparedCreate[R], error)
PrepareCreate validates REQUIRED input and removes IDENTIFIER/OUTPUT_ONLY fields.
func (*ResourcePlan[R]) PrepareUpdate ¶
func (plan *ResourcePlan[R]) PrepareUpdate( resource R, mask *fieldmaskpb.FieldMask, options UpdateOptions, ) (PreparedUpdate[R], error)
PrepareUpdate normalizes FieldMask, lifecycle partitions and immutable compare intents.
func (*ResourcePlan[R]) QueryablePaths ¶
func (p *ResourcePlan[R]) QueryablePaths() []string
QueryablePaths returns non-identifier, non-input-only paths in canonical sorted order.
func (*ResourcePlan[R]) ResourceType ¶
func (p *ResourcePlan[R]) ResourceType() string
ResourceType returns the google.api.resource type.
func (*ResourcePlan[R]) ToResponse ¶
func (plan *ResourcePlan[R]) ToResponse(resource R) (R, error)
ToResponse validates canonical identity, clones the resource and removes INPUT_ONLY fields.
func (*ResourcePlan[R]) ToResponses ¶
func (plan *ResourcePlan[R]) ToResponses(resources []R) ([]R, error)
ToResponses applies ToResponse to every item and fails on nil or invalid entries.
func (*ResourcePlan[R]) WritablePaths ¶
func (p *ResourcePlan[R]) WritablePaths() []string
WritablePaths returns mutable client-input paths in canonical sorted order.
type StringMatch ¶ added in v0.8.6
type StringMatch struct {
// contains filtered or unexported fields
}
StringMatch is one immutable normalized string comparison value.
func (StringMatch) Kind ¶ added in v0.8.6
func (match StringMatch) Kind() StringMatchKind
Kind returns the normalized string comparison mode.
func (StringMatch) Literal ¶ added in v0.8.6
func (match StringMatch) Literal() string
Literal returns the string after wildcard markers have been removed.
type StringMatchKind ¶ added in v0.8.6
type StringMatchKind uint8
StringMatchKind identifies one normalized string comparison mode.
const ( StringMatchInvalid StringMatchKind = iota StringMatchExact StringMatchPrefix StringMatchSuffix StringMatchContains )
type UnsignedPageTokenCodec ¶
type UnsignedPageTokenCodec struct{}
UnsignedPageTokenCodec uses deterministic Proto binary and unpadded Base64URL. It intentionally provides no integrity or confidentiality.
func NewUnsignedPageTokenCodec ¶
func NewUnsignedPageTokenCodec() UnsignedPageTokenCodec
NewUnsignedPageTokenCodec returns the framework default codec.
func (UnsignedPageTokenCodec) Decode ¶
func (UnsignedPageTokenCodec) Decode(token string) (*crudpb.PageTokenPayload, error)
Decode parses one unpadded Base64URL token and rejects unsupported versions.
func (UnsignedPageTokenCodec) Encode ¶
func (UnsignedPageTokenCodec) Encode(payload *crudpb.PageTokenPayload) (string, error)
Encode serializes one supported payload deterministically.
type UpdateOptions ¶
UpdateOptions contains normalized AIP update controls without business behavior.
type WriteMask ¶
type WriteMask struct {
// contains filtered or unexported fields
}
WriteMask is an immutable normalized update path selection.
func (WriteMask) Fields ¶
Fields returns descriptor-resolved selected fields. Wildcard expansion occurs during lifecycle planning.
func (WriteMask) Implicit ¶
Implicit reports whether update_mask was omitted and derived from resource presence.