1414from frequenz .api .assets .v1 import assets_pb2 , assets_pb2_grpc
1515from frequenz .client .base import channel
1616from frequenz .client .base .client import BaseApiClient , call_stub_method
17+ from frequenz .client .common .microgrid import MicrogridId
18+ from frequenz .client .common .microgrid .electrical_components import ElectricalComponentId
1719
1820from ._microgrid import Microgrid
1921from ._microgrid_proto import microgrid_from_proto
@@ -87,7 +89,7 @@ def stub(self) -> assets_pb2_grpc.PlatformAssetsAsyncStub:
8789 return self ._stub # type: ignore
8890
8991 async def get_microgrid ( # noqa: DOC502 (raises ApiClientError indirectly)
90- self , microgrid_id : int
92+ self , microgrid_id : MicrogridId
9193 ) -> Microgrid :
9294 """
9395 Get the details of a microgrid.
@@ -105,7 +107,7 @@ async def get_microgrid( # noqa: DOC502 (raises ApiClientError indirectly)
105107 response = await call_stub_method (
106108 self ,
107109 lambda : self .stub .GetMicrogrid (
108- assets_pb2 .GetMicrogridRequest (microgrid_id = microgrid_id ),
110+ assets_pb2 .GetMicrogridRequest (microgrid_id = int ( microgrid_id ) ),
109111 timeout = DEFAULT_GRPC_CALL_TIMEOUT ,
110112 ),
111113 method_name = "GetMicrogrid" ,
@@ -114,7 +116,7 @@ async def get_microgrid( # noqa: DOC502 (raises ApiClientError indirectly)
114116 return microgrid_from_proto (response .microgrid )
115117
116118 async def list_microgrid_electrical_components (
117- self , microgrid_id : int
119+ self , microgrid_id : MicrogridId
118120 ) -> list [ElectricalComponent ]:
119121 """
120122 Get the electrical components of a microgrid.
@@ -129,7 +131,7 @@ async def list_microgrid_electrical_components(
129131 self ,
130132 lambda : self .stub .ListMicrogridElectricalComponents (
131133 assets_pb2 .ListMicrogridElectricalComponentsRequest (
132- microgrid_id = microgrid_id ,
134+ microgrid_id = int ( microgrid_id ) ,
133135 ),
134136 timeout = DEFAULT_GRPC_CALL_TIMEOUT ,
135137 ),
@@ -142,9 +144,9 @@ async def list_microgrid_electrical_components(
142144
143145 async def list_microgrid_electrical_component_connections (
144146 self ,
145- microgrid_id : int ,
146- source_component_ids : Iterable [int ] = (),
147- destination_component_ids : Iterable [int ] = (),
147+ microgrid_id : MicrogridId ,
148+ source_component_ids : Iterable [ElectricalComponentId ] = (),
149+ destination_component_ids : Iterable [ElectricalComponentId ] = (),
148150 ) -> list [ComponentConnection | None ]:
149151 """
150152 Get the electrical component connections of a microgrid.
@@ -161,9 +163,9 @@ async def list_microgrid_electrical_component_connections(
161163 The electrical component connections of the microgrid.
162164 """
163165 request = assets_pb2 .ListMicrogridElectricalComponentConnectionsRequest (
164- microgrid_id = microgrid_id ,
165- source_component_ids = source_component_ids ,
166- destination_component_ids = destination_component_ids ,
166+ microgrid_id = int ( microgrid_id ) ,
167+ source_component_ids = ( int ( c ) for c in source_component_ids ) ,
168+ destination_component_ids = ( int ( c ) for c in destination_component_ids ) ,
167169 )
168170
169171 response = await call_stub_method (
0 commit comments