class documentation

Base wrapper for protobuf message instances.

Provides Pythonic accessors, reset-mask tracking, and sensitive-field handling around a generated protobuf message object.

Parameters
initial_messageOptional protobuf message to wrap.
Class Method get_descriptor Return the protobuf descriptor for this message class.
Class Method is_credentials Return True if the field contains credentials.
Class Method is_sensitive Return True if the field is marked as sensitive.
Method __init__ Create a wrapper around a protobuf message instance.
Method __repr__ Return a representation of the message with sensitive fields sanitized.
Method check_presence Check explicit presence for a field in the protobuf message.
Method get_full_update_reset_mask Build a reset mask for a full update of this message.
Method get_mask Return the tracked reset mask.
Method is_default Return True if a field equals its default value.
Method set_mask Replace the tracked reset mask.
Method which_field_in_oneof Return the set field name for a given oneof.
Class Variable __mask_functions__ Undocumented
Instance Variable __PB2_CLASS__ Protobuf message class associated with this wrapper.
Instance Variable __PB2_DESCRIPTOR__ Protobuf descriptor or descriptor wrapper for this message.
Instance Variable __pb2_message__ Underlying protobuf message instance.
Instance Variable __PY_TO_PB2__ Mapping of Pythonic field names to protobuf field names.
Method _clear_field Clear a field and record it in the reset mask.
Method _get_field Return a field value with optional wrapping and presence handling.
Method _set_field Set a field value and update the reset mask.
Class Variable __credentials_fields Undocumented
Class Variable __default Undocumented
Class Variable __sensitive_fields Undocumented
Instance Variable __recorded_reset_mask Mask tracking fields cleared or set to default.
@classmethod
def get_descriptor(cls) -> Descriptor: (source)

Return the protobuf descriptor for this message class.

Returns
DescriptorProtobuf Descriptor.
Raises
ValueErrorIf the descriptor is not configured.
@classmethod
def is_credentials(cls, field_name: str) -> bool: (source)

Return True if the field contains credentials.

Parameters
field_name:strPythonic field name.
Returns
boolTrue if the field should be sanitized.
@classmethod
def is_sensitive(cls, field_name: str) -> bool: (source)

Return True if the field is marked as sensitive.

Parameters
field_name:strPythonic field name.
Returns
boolTrue if the field is sensitive.
def __init__(self, initial_message: PMessage | None): (source)

Create a wrapper around a protobuf message instance.

Raises
AttributeErrorIf the wrapper is missing required class metadata.
def __repr__(self) -> str: (source)

Return a representation of the message with sensitive fields sanitized.

def check_presence(self, name: str) -> bool: (source)

Check explicit presence for a field in the protobuf message.

Parameters
name:strPythonic field name.
Returns
boolTrue if the field is present.
def get_full_update_reset_mask(self) -> Mask: (source)

Build a reset mask for a full update of this message.

Returns
MaskMask covering all non-default fields and nested masks.
def get_mask(self) -> Mask: (source)

Return the tracked reset mask.

def is_default(self, pythonic_name: str) -> bool: (source)

Return True if a field equals its default value.

Parameters
pythonic_name:strPythonic field name.
Returns
boolTrue if the field equals the default instance.
def set_mask(self, new_mask: Mask): (source)

Replace the tracked reset mask.

Parameters
new_mask:MaskNew mask to store.
def which_field_in_oneof(self, pb2_name: str) -> str | None: (source)

Return the set field name for a given oneof.

Parameters
pb2_name:strProtobuf oneof name.
Returns
str | NoneName of the set field or None.
__mask_functions__: dict[str, MaskFunction] = (source)

Undocumented

__PB2_CLASS__: type[PMessage] = (source)

Protobuf message class associated with this wrapper.

__PB2_DESCRIPTOR__: DescriptorWrap[Descriptor] | Descriptor = (source)

Protobuf descriptor or descriptor wrapper for this message.

__pb2_message__ = (source)

Underlying protobuf message instance.

__PY_TO_PB2__: dict[str, str] = (source)

Mapping of Pythonic field names to protobuf field names.

def _clear_field(self, name: str): (source)

Clear a field and record it in the reset mask.

Parameters
name:strPythonic field name.
def _get_field(self, name: str, explicit_presence: bool = False, wrap: Callable[[Any], Any] | None = None) -> Any: (source)

Return a field value with optional wrapping and presence handling.

Parameters
name:strPythonic field name.
explicit_presence:boolWhen true, return None if unset.
wrap:Callable[[Any], Any] | NoneOptional wrapper for the raw value.
Returns
AnyField value or None when not present.
def _set_field(self, name: str, value: Any, unwrap: Callable[[Any], Any] | None = None, explicit_presence: bool = False): (source)

Set a field value and update the reset mask.

Parameters
name:strPythonic field name.
value:AnyValue to assign, None to clear.
unwrap:Callable[[Any], Any] | NoneOptional unwrapping function for leaf values.
explicit_presence:boolWhen true, do not treat defaults as clears.
__credentials_fields = (source)

Undocumented

Undocumented

__sensitive_fields = (source)

Undocumented

__recorded_reset_mask = (source)

Mask tracking fields cleared or set to default.