99 ListUnitsRequest ,
1010 ListUnitsResponse ,
1111)
12+ from sift .unit .v2 .unit_pb2 import Unit as UnitProto
1213from sift .unit .v2 .unit_pb2_grpc import UnitServiceStub
1314
1415from sift_client ._internal .low_level_wrappers .base import DEFAULT_PAGE_SIZE , LowLevelClientBase
15- from sift_client .sift_types .unit import Unit
1616from sift_client .transport import WithGrpcClient
1717
1818if TYPE_CHECKING :
@@ -36,7 +36,7 @@ def __init__(self, grpc_client: GrpcClient):
3636 """
3737 super ().__init__ (grpc_client )
3838
39- async def create_unit (self , name : str ) -> Unit :
39+ async def create_unit (self , name : str ) -> UnitProto :
4040 """Create a new unit.
4141
4242 If a unit with the same name already exists, it is returned instead of creating a duplicate.
@@ -45,7 +45,7 @@ async def create_unit(self, name: str) -> Unit:
4545 name: The name of the unit.
4646
4747 Returns:
48- The created Unit .
48+ The created unit proto, whose unit_id is used to reference the unit .
4949
5050 Raises:
5151 ValueError: If name is not provided.
@@ -55,8 +55,7 @@ async def create_unit(self, name: str) -> Unit:
5555
5656 request = CreateUnitRequest (name = name )
5757 response = await self ._grpc_client .get_stub (UnitServiceStub ).CreateUnit (request )
58- grpc_unit = cast ("CreateUnitResponse" , response ).unit
59- return Unit ._from_proto (grpc_unit )
58+ return cast ("CreateUnitResponse" , response ).unit
6059
6160 async def list_units (
6261 self ,
@@ -65,17 +64,17 @@ async def list_units(
6564 page_token : str | None = None ,
6665 query_filter : str | None = None ,
6766 order_by : str | None = None ,
68- ) -> tuple [list [Unit ], str ]:
67+ ) -> tuple [list [UnitProto ], str ]:
6968 """List units with optional filtering and pagination.
7069
7170 Args:
7271 page_size: The maximum number of units to return.
7372 page_token: A page token for pagination.
74- query_filter: A CEL filter string.
73+ query_filter: A CEL filter string (e.g. filtering on unit_id or abbreviated_name) .
7574 order_by: How to order the retrieved units.
7675
7776 Returns:
78- A tuple of (units , next_page_token).
77+ A tuple of (unit protos , next_page_token).
7978 """
8079 request_kwargs : dict [str , Any ] = {}
8180 if page_size is not None :
@@ -91,5 +90,4 @@ async def list_units(
9190 response = await self ._grpc_client .get_stub (UnitServiceStub ).ListUnits (request )
9291 response = cast ("ListUnitsResponse" , response )
9392
94- units = [Unit ._from_proto (unit ) for unit in response .units ]
95- return units , response .next_page_token
93+ return list (response .units ), response .next_page_token
0 commit comments