diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7ff3499..adb695b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -11,7 +11,7 @@ This release introduces the `v1alpha8` module to support a new API version. ## New Features - Provide access to new API using new `v1alpha8` module. - +- Mapping for the new `Event` message has been added. ## Bug Fixes diff --git a/src/frequenz/client/common/v1alpha8/streaming/__init__.py b/src/frequenz/client/common/v1alpha8/streaming/__init__.py new file mode 100644 index 0000000..263697d --- /dev/null +++ b/src/frequenz/client/common/v1alpha8/streaming/__init__.py @@ -0,0 +1,26 @@ +# License: MIT +# Copyright © 2025 Frequenz Energy-as-a-Service GmbH + +"""Type wrappers for the generated protobuf messages.""" + + +from enum import Enum + +# pylint: disable-next=no-name-in-module +from frequenz.api.common.v1alpha8.streaming import event_pb2 as PBEvent + + +class Event(Enum): + """Enum representing the type of streaming event.""" + + EVENT_UNSPECIFIED = PBEvent.EVENT_UNSPECIFIED + """Unspecified event type.""" + + EVENT_CREATED = PBEvent.EVENT_CREATED + """Event when a new resource is created.""" + + EVENT_UPDATED = PBEvent.EVENT_UPDATED + """Event when an existing resource is updated.""" + + EVENT_DELETED = PBEvent.EVENT_DELETED + """Event when a resource is deleted.""" diff --git a/tests/test_streaming.py b/tests/test_streaming.py new file mode 100644 index 0000000..4075772 --- /dev/null +++ b/tests/test_streaming.py @@ -0,0 +1,13 @@ +# License: MIT +# Copyright © 2025 Frequenz Energy-as-a-Service GmbH + +"""Tests for the frequenz.client.common.v1alpha8.streaming package.""" + +from frequenz.client.common.enum_proto import enum_from_proto +from frequenz.client.common.v1alpha8.streaming import Event + + +def test_event_enum() -> None: + """Test the Event enum.""" + for event in Event: + assert enum_from_proto(event.value, Event) == event