Skip to content

Commit 9b008f7

Browse files
committed
feat: Add backwards compatibility for key param
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 111667e commit 9b008f7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/frequenz/client/dispatch/_client.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""Dispatch API client for Python."""
55
from __future__ import annotations
66

7+
import warnings
78
from datetime import datetime, timedelta
89
from typing import Any, AsyncIterator, Awaitable, Iterator, Literal, cast
910

@@ -58,7 +59,8 @@ def __init__(
5859
self,
5960
*,
6061
server_url: str,
61-
auth_key: str,
62+
auth_key: str | None = None,
63+
key: str | None = None,
6264
sign_secret: str | None = None,
6365
connect: bool = True,
6466
call_timeout: timedelta = timedelta(seconds=60),
@@ -69,11 +71,27 @@ def __init__(
6971
Args:
7072
server_url: The URL of the server to connect to.
7173
auth_key: API key to use for authentication.
74+
key: Deprecated, use `auth_key` instead.
7275
sign_secret: Optional secret for signing requests.
7376
connect: Whether to connect to the service immediately.
7477
call_timeout: Timeout for gRPC calls, default is 60 seconds.
7578
stream_timeout: Timeout for gRPC streams, default is 5 minutes.
79+
80+
Raises:
81+
TypeError: If neither `auth_key` nor `key` is provided.
7682
"""
83+
if key is not None:
84+
warnings.warn(
85+
"The `key` parameter is deprecated, use `auth_key` instead.",
86+
DeprecationWarning,
87+
stacklevel=2,
88+
)
89+
auth_key = auth_key or key
90+
if auth_key is None:
91+
raise TypeError(
92+
"__init__() missing 1 required keyword-only argument: 'auth_key'"
93+
)
94+
7795
super().__init__(
7896
server_url,
7997
dispatch_pb2_grpc.MicrogridDispatchServiceStub,

0 commit comments

Comments
 (0)