Skip to content

v1alpha8

frequenz.client.common.streaming.proto.v1alpha8 ¤

Conversion of Event from/to protobuf v1alpha8.

Functions¤

frequenz.client.common.streaming.proto.v1alpha8.event_from_proto ¤

event_from_proto(message: ValueType) -> Event | int

Convert a protobuf Event enum value to an Event enum member.

PARAMETER DESCRIPTION
message

A protobuf Event enum value.

TYPE: ValueType

RETURNS DESCRIPTION
Event | int

The corresponding Event enum member, or the raw int if the protobuf value is not recognized.

Source code in src/frequenz/client/common/streaming/proto/v1alpha8/_event.py
def event_from_proto(message: event_pb2.Event.ValueType) -> Event | int:
    """Convert a protobuf Event enum value to an Event enum member.

    Args:
        message: A protobuf Event enum value.

    Returns:
        The corresponding Event enum member, or the raw `int` if the protobuf value
            is not recognized.
    """
    return enum_from_proto(message, Event)

frequenz.client.common.streaming.proto.v1alpha8.event_to_proto ¤

event_to_proto(event: Event) -> ValueType

Convert an Event enum member to a protobuf Event enum value.

PARAMETER DESCRIPTION
event

An Event enum member.

TYPE: Event

RETURNS DESCRIPTION
ValueType

The corresponding protobuf Event enum value.

Source code in src/frequenz/client/common/streaming/proto/v1alpha8/_event.py
def event_to_proto(event: Event) -> event_pb2.Event.ValueType:
    """Convert an Event enum member to a protobuf Event enum value.

    Args:
        event: An Event enum member.

    Returns:
        The corresponding protobuf Event enum value.
    """
    return event_pb2.Event.ValueType(event.value)