diff --git a/src/frequenz/dispatch/_actor_dispatcher.py b/src/frequenz/dispatch/_actor_dispatcher.py index 4419b5e..5366936 100644 --- a/src/frequenz/dispatch/_actor_dispatcher.py +++ b/src/frequenz/dispatch/_actor_dispatcher.py @@ -181,7 +181,7 @@ 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") + key = os.getenv("DISPATCH_API_KEY", "some-key") sign_secret = os.getenv("DISPATCH_API_SIGN_SECRET") microgrid_id = 1 @@ -189,7 +189,7 @@ async def main(): async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=auth_key, + key=key, sign_secret=sign_secret, ) as dispatcher: status_receiver = dispatcher.new_running_state_event_receiver("EXAMPLE_TYPE") diff --git a/src/frequenz/dispatch/_dispatcher.py b/src/frequenz/dispatch/_dispatcher.py index d7a793e..f0198e2 100644 --- a/src/frequenz/dispatch/_dispatcher.py +++ b/src/frequenz/dispatch/_dispatcher.py @@ -65,7 +65,7 @@ async def run(): async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key + key=key ) as dispatcher: dispatcher.start_managing( dispatch_type="DISPATCH_TYPE", @@ -91,7 +91,7 @@ async def run(): async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key + key=key ) as dispatcher: actor = MagicMock() # replace with your actor @@ -136,7 +136,7 @@ async def run(): async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key, + key=key, ) as dispatcher: events_receiver = dispatcher.new_lifecycle_events_receiver("DISPATCH_TYPE") @@ -173,7 +173,7 @@ async def run(): async with Dispatcher( microgrid_id=microgrid_id, server_url=url, - auth_key=key, + key=key, ) as dispatcher: # Create a new dispatch new_dispatch = await dispatcher.client.create( @@ -217,8 +217,8 @@ def __init__( Args: microgrid_id: The microgrid id. server_url: The URL of the dispatch service. - key: The key to access the service, deprecated, use `auth_key` instead. - auth_key: The authentication key to access the service. + key: The key to access the service. + auth_key: Deprecated, use `key` instead. sign_secret: The secret to sign the requests, optional call_timeout: The timeout for API calls. stream_timeout: The timeout for streaming API calls. @@ -230,25 +230,23 @@ def __init__( if key is not None and auth_key is not None: raise ValueError( - "Both 'key' and 'auth_key' are provided, please use only 'auth_key'." + "Both 'key' and 'auth_key' are provided, please use only 'key'." ) if key is None and auth_key is None: - raise ValueError( - "'auth_key' must be provided to access the dispatch service." - ) + raise ValueError("'key' must be provided to access the dispatch service.") - if key is not None: - auth_key = key + if auth_key is not None: + key = auth_key warnings.warn( - "'key' is deprecated, use 'auth_key' instead.", + "'auth_key' is deprecated, use 'key' instead.", DeprecationWarning, stacklevel=2, ) self._client = DispatchApiClient( server_url=server_url, - auth_key=auth_key, + key=key, sign_secret=sign_secret, call_timeout=call_timeout, stream_timeout=stream_timeout,