From 7ea9b6a6466b0183adec4800f0fc3ffb73e3d0a8 Mon Sep 17 00:00:00 2001 From: "Mathias L. Baumann" Date: Fri, 28 Aug 2026 11:29:04 +0200 Subject: [PATCH] Use common API credentials in examples Signed-off-by: Mathias L. Baumann --- README.md | 8 ++++---- RELEASE_NOTES.md | 2 ++ src/frequenz/dispatch/_actor_dispatcher.py | 4 ++-- src/frequenz/dispatch/_dispatcher.py | 16 ++++++++-------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a56ce041..873ec03d 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ from frequenz.dispatch import Created, Deleted, Dispatcher, Updated async def main() -> None: url = os.getenv("DISPATCH_API_URL", "grpc://localhost:50051") - auth_key = os.getenv("DISPATCH_API_AUTH_KEY", "my-api-key") - sign_secret = os.getenv("DISPATCH_API_SIGN_SECRET") + auth_key = os.getenv("FREQUENZ_API_KEY", "my-api-key") + sign_secret = os.getenv("FREQUENZ_API_SECRET") microgrid_id = 1 async with Dispatcher( @@ -118,8 +118,8 @@ async def run() -> None: url = os.getenv( "DISPATCH_API_URL", "grpc://dispatch.api.example.com:50051" ) - auth_key = os.getenv("DISPATCH_API_AUTH_KEY", "my-api-key") - sign_secret = os.getenv("DISPATCH_API_SIGN_SECRET") + auth_key = os.getenv("FREQUENZ_API_KEY", "my-api-key") + sign_secret = os.getenv("FREQUENZ_API_SECRET") microgrid_id = 1 diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4b13f7de..61f8c169 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -8,6 +8,8 @@ +- Credential examples now use `FREQUENZ_API_KEY` and `FREQUENZ_API_SECRET`. + ## New Features diff --git a/src/frequenz/dispatch/_actor_dispatcher.py b/src/frequenz/dispatch/_actor_dispatcher.py index cb79d636..a06b2237 100644 --- a/src/frequenz/dispatch/_actor_dispatcher.py +++ b/src/frequenz/dispatch/_actor_dispatcher.py @@ -183,8 +183,8 @@ def _update_dispatch_information(self, dispatch_update: DispatchInfo) -> None: async def main(): url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com") - auth_key = os.getenv("DISPATCH_API_AUTH_KEY", "some-key") - sign_secret = os.getenv("DISPATCH_API_SIGN_SECRET") + auth_key = os.getenv("FREQUENZ_API_KEY", "some-key") + sign_secret = os.getenv("FREQUENZ_API_SECRET") microgrid_id = 1 diff --git a/src/frequenz/dispatch/_dispatcher.py b/src/frequenz/dispatch/_dispatcher.py index c49b843c..e982c70e 100644 --- a/src/frequenz/dispatch/_dispatcher.py +++ b/src/frequenz/dispatch/_dispatcher.py @@ -61,14 +61,14 @@ async def create_actor(dispatch: DispatchInfo, receiver: Receiver[DispatchInfo]) async def run(): url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com") - key = os.getenv("DISPATCH_API_KEY", "some-key") + auth_key = os.getenv("FREQUENZ_API_KEY", "some-key") microgrid_id = 1 async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key + auth_key=auth_key ) as dispatcher: await dispatcher.start_managing( dispatch_type="DISPATCH_TYPE", @@ -87,14 +87,14 @@ async def run(): async def run(): url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com") - key = os.getenv("DISPATCH_API_KEY", "some-key") + auth_key = os.getenv("FREQUENZ_API_KEY", "some-key") microgrid_id = 1 async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key + auth_key=auth_key ) as dispatcher: actor = MagicMock() # replace with your actor @@ -132,14 +132,14 @@ async def run(): async def run(): url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com") - key = os.getenv("DISPATCH_API_KEY", "some-key") + auth_key = os.getenv("FREQUENZ_API_KEY", "some-key") microgrid_id = 1 async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key, + auth_key=auth_key, ) as dispatcher: events_receiver = dispatcher.new_lifecycle_events_receiver("DISPATCH_TYPE") @@ -169,14 +169,14 @@ async def run(): async def run(): url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com") - key = os.getenv("DISPATCH_API_KEY", "some-key") + auth_key = os.getenv("FREQUENZ_API_KEY", "some-key") microgrid_id = 1 async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key, + auth_key=auth_key, ) as dispatcher: # Create a new dispatch new_dispatch = await dispatcher.client.create(