Skip to content

Commit cafc7e4

Browse files
committed
http: api: devices: add optional filter by site id
1 parent 8406e48 commit cafc7e4

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/enapter/cli/http/api/device_list_command.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def register(parent: cli.Subparsers) -> None:
4141
action="store_true",
4242
help="Expand device communication information",
4343
)
44+
parser.add_argument("-s", "--site-id", help="Filter devices by site ID")
4445

4546
@staticmethod
4647
async def run(args: argparse.Namespace) -> None:
@@ -52,6 +53,7 @@ async def run(args: argparse.Namespace) -> None:
5253
expand_properties=args.properties,
5354
expand_connectivity=args.connectivity,
5455
expand_communication=args.communication,
56+
site_id=args.site_id,
5557
) as stream:
5658
count = 0
5759
async for device in stream:

src/enapter/http/api/devices/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ async def list(
101101
expand_properties: bool = False,
102102
expand_connectivity: bool = False,
103103
expand_communication: bool = False,
104+
site_id: str | None = None,
104105
) -> AsyncGenerator[Device, None]:
105-
url = "v3/devices"
106+
url = "v3/devices" if site_id is None else f"v3/sites/{site_id}/devices"
106107
expand = {
107108
"manifest": expand_manifest,
108109
"properties": expand_properties,

0 commit comments

Comments
 (0)