|
11 | 11 |
|
12 | 12 | from collections.abc import Iterable |
13 | 13 |
|
14 | | -from frequenz.api.assets.v1 import assets_pb2, assets_pb2_grpc |
| 14 | +from frequenz.api.platformassets.v1alpha1 import ( |
| 15 | + platformassets_pb2, |
| 16 | + platformassets_pb2_grpc, |
| 17 | +) |
15 | 18 | from frequenz.client.base import channel |
16 | 19 | from frequenz.client.base.client import BaseApiClient, call_stub_method |
17 | 20 | from frequenz.client.common.microgrid import MicrogridId |
|
41 | 44 |
|
42 | 45 |
|
43 | 46 | class AssetsApiClient( |
44 | | - BaseApiClient[assets_pb2_grpc.PlatformAssetsStub] |
| 47 | + BaseApiClient[platformassets_pb2_grpc.PlatformAssetsServiceStub] |
45 | 48 | ): # pylint: disable=too-many-arguments |
46 | 49 | """A client for the Assets API.""" |
47 | 50 |
|
@@ -75,15 +78,15 @@ def __init__( |
75 | 78 | """ |
76 | 79 | super().__init__( |
77 | 80 | server_url, |
78 | | - assets_pb2_grpc.PlatformAssetsStub, |
| 81 | + platformassets_pb2_grpc.PlatformAssetsServiceStub, |
79 | 82 | connect=connect, |
80 | 83 | channel_defaults=channel_defaults, |
81 | 84 | auth_key=auth_key, |
82 | 85 | sign_secret=sign_secret, |
83 | 86 | ) |
84 | 87 |
|
85 | 88 | @property |
86 | | - def stub(self) -> assets_pb2_grpc.PlatformAssetsAsyncStub: |
| 89 | + def stub(self) -> platformassets_pb2_grpc.PlatformAssetsServiceAsyncStub: |
87 | 90 | """ |
88 | 91 | The gRPC stub for the Assets API. |
89 | 92 |
|
@@ -127,7 +130,7 @@ async def get_microgrid( # noqa: DOC502,DOC503 (raises indirectly) |
127 | 130 | response = await call_stub_method( |
128 | 131 | self, |
129 | 132 | lambda: self.stub.GetMicrogrid( |
130 | | - assets_pb2.GetMicrogridRequest(microgrid_id=int(microgrid_id)), |
| 133 | + platformassets_pb2.GetMicrogridRequest(microgrid_id=int(microgrid_id)), |
131 | 134 | timeout=DEFAULT_GRPC_CALL_TIMEOUT, |
132 | 135 | ), |
133 | 136 | method_name="GetMicrogrid", |
@@ -179,7 +182,7 @@ async def list_microgrid_electrical_components( |
179 | 182 | response = await call_stub_method( |
180 | 183 | self, |
181 | 184 | lambda: self.stub.ListMicrogridElectricalComponents( |
182 | | - assets_pb2.ListMicrogridElectricalComponentsRequest( |
| 185 | + platformassets_pb2.ListMicrogridElectricalComponentsRequest( |
183 | 186 | microgrid_id=int(microgrid_id), |
184 | 187 | ), |
185 | 188 | timeout=DEFAULT_GRPC_CALL_TIMEOUT, |
@@ -251,11 +254,14 @@ async def list_microgrid_electrical_component_connections( |
251 | 254 | issues are found. All exceptions in the group are |
252 | 255 | [InvalidConnectionError][frequenz.client.assets.exceptions.InvalidConnectionError]. |
253 | 256 | """ |
254 | | - request = assets_pb2.ListMicrogridElectricalComponentConnectionsRequest( |
| 257 | + source_ids = [int(c) for c in source_component_ids] |
| 258 | + destination_ids = [int(c) for c in destination_component_ids] |
| 259 | + request = platformassets_pb2.ListMicrogridElectricalComponentConnectionsRequest( |
255 | 260 | microgrid_id=int(microgrid_id), |
256 | | - source_component_ids=(int(c) for c in source_component_ids), |
257 | | - destination_component_ids=(int(c) for c in destination_component_ids), |
258 | 261 | ) |
| 262 | + if source_ids or destination_ids: |
| 263 | + request.filter.source_component_ids.extend(source_ids) |
| 264 | + request.filter.destination_component_ids.extend(destination_ids) |
259 | 265 |
|
260 | 266 | response = await call_stub_method( |
261 | 267 | self, |
|
0 commit comments