Skip to content

Commit c502499

Browse files
committed
Add streaming.Event bindings
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent fb3ff4c commit c502499

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This release introduces the `v1alpha8` module to support a new API version.
1111
## New Features
1212

1313
- Provide access to new API using new `v1alpha8` module.
14-
<!-- Here goes the main new features and examples or instructions on how to use them -->
14+
- Mapping for the new `Event` message has been added.
1515

1616
## Bug Fixes
1717

src/frequenz/client/common/v1alpha8/microgrid/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# License: MIT
2-
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
2+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
33

44
"""Frequenz microgrid definition."""
55

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# License: MIT
2+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Type wrappers for the generated protobuf messages."""
5+
6+
7+
from enum import Enum
8+
9+
# pylint: disable-next=no-name-in-module
10+
from frequenz.api.common.v1alpha8.streaming import event_pb2 as PBEvent
11+
12+
13+
class Event(Enum):
14+
"""Enum representing the type of streaming event."""
15+
16+
EVENT_UNSPECIFIED = PBEvent.EVENT_UNSPECIFIED
17+
"""Unspecified event type."""
18+
19+
EVENT_CREATED = PBEvent.EVENT_CREATED
20+
"""Event when a new resource is created."""
21+
22+
EVENT_UPDATED = PBEvent.EVENT_UPDATED
23+
"""Event when an existing resource is updated."""
24+
25+
EVENT_DELETED = PBEvent.EVENT_DELETED
26+
"""Event when a resource is deleted."""

tests/test_streaming.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# License: MIT
2+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Tests for the frequenz.client.common.v1alpha8.streaming package."""
5+
6+
from frequenz.client.common.enum_proto import enum_from_proto
7+
from frequenz.client.common.v1alpha8.streaming import Event
8+
9+
10+
def test_event_enum() -> None:
11+
"""Test the Event enum."""
12+
for event in Event:
13+
assert enum_from_proto(event.value, Event) == event

0 commit comments

Comments
 (0)