@@ -60,7 +60,8 @@ def __init__(
6060 self ,
6161 * ,
6262 server_url : str ,
63- key : str ,
63+ auth_key : str ,
64+ sign_secret : str | None = None ,
6465 connect : bool = True ,
6566 call_timeout : timedelta = timedelta (seconds = 60 ),
6667 stream_timeout : timedelta = timedelta (minutes = 5 ),
@@ -69,7 +70,8 @@ def __init__(
6970
7071 Args:
7172 server_url: The URL of the server to connect to.
72- key: API key to use for authentication.
73+ auth_key: API key to use for authentication.
74+ sign_secret: Optional secret for signing requests.
7375 connect: Whether to connect to the service immediately.
7476 call_timeout: Timeout for gRPC calls, default is 60 seconds.
7577 stream_timeout: Timeout for gRPC streams, default is 5 minutes.
@@ -82,8 +84,9 @@ def __init__(
8284 port = DEFAULT_DISPATCH_PORT ,
8385 ssl = SslOptions (enabled = True ),
8486 ),
87+ auth_key = auth_key ,
88+ sign_secret = sign_secret ,
8589 )
86- self ._metadata = (("key" , key ),)
8790 self ._streams : dict [
8891 MicrogridId ,
8992 GrpcStreamBroadcaster [StreamMicrogridDispatchesResponse , DispatchEvent ],
@@ -199,7 +202,7 @@ def to_interval(
199202 response = await cast (
200203 Awaitable [ListMicrogridDispatchesResponse ],
201204 self .stub .ListMicrogridDispatches (
202- request , metadata = self . _metadata , timeout = self ._call_timeout_seconds
205+ request , timeout = self ._call_timeout_seconds
203206 ),
204207 )
205208
@@ -256,7 +259,6 @@ def _get_stream(
256259 AsyncIterator [StreamMicrogridDispatchesResponse ],
257260 self .stub .StreamMicrogridDispatches (
258261 request ,
259- metadata = self ._metadata ,
260262 timeout = self ._stream_timeout_seconds ,
261263 ),
262264 ),
@@ -327,7 +329,6 @@ async def create( # pylint: disable=too-many-positional-arguments
327329 Awaitable [CreateMicrogridDispatchResponse ],
328330 self .stub .CreateMicrogridDispatch (
329331 request .to_protobuf (),
330- metadata = self ._metadata ,
331332 timeout = self ._call_timeout_seconds ,
332333 ),
333334 )
@@ -419,9 +420,7 @@ async def update(
419420
420421 response = await cast (
421422 Awaitable [UpdateMicrogridDispatchResponse ],
422- self .stub .UpdateMicrogridDispatch (
423- msg , metadata = self ._metadata , timeout = self ._call_timeout_seconds
424- ),
423+ self .stub .UpdateMicrogridDispatch (msg , timeout = self ._call_timeout_seconds ),
425424 )
426425
427426 return Dispatch .from_protobuf (response .dispatch )
@@ -443,9 +442,7 @@ async def get(
443442 )
444443 response = await cast (
445444 Awaitable [GetMicrogridDispatchResponse ],
446- self .stub .GetMicrogridDispatch (
447- request , metadata = self ._metadata , timeout = self ._call_timeout_seconds
448- ),
445+ self .stub .GetMicrogridDispatch (request , timeout = self ._call_timeout_seconds ),
449446 )
450447 return Dispatch .from_protobuf (response .dispatch )
451448
@@ -464,6 +461,6 @@ async def delete(
464461 await cast (
465462 Awaitable [None ],
466463 self .stub .DeleteMicrogridDispatch (
467- request , metadata = self . _metadata , timeout = self ._call_timeout_seconds
464+ request , timeout = self ._call_timeout_seconds
468465 ),
469466 )
0 commit comments