module documentation

Field mask utilities for partial updates and reset masks.

This module provides small, composable helpers for building, merging, and serializing field masks used by the Nebius API. Masks are represented as a tree of fields and can be serialized into the dotted syntax accepted by gRPC metadata (for example, via the X-ResetMask header).

Basic usage

Create a simple mask by hand and serialize it:

from nebius.base.fieldmask import FieldPath, Mask

path = FieldPath(["spec", "max_size_bytes"])
mask = path.to_mask()
serialized = mask.marshal()
# serialized == "spec.max_size_bytes"

Merge masks:

mask = FieldPath(["spec", "max_size_bytes"]).to_mask()
mask += FieldPath(["spec", "versioning"]).to_mask()
# mask.marshal() == "spec.max_size_bytes,spec.versioning"

Use in request metadata (reset a field to its default):

from nebius.base.metadata import Metadata

md = Metadata()
md["X-ResetMask"] = "spec.max_size_bytes"
# ... pass md into a request as metadata

Notes

  • The internal mask format supports wildcards and nesting. Not all masks are representable as a single field path.
  • Masks are more granular than standard Google field masks and are not directly compatible.
Class FieldKey Field key component used in paths and mask trees.
Class FieldPath Ordered path of FieldKey components.
Class Mask Tree representation of a field mask.
Exception Error Base error for field mask operations.
Exception MarshalError Raised when parsing or serializing field mask strings fails.
Variable _simple_string_pattern Undocumented
_simple_string_pattern = (source) ΒΆ

Undocumented