12
12
DeviceType ,
13
13
)
14
14
from typing import Any , List , Union , Optional , Dict
15
+ from seamapi .utils .parse_list_device_params import parse_list_device_params
15
16
from seamapi .utils .convert_to_id import (
16
- to_connect_webview_id ,
17
- to_connected_account_id ,
18
17
to_device_id ,
19
18
)
20
19
from seamapi .utils .report_error import report_error
@@ -69,6 +68,8 @@ def list(
69
68
device_types : Optional [List [DeviceType ]] = None ,
70
69
device_ids : Optional [List [Union [DeviceId , Device ]]] = None ,
71
70
manufacturer : Optional [str ] = None ,
71
+ limit : Optional [float ] = None ,
72
+ created_before : Optional [str ] = None ,
72
73
) -> List [Device ]:
73
74
"""Gets a list of devices.
74
75
@@ -88,6 +89,10 @@ def list(
88
89
Device IDs to filter devices by
89
90
manufacturer : Optional[str]
90
91
Manufacturer name to filter devices by e.g. august, schlage
92
+ limit : str, optional
93
+ Limit the number of devices returned
94
+ created_before : str, optional
95
+ If specified, only devices created before this date will be returned
91
96
92
97
Raises
93
98
------
@@ -99,14 +104,16 @@ def list(
99
104
A list of devices.
100
105
"""
101
106
102
- params = parse_list_params (
107
+ params = parse_list_device_params (
103
108
connected_account ,
104
109
connected_accounts ,
105
110
connect_webview ,
106
111
device_type ,
107
112
device_types ,
108
113
device_ids ,
109
114
manufacturer ,
115
+ limit ,
116
+ created_before ,
110
117
)
111
118
112
119
res = self .seam .make_request (
@@ -318,6 +325,8 @@ def list(
318
325
device_types : Optional [List [DeviceType ]] = None ,
319
326
device_ids : Optional [List [Union [DeviceId , Device ]]] = None ,
320
327
manufacturer : Optional [str ] = None ,
328
+ limit : Optional [float ] = None ,
329
+ created_before : Optional [str ] = None ,
321
330
) -> List [UnmanagedDevice ]:
322
331
"""Gets a list of unmanaged devices.
323
332
@@ -333,10 +342,14 @@ def list(
333
342
Device type e.g. august_lock
334
343
device_types : List[DeviceType], optional
335
344
List of device types e.g. august_lock
336
- device_ids : Optional[ List[Union[DeviceId, Device]]]
345
+ device_ids : List[Union[DeviceId, Device]], optional
337
346
Device IDs to filter devices by
338
- manufacturer : Optional[ str]
347
+ manufacturer : str, optional
339
348
Manufacturer name to filter devices by e.g. august, schlage
349
+ limit : str, optional
350
+ Limit the number of devices returned
351
+ created_before : str, optional
352
+ If specified, only devices created before this date will be returned
340
353
341
354
Raises
342
355
------
@@ -348,14 +361,16 @@ def list(
348
361
A list of unmanaged devices.
349
362
"""
350
363
351
- params = parse_list_params (
364
+ params = parse_list_device_params (
352
365
connected_account ,
353
366
connected_accounts ,
354
367
connect_webview ,
355
368
device_type ,
356
369
device_types ,
357
370
device_ids ,
358
371
manufacturer ,
372
+ limit ,
373
+ created_before ,
359
374
)
360
375
361
376
res = self .seam .make_request (
@@ -405,34 +420,3 @@ def update(
405
420
)
406
421
407
422
return True
408
-
409
-
410
- def parse_list_params (
411
- connected_account ,
412
- connected_accounts ,
413
- connect_webview ,
414
- device_type ,
415
- device_types ,
416
- device_ids ,
417
- manufacturer ,
418
- ):
419
- params = {}
420
- if connected_account :
421
- params ["connected_account_id" ] = to_connected_account_id (
422
- connected_account
423
- )
424
- if connected_accounts :
425
- params ["connected_account_ids" ] = [
426
- to_connected_account_id (ca ) for ca in connected_accounts
427
- ]
428
- if connect_webview :
429
- params ["connect_webview_id" ] = to_connect_webview_id (connect_webview )
430
- if device_type :
431
- params ["device_type" ] = device_type
432
- if device_types is not None :
433
- params ["device_types" ] = device_types
434
- if device_ids is not None :
435
- params ["device_ids" ] = [to_device_id (d ) for d in device_ids ]
436
- if manufacturer :
437
- params ["manufacturer" ] = manufacturer
438
- return params
0 commit comments