class documentation
Tree representation of a field mask.
A mask contains named field parts and an optional wildcard branch (any). Masks can be merged, intersected, or subtracted to build more complex partial update expressions.
Example
Build a mask with a wildcard and a specific field:
mask = Mask(any=FieldPath(["spec"]).to_mask()) mask += FieldPath(["labels"]).to_mask() serialized = mask.marshal()
| Parameters | |
| any | Wildcard sub-mask or None. |
| field | Mapping of field names to nested masks. |
| Raises | |
ValueError | If inputs are not valid mask structures. |
| Class Method | unmarshal |
Parse a marshaled mask string into a Mask. |
| Method | __add__ |
Return a merged copy of this mask and another. |
| Method | __and__ |
Alias for intersect_reset_mask. |
| Method | __eq__ |
Return True when another mask is structurally equal. |
| Method | __iadd__ |
Merge another mask or field path into this mask. |
| Method | __imul__ |
In-place simple intersection with another mask. |
| Method | __init__ |
Create a mask from an optional wildcard and field mapping. |
| Method | __isub__ |
In-place reset-mask subtraction. |
| Method | __itruediv__ |
In-place simple subtraction from another mask. |
| Method | __mul__ |
Return a copy intersected with another mask. |
| Method | __repr__ |
Return a debug representation of the mask. |
| Method | __sub__ |
Return a copy with reset-mask subtraction applied. |
| Method | __truediv__ |
Return a copy with simple subtraction applied. |
| Method | copy |
Return a deep copy of the mask tree. |
| Method | intersect |
Return a simple intersection (no wildcard promotion). |
| Method | intersect |
Return the reset-mask intersection with another mask. |
| Method | is |
Return True if the mask has no wildcard and no field parts. |
| Method | is |
Return True if the mask can be represented as a single path. |
| Method | marshal |
Serialize the mask to a string. |
| Method | sub |
Return a sub-mask for the provided field path or key. |
| Method | subtract |
Remove paths from the mask without wildcard promotion. |
| Method | subtract |
Remove paths using reset-mask semantics. |
| Method | to |
Convert a single-path mask to a FieldPath. |
| Instance Variable | any |
Wildcard sub-mask or None. |
| Instance Variable | field |
Mapping of field names to nested masks. |
| Method | _marshal |
Return a tuple of (segment count, marshaled string). |
In-place simple intersection with another mask.
| Parameters | |
other:Mask | Mask to intersect with. |
| Returns | |
Mask | This mask instance. |
| Raises | |
ValueError | If other is not a Mask. |
def __init__(self, any:
Mask | None = None, field_parts: Mapping[ FieldKey | str, Mask] | None = None):
(source)
¶
Create a mask from an optional wildcard and field mapping.
In-place simple subtraction from another mask.
| Parameters | |
other:Mask | Mask to subtract. |
| Returns | |
Mask | This mask instance. |
| Raises | |
ValueError | If other is not a Mask. |
Return True if the mask has no wildcard and no field parts.
| Returns | |
bool | True if empty, otherwise False. |