Repository navigation
Expand file tree
/
Copy pathdevices.py
More file actions
964 lines (867 loc) · 34.2 KB
/
Copy pathdevices.py
File metadata and controls
964 lines (867 loc) · 34.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
"""
--------------------------------------------------------------------------------
------------------------- Mist API Python CLI Session --------------------------
Written by: Thomas Munzer (tmunzer@juniper.net)
Github : https://github.com/tmunzer/mistapi_python
This package is licensed under the MIT License.
--------------------------------------------------------------------------------
"""
from mistapi import APISession as _APISession
from mistapi.__api_response import APIResponse as _APIResponse
def listOrgDevices(mist_session: _APISession, org_id: str) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/list-org-devices
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices"
query_params: dict[str, str] = {}
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def countOrgDevices(
mist_session: _APISession,
org_id: str,
distinct: str | None = None,
hostname: str | None = None,
site_id: str | None = None,
model: str | None = None,
managed: str | None = None,
mac: str | None = None,
version: str | None = None,
ip: str | None = None,
mxtunnel_status: str | None = None,
mxedge_id: str | None = None,
lldp_system_name: str | None = None,
lldp_system_desc: str | None = None,
lldp_port_id: str | None = None,
lldp_mgmt_addr: str | None = None,
type: str | None = None,
start: str | None = None,
end: str | None = None,
duration: str | None = None,
limit: int | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/count-org-devices
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
distinct : str{'hostname', 'ip', 'lldp_mgmt_addr', 'lldp_port_id', 'lldp_system_desc', 'lldp_system_name', 'mac', 'model', 'mxedge_id', 'mxtunnel_status', 'site_id', 'version'}, default: model
Field used to group this count response. enum: `hostname`, `ip`, `lldp_mgmt_addr`, `lldp_port_id`, `lldp_system_desc`, `lldp_system_name`, `mac`, `model`, `mxedge_id`, `mxtunnel_status`, `site_id`, `version`
hostname : str
Partial / full hostname
site_id : str
Filter results by site identifier
model : str
Filter results by device model. Accepts multiple comma-separated values.
managed : str
for switches and gateways, to filter on managed/unmanaged devices. Deprecated in favour of mist_configured. enum: `true`, `false`
mac : str
Filter results by MAC address
version : str
Filter results by software version
ip : str
Filter results by IPv4 address
mxtunnel_status : str{'down', 'up'}
MxTunnel status, enum: `up`, `down`
mxedge_id : str
Mist Edge id, if AP is connecting to a Mist Edge
lldp_system_name : str
Filter results by LLDP system name
lldp_system_desc : str
Filter results by LLDP system description
lldp_port_id : str
Filter results by LLDP port identifier
lldp_mgmt_addr : str
LLDP management IP address
type : str{'ap', 'gateway', 'switch'}, default: ap
Filter results by type. enum: `ap`, `gateway`, `switch`
start : str
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
end : str
Upper bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d`, `-2h`, or `now`
duration : str, default: 1d
Time range duration for the query, using relative units such as `10m`, `7d`, or `2w`
limit : int, default: 100
Maximum number of results to return per page
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/count"
query_params: dict[str, str] = {}
if distinct:
query_params["distinct"] = str(distinct)
if hostname:
query_params["hostname"] = str(hostname)
if site_id:
query_params["site_id"] = str(site_id)
if model:
query_params["model"] = str(model)
if managed:
query_params["managed"] = str(managed)
if mac:
query_params["mac"] = str(mac)
if version:
query_params["version"] = str(version)
if ip:
query_params["ip"] = str(ip)
if mxtunnel_status:
query_params["mxtunnel_status"] = str(mxtunnel_status)
if mxedge_id:
query_params["mxedge_id"] = str(mxedge_id)
if lldp_system_name:
query_params["lldp_system_name"] = str(lldp_system_name)
if lldp_system_desc:
query_params["lldp_system_desc"] = str(lldp_system_desc)
if lldp_port_id:
query_params["lldp_port_id"] = str(lldp_port_id)
if lldp_mgmt_addr:
query_params["lldp_mgmt_addr"] = str(lldp_mgmt_addr)
if type:
query_params["type"] = str(type)
if start:
query_params["start"] = str(start)
if end:
query_params["end"] = str(end)
if duration:
query_params["duration"] = str(duration)
if limit:
query_params["limit"] = str(limit)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def countOrgDeviceEvents(
mist_session: _APISession,
org_id: str,
distinct: str | None = None,
site_id: str | None = None,
ap: str | None = None,
apfw: str | None = None,
model: str | None = None,
text: str | None = None,
type: str | None = None,
includes: str | None = None,
start: str | None = None,
end: str | None = None,
duration: str | None = None,
limit: int | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/count-org-device-events
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
distinct : str{'ap', 'apfw', 'model', 'org_id', 'site_id', 'text', 'timestamp', 'type'}, default: model
Field used to group this count response. enum: `ap`, `apfw`, `model`, `org_id`, `site_id`, `status`, `text`, `timestamp`, `type`
site_id : str
Filter results by site identifier
ap : str
Filter results by AP MAC address
apfw : str
Filter results by AP firmware version
model : str
Filter results by device model
text : str
Filter results by event message text
type : str
See [List Device Events Definitions](/#operations/listDeviceEventsDefinitions)
includes : str
Keyword to include events from additional indices (e.g. ext_tunnel for ext tunnel events)
start : str
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
end : str
Upper bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d`, `-2h`, or `now`
duration : str, default: 1d
Time range duration for the query, using relative units such as `10m`, `7d`, or `2w`
limit : int, default: 100
Maximum number of results to return per page
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/events/count"
query_params: dict[str, str] = {}
if distinct:
query_params["distinct"] = str(distinct)
if site_id:
query_params["site_id"] = str(site_id)
if ap:
query_params["ap"] = str(ap)
if apfw:
query_params["apfw"] = str(apfw)
if model:
query_params["model"] = str(model)
if text:
query_params["text"] = str(text)
if type:
query_params["type"] = str(type)
if includes:
query_params["includes"] = str(includes)
if start:
query_params["start"] = str(start)
if end:
query_params["end"] = str(end)
if duration:
query_params["duration"] = str(duration)
if limit:
query_params["limit"] = str(limit)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def searchOrgDeviceEvents(
mist_session: _APISession,
org_id: str,
mac: str | None = None,
model: str | None = None,
device_type: str | None = None,
text: str | None = None,
type: str | None = None,
last_by: str | None = None,
includes: str | None = None,
limit: int | None = None,
start: str | None = None,
end: str | None = None,
duration: str | None = None,
sort: str | None = None,
search_after: str | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/search-org-device-events
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
mac : str
Filter results by MAC address. Accepts multiple comma-separated values.
model : str
Filter results by device model. Accepts multiple comma-separated values.
device_type : str, default: ap
Filter results by device type. Accepts multiple comma-separated values.
text : str
Filter results by event message text
type : str
See [List Device Events Definitions](/#operations/listDeviceEventsDefinitions). Accepts multiple comma-separated values.
last_by : str
Return last/recent event for passed in field
includes : str
Keyword to include events from additional indices (e.g. ext_tunnel for ext tunnel events)
limit : int, default: 100
Maximum number of results to return per page
start : str
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
end : str
Upper bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d`, `-2h`, or `now`
duration : str, default: 1d
Time range duration for the query, using relative units such as `10m`, `7d`, or `2w`
sort : str, default: timestamp
On which field the list should be sorted, -prefix represents DESC order
search_after : str
Pagination cursor for retrieving subsequent pages of results. This value is automatically populated by Mist in the `next` URL from the previous response and should not be manually constructed.
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/events/search"
query_params: dict[str, str] = {}
if mac:
query_params["mac"] = str(mac)
if model:
query_params["model"] = str(model)
if device_type:
query_params["device_type"] = str(device_type)
if text:
query_params["text"] = str(text)
if type:
query_params["type"] = str(type)
if last_by:
query_params["last_by"] = str(last_by)
if includes:
query_params["includes"] = str(includes)
if limit:
query_params["limit"] = str(limit)
if start:
query_params["start"] = str(start)
if end:
query_params["end"] = str(end)
if duration:
query_params["duration"] = str(duration)
if sort:
query_params["sort"] = str(sort)
if search_after:
query_params["search_after"] = str(search_after)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def countOrgDeviceLastConfigs(
mist_session: _APISession,
org_id: str,
type: str | None = None,
distinct: str | None = None,
start: str | None = None,
end: str | None = None,
duration: str | None = None,
limit: int | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/count-org-device-last-configs
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
type : str{'ap', 'gateway', 'switch'}, default: ap
Filter results by type. enum: `ap`, `gateway`, `switch`
distinct : str{'mac', 'name', 'site_id', 'version'}
Field used to group this count response. enum: `mac`, `name`, `site_id`, `version`
start : str
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
end : str
Upper bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d`, `-2h`, or `now`
duration : str, default: 1d
Time range duration for the query, using relative units such as `10m`, `7d`, or `2w`
limit : int, default: 100
Maximum number of results to return per page
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/last_config/count"
query_params: dict[str, str] = {}
if type:
query_params["type"] = str(type)
if distinct:
query_params["distinct"] = str(distinct)
if start:
query_params["start"] = str(start)
if end:
query_params["end"] = str(end)
if duration:
query_params["duration"] = str(duration)
if limit:
query_params["limit"] = str(limit)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def searchOrgDeviceLastConfigs(
mist_session: _APISession,
org_id: str,
device_type: str | None = None,
mac: str | None = None,
name: str | None = None,
version: str | None = None,
cert_expiry_duration: str | None = None,
start: str | None = None,
end: str | None = None,
limit: int | None = None,
duration: str | None = None,
sort: str | None = None,
search_after: str | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/search-org-device-last-configs
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
device_type : str{'ap', 'gateway', 'switch', 'mxedge'}, default: ap
Filter results by device type. enum: `ap`, `gateway`, `switch`, `mxedge`
mac : str
Filter results by MAC address. Accepts multiple comma-separated values.
name : str
Filter results by name. Accepts multiple comma-separated values.
version : str
Filter results by software version. Accepts multiple comma-separated values.
cert_expiry_duration : str
Duration for expiring cert queries (format: 2d/3h/172800 seconds)
start : str
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
end : str
Upper bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d`, `-2h`, or `now`
limit : int, default: 100
Maximum number of results to return per page
duration : str, default: 1d
Time range duration for the query, using relative units such as `10m`, `7d`, or `2w`
sort : str, default: timestamp
On which field the list should be sorted, -prefix represents DESC order
search_after : str
Pagination cursor for retrieving subsequent pages of results. This value is automatically populated by Mist in the `next` URL from the previous response and should not be manually constructed.
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/last_config/search"
query_params: dict[str, str] = {}
if device_type:
query_params["device_type"] = str(device_type)
if mac:
query_params["mac"] = str(mac)
if name:
query_params["name"] = str(name)
if version:
query_params["version"] = str(version)
if cert_expiry_duration:
query_params["cert_expiry_duration"] = str(cert_expiry_duration)
if start:
query_params["start"] = str(start)
if end:
query_params["end"] = str(end)
if limit:
query_params["limit"] = str(limit)
if duration:
query_params["duration"] = str(duration)
if sort:
query_params["sort"] = str(sort)
if search_after:
query_params["search_after"] = str(search_after)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def listOrgApsMacs(
mist_session: _APISession,
org_id: str,
limit: int | None = None,
page: int | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/list-org-aps-macs
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
limit : int, default: 100
Maximum number of results to return per page
page : int, default: 1
Select the page number to return when using page-based pagination; starts at `1`
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/radio_macs"
query_params: dict[str, str] = {}
if limit:
query_params["limit"] = str(limit)
if page:
query_params["page"] = str(page)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def searchOrgDevices(
mist_session: _APISession,
org_id: str,
band_24_channel: int | None = None,
band_5_channel: int | None = None,
band_6_channel: int | None = None,
band_24_bandwidth: int | None = None,
band_5_bandwidth: int | None = None,
band_6_bandwidth: int | None = None,
band_24_power: int | None = None,
band_5_power: int | None = None,
band_6_power: int | None = None,
clustered: bool | None = None,
eth0_port_speed: int | None = None,
evpntopo_id: str | None = None,
ext_ip: str | None = None,
hostname: str | None = None,
ip: str | None = None,
last_config_status: str | None = None,
last_hostname: str | None = None,
lldp_mgmt_addr: str | None = None,
lldp_port_id: str | None = None,
lldp_system_desc: str | None = None,
lldp_system_name: str | None = None,
mac: str | None = None,
model: str | None = None,
mxedge_id: str | None = None,
mxedge_ids: str | None = None,
mxtunnel_status: str | None = None,
node: str | None = None,
node0_mac: str | None = None,
node1_mac: str | None = None,
power_constrained: bool | None = None,
radius_stats: str | None = None,
site_id: str | None = None,
stats: bool | None = None,
t128agent_version: str | None = None,
type: str | None = None,
version: str | None = None,
limit: int | None = None,
start: str | None = None,
end: str | None = None,
duration: str | None = None,
sort: str | None = None,
search_after: str | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/search-org-devices
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
band_24_channel : int
When `type`==`ap`, Channel of band_24. Accepts multiple comma-separated integer values.
band_5_channel : int
When `type`==`ap`, Channel of band_5. Accepts multiple comma-separated integer values.
band_6_channel : int
When `type`==`ap`, Channel of band_6. Accepts multiple comma-separated integer values.
band_24_bandwidth : int
When `type`==`ap`, Bandwidth of band_24. Accepts multiple comma-separated integer values.
band_5_bandwidth : int
When `type`==`ap`, Bandwidth of band_5. Accepts multiple comma-separated integer values.
band_6_bandwidth : int
When `type`==`ap`, Bandwidth of band_6. Accepts multiple comma-separated integer values.
band_24_power : int
When `type`==`ap`, Power of band_24. Accepts multiple comma-separated integer values.
band_5_power : int
When `type`==`ap`, Power of band_5. Accepts multiple comma-separated integer values.
band_6_power : int
When `type`==`ap`, Power of band_6. Accepts multiple comma-separated integer values.
clustered : bool
When `type`==`gateway`, true / false
eth0_port_speed : int
When `type`==`ap`, Port speed of eth0. Accepts multiple comma-separated integer values.
evpntopo_id : str
When `type`==`switch`, EVPN topology id
ext_ip : str
Partial / full Device external ip. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `1.2.3.*` and `*.2.3.*` match `1.2.3.4`). Suffix-only wildcards (e.g. `*.2.3.4`) are not supported. Accepts multiple comma-separated values.
hostname : str
Partial / full Device hostname. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `my-london*` and `*london*` match `my-london-1`). Suffix-only wildcards (e.g. `*london-1`) are not supported. Accepts multiple comma-separated values.
ip : str
Partial / full Device IP address. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `10.100.10.*` and `*100.10.*` match `10.100.10.54`). Suffix-only wildcards (e.g. `*.54`) are not supported. Accepts multiple comma-separated values.
last_config_status : str
When `type`==`switch` or `type`==`gateway`, last configuration status
last_hostname : str
Last hostname of the device. Accepts multiple comma-separated values.
lldp_mgmt_addr : str
When `type`==`ap`, LLDP management IP address. Accepts multiple comma-separated values.
lldp_port_id : str
When `type`==`ap`, LLDP port id. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `ge-0/0/*` and `*-0/0/*` match `ge-0/0/30`). Suffix-only wildcards (e.g. `*switch-01`) are not supported. Accepts multiple comma-separated values.
lldp_system_desc : str
When `type`==`ap`, LLDP system description. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `Juniper Networks*` and `*Networks*` match `Juniper Networks, Inc.`). Suffix-only wildcards (e.g. `*switch-01`) are not supported
lldp_system_name : str
When `type`==`ap`, LLDP system name. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `my-switch*` and `*switch*` match `my-switch-01`). Suffix-only wildcards (e.g. `*switch-01`) are not supported. Accepts multiple comma-separated values.
mac : str
Partial / full Device MAC address. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `001122*` and `*1122*` match `001122334455`). Suffix-only wildcards (e.g. `*4455`) are not supported. Accepts multiple comma-separated values.
model : str
Partial / full Device model. Use `prefix*` for prefix search or `*substring*` for contains search (e.g. `AP4*` and `*P4*` match `AP43`). Suffix-only wildcards (e.g. `*43`) are not supported. Accepts multiple comma-separated values.
mxedge_id : str
When `type`==`ap`, Mist Edge id, if AP is connecting to a Mist Edge. Accepts multiple comma-separated values.
mxedge_ids : str
When `type`==`ap`, Comma separated list of Mist Edge id, if AP is connecting to a Mist Edge
mxtunnel_status : str{'down', 'up'}
When `type`==`ap`, Mist Tunnel status used to filter results. enum: `down`, `up`
node : str{'node0', 'node1'}
When `type`==`gateway`. enum: `node0`, `node1`
node0_mac : str
When `type`==`gateway`, node0 MAC address
node1_mac : str
When `type`==`gateway`, node1 MAC address
power_constrained : bool
When `type`==`ap`, whether the AP is power constrained.
radius_stats : str
When `type`==`switch` or `type`==`gateway`, Key-value pairs where the key
is the RADIUS server address and the value contains authentication statistics:
* <server_address> (string): IP address of the RADIUS server as the key
* `auth_accepts` (long): Number of accepted authentication requests
* `auth_rejects` (long): Number of rejected authentication requests
* `auth_timeouts` (long): Number of authentication timeouts
* `auth_server_status` (string): Status of the server. Possible values: `up`, `down`, `unreachable`
site_id : str
Filter results by site identifier
stats : bool
Whether to return device stats
t128agent_version : str
When `type`==`gateway` (SSR only), version of 128T agent
type : str{'ap', 'gateway', 'switch'}, default: ap
Device type used to filter results. enum: `ap`, `gateway`, `switch`
version : str
Filter results by software version. Accepts multiple comma-separated values.
limit : int, default: 100
Maximum number of results to return per page
start : str
Lower bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d` or `-1w`
end : str
Upper bound of the time range, as an epoch timestamp in seconds or a relative value such as `-1d`, `-2h`, or `now`
duration : str, default: 1d
Time range duration for the query, using relative units such as `10m`, `7d`, or `2w`
sort : str, default: timestamp
On which field the list should be sorted, -prefix represents DESC order
search_after : str
Pagination cursor for retrieving subsequent pages of results. This value is automatically populated by Mist in the `next` URL from the previous response and should not be manually constructed.
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/search"
query_params: dict[str, str] = {}
if band_24_channel:
query_params["band_24_channel"] = str(band_24_channel)
if band_5_channel:
query_params["band_5_channel"] = str(band_5_channel)
if band_6_channel:
query_params["band_6_channel"] = str(band_6_channel)
if band_24_bandwidth:
query_params["band_24_bandwidth"] = str(band_24_bandwidth)
if band_5_bandwidth:
query_params["band_5_bandwidth"] = str(band_5_bandwidth)
if band_6_bandwidth:
query_params["band_6_bandwidth"] = str(band_6_bandwidth)
if band_24_power:
query_params["band_24_power"] = str(band_24_power)
if band_5_power:
query_params["band_5_power"] = str(band_5_power)
if band_6_power:
query_params["band_6_power"] = str(band_6_power)
if clustered:
query_params["clustered"] = str(clustered)
if eth0_port_speed:
query_params["eth0_port_speed"] = str(eth0_port_speed)
if evpntopo_id:
query_params["evpntopo_id"] = str(evpntopo_id)
if ext_ip:
query_params["ext_ip"] = str(ext_ip)
if hostname:
query_params["hostname"] = str(hostname)
if ip:
query_params["ip"] = str(ip)
if last_config_status:
query_params["last_config_status"] = str(last_config_status)
if last_hostname:
query_params["last_hostname"] = str(last_hostname)
if lldp_mgmt_addr:
query_params["lldp_mgmt_addr"] = str(lldp_mgmt_addr)
if lldp_port_id:
query_params["lldp_port_id"] = str(lldp_port_id)
if lldp_system_desc:
query_params["lldp_system_desc"] = str(lldp_system_desc)
if lldp_system_name:
query_params["lldp_system_name"] = str(lldp_system_name)
if mac:
query_params["mac"] = str(mac)
if model:
query_params["model"] = str(model)
if mxedge_id:
query_params["mxedge_id"] = str(mxedge_id)
if mxedge_ids:
query_params["mxedge_ids"] = str(mxedge_ids)
if mxtunnel_status:
query_params["mxtunnel_status"] = str(mxtunnel_status)
if node:
query_params["node"] = str(node)
if node0_mac:
query_params["node0_mac"] = str(node0_mac)
if node1_mac:
query_params["node1_mac"] = str(node1_mac)
if power_constrained:
query_params["power_constrained"] = str(power_constrained)
if radius_stats:
query_params["radius_stats"] = str(radius_stats)
if site_id:
query_params["site_id"] = str(site_id)
if stats:
query_params["stats"] = str(stats)
if t128agent_version:
query_params["t128agent_version"] = str(t128agent_version)
if type:
query_params["type"] = str(type)
if version:
query_params["version"] = str(version)
if limit:
query_params["limit"] = str(limit)
if start:
query_params["start"] = str(start)
if end:
query_params["end"] = str(end)
if duration:
query_params["duration"] = str(duration)
if sort:
query_params["sort"] = str(sort)
if search_after:
query_params["search_after"] = str(search_after)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def listOrgDevicesSummary(mist_session: _APISession, org_id: str) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/devices/list-org-devices-summary
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/summary"
query_params: dict[str, str] = {}
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def listOrgDeviceUpgrades(mist_session: _APISession, org_id: str) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/utilities/upgrade/list-org-device-upgrades
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/upgrade"
query_params: dict[str, str] = {}
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def upgradeOrgDevices(
mist_session: _APISession, org_id: str, body: dict | list
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/utilities/upgrade/upgrade-org-devices
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
BODY PARAMS
-----------
body : dict
JSON object to send to Mist Cloud (see API doc above for more details)
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/upgrade"
resp = mist_session.mist_post(uri=uri, body=body)
return resp
def getOrgDeviceUpgrade(
mist_session: _APISession, org_id: str, upgrade_id: str
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/utilities/upgrade/get-org-device-upgrade
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
upgrade_id : str
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/upgrade/{upgrade_id}"
query_params: dict[str, str] = {}
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp
def cancelOrgDeviceUpgrade(
mist_session: _APISession, org_id: str, upgrade_id: str
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/utilities/upgrade/cancel-org-device-upgrade
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
upgrade_id : str
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/upgrade/{upgrade_id}/cancel"
resp = mist_session.mist_post(uri=uri)
return resp
def listOrgAvailableDeviceVersions(
mist_session: _APISession,
org_id: str,
type: str | None = None,
model: str | None = None,
) -> _APIResponse:
"""
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/utilities/upgrade/list-org-available-device-versions
PARAMS
-----------
mistapi.APISession : mist_session
mistapi session including authentication and Mist host information
PATH PARAMS
-----------
org_id : str
QUERY PARAMS
------------
type : str{'ap', 'gateway', 'switch'}, default: ap
Filter results by type. enum: `ap`, `gateway`, `switch`
model : str
Fetch version for device model, use/combine with `type` as needed (for switch and gateway devices). Accepts multiple comma-separated values.
RETURN
-----------
mistapi.APIResponse
response from the API call
"""
uri = f"/api/v1/orgs/{org_id}/devices/versions"
query_params: dict[str, str] = {}
if type:
query_params["type"] = str(type)
if model:
query_params["model"] = str(model)
resp = mist_session.mist_get(uri=uri, query=query_params)
return resp