forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsm.py
More file actions
1291 lines (930 loc) · 56.4 KB
/
Copy pathsm.py
File metadata and controls
1291 lines (930 loc) · 56.4 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
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import urllib
class Sm(object):
def __init__(self, session):
super(Sm, self).__init__()
self._session = session
def createNetworkSmBypassActivationLockAttempt(self, networkId: str, ids: list):
"""
**Bypass activation lock attempt**
https://developer.cisco.com/meraki/api-v1/#!create-network-sm-bypass-activation-lock-attempt
- networkId (string): Network ID
- ids (array): The ids of the devices to attempt activation lock bypass.
"""
kwargs = locals()
metadata = {
'tags': ['sm', 'configure', 'bypassActivationLockAttempts'],
'operation': 'createNetworkSmBypassActivationLockAttempt'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/bypassActivationLockAttempts'
body_params = ['ids', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkSmBypassActivationLockAttempt(self, networkId: str, attemptId: str):
"""
**Bypass activation lock attempt status**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-bypass-activation-lock-attempt
- networkId (string): Network ID
- attemptId (string): Attempt ID
"""
metadata = {
'tags': ['sm', 'configure', 'bypassActivationLockAttempts'],
'operation': 'getNetworkSmBypassActivationLockAttempt'
}
networkId = urllib.parse.quote(str(networkId), safe='')
attemptId = urllib.parse.quote(str(attemptId), safe='')
resource = f'/networks/{networkId}/sm/bypassActivationLockAttempts/{attemptId}'
return self._session.get(metadata, resource)
def getNetworkSmDevices(self, networkId: str, total_pages=1, direction='next', **kwargs):
"""
**List the devices enrolled in an SM network with various specified fields and filters**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-devices
- networkId (string): Network ID
- total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages
- direction (string): direction to paginate, either "next" (default) or "prev" page
- fields (array): Additional fields that will be displayed for each device.
The default fields are: id, name, tags, ssid, wifiMac, osName, systemModel, uuid, and serialNumber. The additional fields are: ip,
systemType, availableDeviceCapacity, kioskAppName, biosVersion, lastConnected, missingAppsCount, userSuppliedAddress, location, lastUser,
ownerEmail, ownerUsername, osBuild, publicIp, phoneNumber, diskInfoJson, deviceCapacity, isManaged, hadMdm, isSupervised, meid, imei, iccid,
simCarrierNetwork, cellularDataUsed, isHotspotEnabled, createdAt, batteryEstCharge, quarantined, avName, avRunning, asName, fwName,
isRooted, loginRequired, screenLockEnabled, screenLockDelay, autoLoginDisabled, autoTags, hasMdm, hasDesktopAgent, diskEncryptionEnabled,
hardwareEncryptionCaps, passCodeLock, usesHardwareKeystore, androidSecurityPatchVersion, cellular, and url.
- wifiMacs (array): Filter devices by wifi mac(s).
- serials (array): Filter devices by serial(s).
- ids (array): Filter devices by id(s).
- uuids (array): Filter devices by uuid(s).
- systemTypes (array): Filter devices by system type(s).
- scope (array): Specify a scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags.
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 1000.
- startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
- endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'getNetworkSmDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices'
query_params = ['fields', 'wifiMacs', 'serials', 'ids', 'uuids', 'systemTypes', 'scope', 'perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['fields', 'wifiMacs', 'serials', 'ids', 'uuids', 'systemTypes', 'scope', ]
for k, v in kwargs.items():
if k.strip() in array_params:
params[f'{k.strip()}[]'] = kwargs[f'{k}']
params.pop(k.strip())
return self._session.get_pages(metadata, resource, params, total_pages, direction)
def checkinNetworkSmDevices(self, networkId: str, **kwargs):
"""
**Force check-in a set of devices**
https://developer.cisco.com/meraki/api-v1/#!checkin-network-sm-devices
- networkId (string): Network ID
- wifiMacs (array): The wifiMacs of the devices to be checked-in.
- ids (array): The ids of the devices to be checked-in.
- serials (array): The serials of the devices to be checked-in.
- scope (array): The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the devices to be checked-in.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'checkinNetworkSmDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/checkin'
body_params = ['wifiMacs', 'ids', 'serials', 'scope', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def updateNetworkSmDevicesFields(self, networkId: str, deviceFields: dict, **kwargs):
"""
**Modify the fields of a device**
https://developer.cisco.com/meraki/api-v1/#!update-network-sm-devices-fields
- networkId (string): Network ID
- deviceFields (object): The new fields of the device. Each field of this object is optional.
- wifiMac (string): The wifiMac of the device to be modified.
- id (string): The id of the device to be modified.
- serial (string): The serial of the device to be modified.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices', 'fields'],
'operation': 'updateNetworkSmDevicesFields'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/fields'
body_params = ['wifiMac', 'id', 'serial', 'deviceFields', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def lockNetworkSmDevices(self, networkId: str, **kwargs):
"""
**Lock a set of devices**
https://developer.cisco.com/meraki/api-v1/#!lock-network-sm-devices
- networkId (string): Network ID
- wifiMacs (array): The wifiMacs of the devices to be locked.
- ids (array): The ids of the devices to be locked.
- serials (array): The serials of the devices to be locked.
- scope (array): The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the devices to be locked.
- pin (integer): The pin number for locking macOS devices (a six digit number). Required only for macOS devices.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'lockNetworkSmDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/lock'
body_params = ['wifiMacs', 'ids', 'serials', 'scope', 'pin', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def modifyNetworkSmDevicesTags(self, networkId: str, tags: list, updateAction: str, **kwargs):
"""
**Add, delete, or update the tags of a set of devices**
https://developer.cisco.com/meraki/api-v1/#!modify-network-sm-devices-tags
- networkId (string): Network ID
- tags (array): The tags to be added, deleted, or updated.
- updateAction (string): One of add, delete, or update. Only devices that have been modified will be returned.
- wifiMacs (array): The wifiMacs of the devices to be modified.
- ids (array): The ids of the devices to be modified.
- serials (array): The serials of the devices to be modified.
- scope (array): The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the devices to be modified.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'modifyNetworkSmDevicesTags'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/modifyTags'
body_params = ['wifiMacs', 'ids', 'serials', 'scope', 'tags', 'updateAction', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def moveNetworkSmDevices(self, networkId: str, newNetwork: str, **kwargs):
"""
**Move a set of devices to a new network**
https://developer.cisco.com/meraki/api-v1/#!move-network-sm-devices
- networkId (string): Network ID
- newNetwork (string): The new network to which the devices will be moved.
- wifiMacs (array): The wifiMacs of the devices to be moved.
- ids (array): The ids of the devices to be moved.
- serials (array): The serials of the devices to be moved.
- scope (array): The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the devices to be moved.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'moveNetworkSmDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/move'
body_params = ['wifiMacs', 'ids', 'serials', 'scope', 'newNetwork', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def rebootNetworkSmDevices(self, networkId: str, **kwargs):
"""
**Reboot a set of endpoints**
https://developer.cisco.com/meraki/api-v1/#!reboot-network-sm-devices
- networkId (string): Network ID
- wifiMacs (array): The wifiMacs of the endpoints to be rebooted.
- ids (array): The ids of the endpoints to be rebooted.
- serials (array): The serials of the endpoints to be rebooted.
- scope (array): The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the endpoints to be rebooted.
- kextPaths (array): The KextPaths of the endpoints to be rebooted. Available for macOS 11+
- notifyUser (boolean): Whether or not to notify the user before rebooting the endpoint. Available for macOS 11.3+
- rebuildKernelCache (boolean): Whether or not to rebuild the kernel cache when rebooting the endpoint. Available for macOS 11+
- requestRequiresNetworkTether (boolean): Whether or not the request requires network tethering. Available for macOS and supervised iOS or tvOS
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'rebootNetworkSmDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/reboot'
body_params = ['wifiMacs', 'ids', 'serials', 'scope', 'kextPaths', 'notifyUser', 'rebuildKernelCache', 'requestRequiresNetworkTether', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def shutdownNetworkSmDevices(self, networkId: str, **kwargs):
"""
**Shutdown a set of endpoints**
https://developer.cisco.com/meraki/api-v1/#!shutdown-network-sm-devices
- networkId (string): Network ID
- wifiMacs (array): The wifiMacs of the endpoints to be shutdown.
- ids (array): The ids of the endpoints to be shutdown.
- serials (array): The serials of the endpoints to be shutdown.
- scope (array): The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the endpoints to be shutdown.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'shutdownNetworkSmDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/shutdown'
body_params = ['wifiMacs', 'ids', 'serials', 'scope', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def wipeNetworkSmDevices(self, networkId: str, **kwargs):
"""
**Wipe a device**
https://developer.cisco.com/meraki/api-v1/#!wipe-network-sm-devices
- networkId (string): Network ID
- wifiMac (string): The wifiMac of the device to be wiped.
- id (string): The id of the device to be wiped.
- serial (string): The serial of the device to be wiped.
- pin (integer): The pin number (a six digit value) for wiping a macOS device. Required only for macOS devices.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'wipeNetworkSmDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/devices/wipe'
body_params = ['wifiMac', 'id', 'serial', 'pin', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkSmDeviceCellularUsageHistory(self, networkId: str, deviceId: str):
"""
**Return the client's daily cellular data usage history**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-cellular-usage-history
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'monitor', 'devices', 'cellularUsageHistory'],
'operation': 'getNetworkSmDeviceCellularUsageHistory'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/cellularUsageHistory'
return self._session.get(metadata, resource)
def getNetworkSmDeviceCerts(self, networkId: str, deviceId: str):
"""
**List the certs on a device**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-certs
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices', 'certs'],
'operation': 'getNetworkSmDeviceCerts'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/certs'
return self._session.get(metadata, resource)
def getNetworkSmDeviceConnectivity(self, networkId: str, deviceId: str, total_pages=1, direction='next', **kwargs):
"""
**Returns historical connectivity data (whether a device is regularly checking in to Dashboard).**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-connectivity
- networkId (string): Network ID
- deviceId (string): Device ID
- total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages
- direction (string): direction to paginate, either "next" (default) or "prev" page
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 1000.
- startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
- endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'monitor', 'devices', 'connectivity'],
'operation': 'getNetworkSmDeviceConnectivity'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/connectivity'
query_params = ['perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get_pages(metadata, resource, params, total_pages, direction)
def getNetworkSmDeviceDesktopLogs(self, networkId: str, deviceId: str, total_pages=1, direction='next', **kwargs):
"""
**Return historical records of various Systems Manager network connection details for desktop devices.**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-desktop-logs
- networkId (string): Network ID
- deviceId (string): Device ID
- total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages
- direction (string): direction to paginate, either "next" (default) or "prev" page
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 1000.
- startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
- endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'monitor', 'devices', 'desktopLogs'],
'operation': 'getNetworkSmDeviceDesktopLogs'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/desktopLogs'
query_params = ['perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get_pages(metadata, resource, params, total_pages, direction)
def getNetworkSmDeviceDeviceCommandLogs(self, networkId: str, deviceId: str, total_pages=1, direction='next', **kwargs):
"""
**Return historical records of commands sent to Systems Manager devices**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-device-command-logs
- networkId (string): Network ID
- deviceId (string): Device ID
- total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages
- direction (string): direction to paginate, either "next" (default) or "prev" page
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 1000.
- startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
- endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'monitor', 'devices', 'deviceCommandLogs'],
'operation': 'getNetworkSmDeviceDeviceCommandLogs'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/deviceCommandLogs'
query_params = ['perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get_pages(metadata, resource, params, total_pages, direction)
def getNetworkSmDeviceDeviceProfiles(self, networkId: str, deviceId: str):
"""
**Get the installed profiles associated with a device**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-device-profiles
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices', 'deviceProfiles'],
'operation': 'getNetworkSmDeviceDeviceProfiles'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/deviceProfiles'
return self._session.get(metadata, resource)
def installNetworkSmDeviceApps(self, networkId: str, deviceId: str, appIds: list, **kwargs):
"""
**Install applications on a device**
https://developer.cisco.com/meraki/api-v1/#!install-network-sm-device-apps
- networkId (string): Network ID
- deviceId (string): Device ID
- appIds (array): ids of applications to be installed
- force (boolean): By default, installation of an app which is believed to already be present on the device will be skipped. If you'd like to force the installation of the app, set this parameter to true.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'installNetworkSmDeviceApps'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/installApps'
body_params = ['appIds', 'force', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkSmDeviceNetworkAdapters(self, networkId: str, deviceId: str):
"""
**List the network adapters of a device**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-network-adapters
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices', 'networkAdapters'],
'operation': 'getNetworkSmDeviceNetworkAdapters'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/networkAdapters'
return self._session.get(metadata, resource)
def getNetworkSmDevicePerformanceHistory(self, networkId: str, deviceId: str, total_pages=1, direction='next', **kwargs):
"""
**Return historical records of various Systems Manager client metrics for desktop devices.**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-performance-history
- networkId (string): Network ID
- deviceId (string): Device ID
- total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages
- direction (string): direction to paginate, either "next" (default) or "prev" page
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 1000.
- startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
- endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'monitor', 'devices', 'performanceHistory'],
'operation': 'getNetworkSmDevicePerformanceHistory'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/performanceHistory'
query_params = ['perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get_pages(metadata, resource, params, total_pages, direction)
def refreshNetworkSmDeviceDetails(self, networkId: str, deviceId: str):
"""
**Refresh the details of a device**
https://developer.cisco.com/meraki/api-v1/#!refresh-network-sm-device-details
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'refreshNetworkSmDeviceDetails'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/refreshDetails'
return self._session.post(metadata, resource)
def getNetworkSmDeviceRestrictions(self, networkId: str, deviceId: str):
"""
**List the restrictions on a device**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-restrictions
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices', 'restrictions'],
'operation': 'getNetworkSmDeviceRestrictions'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/restrictions'
return self._session.get(metadata, resource)
def getNetworkSmDeviceSecurityCenters(self, networkId: str, deviceId: str):
"""
**List the security centers on a device**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-security-centers
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices', 'securityCenters'],
'operation': 'getNetworkSmDeviceSecurityCenters'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/securityCenters'
return self._session.get(metadata, resource)
def getNetworkSmDeviceSoftwares(self, networkId: str, deviceId: str):
"""
**Get a list of softwares associated with a device**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-softwares
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices', 'softwares'],
'operation': 'getNetworkSmDeviceSoftwares'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/softwares'
return self._session.get(metadata, resource)
def unenrollNetworkSmDevice(self, networkId: str, deviceId: str):
"""
**Unenroll a device**
https://developer.cisco.com/meraki/api-v1/#!unenroll-network-sm-device
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'unenrollNetworkSmDevice'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/unenroll'
return self._session.post(metadata, resource)
def uninstallNetworkSmDeviceApps(self, networkId: str, deviceId: str, appIds: list):
"""
**Uninstall applications on a device**
https://developer.cisco.com/meraki/api-v1/#!uninstall-network-sm-device-apps
- networkId (string): Network ID
- deviceId (string): Device ID
- appIds (array): ids of applications to be uninstalled
"""
kwargs = locals()
metadata = {
'tags': ['sm', 'configure', 'devices'],
'operation': 'uninstallNetworkSmDeviceApps'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/uninstallApps'
body_params = ['appIds', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkSmDeviceWlanLists(self, networkId: str, deviceId: str):
"""
**List the saved SSID names on a device**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-device-wlan-lists
- networkId (string): Network ID
- deviceId (string): Device ID
"""
metadata = {
'tags': ['sm', 'configure', 'devices', 'wlanLists'],
'operation': 'getNetworkSmDeviceWlanLists'
}
networkId = urllib.parse.quote(str(networkId), safe='')
deviceId = urllib.parse.quote(str(deviceId), safe='')
resource = f'/networks/{networkId}/sm/devices/{deviceId}/wlanLists'
return self._session.get(metadata, resource)
def getNetworkSmProfiles(self, networkId: str, **kwargs):
"""
**List all profiles in a network**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-profiles
- networkId (string): Network ID
- payloadTypes (array): Filter by payload types
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'profiles'],
'operation': 'getNetworkSmProfiles'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/profiles'
query_params = ['payloadTypes', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['payloadTypes', ]
for k, v in kwargs.items():
if k.strip() in array_params:
params[f'{k.strip()}[]'] = kwargs[f'{k}']
params.pop(k.strip())
return self._session.get(metadata, resource, params)
def getNetworkSmTargetGroups(self, networkId: str, **kwargs):
"""
**List the target groups in this network**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-target-groups
- networkId (string): Network ID
- withDetails (boolean): Boolean indicating if the the ids of the devices or users scoped by the target group should be included in the response
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'targetGroups'],
'operation': 'getNetworkSmTargetGroups'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/targetGroups'
query_params = ['withDetails', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def createNetworkSmTargetGroup(self, networkId: str, **kwargs):
"""
**Add a target group**
https://developer.cisco.com/meraki/api-v1/#!create-network-sm-target-group
- networkId (string): Network ID
- name (string): The name of this target group
- scope (string): The scope and tag options of the target group. Comma separated values beginning with one of withAny, withAll, withoutAny, withoutAll, all, none, followed by tags. Default to none if empty.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'targetGroups'],
'operation': 'createNetworkSmTargetGroup'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/targetGroups'
body_params = ['name', 'scope', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkSmTargetGroup(self, networkId: str, targetGroupId: str, **kwargs):
"""
**Return a target group**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-target-group
- networkId (string): Network ID
- targetGroupId (string): Target group ID
- withDetails (boolean): Boolean indicating if the the ids of the devices or users scoped by the target group should be included in the response
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'targetGroups'],
'operation': 'getNetworkSmTargetGroup'
}
networkId = urllib.parse.quote(str(networkId), safe='')
targetGroupId = urllib.parse.quote(str(targetGroupId), safe='')
resource = f'/networks/{networkId}/sm/targetGroups/{targetGroupId}'
query_params = ['withDetails', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def updateNetworkSmTargetGroup(self, networkId: str, targetGroupId: str, **kwargs):
"""
**Update a target group**
https://developer.cisco.com/meraki/api-v1/#!update-network-sm-target-group
- networkId (string): Network ID
- targetGroupId (string): Target group ID
- name (string): The name of this target group
- scope (string): The scope and tag options of the target group. Comma separated values beginning with one of withAny, withAll, withoutAny, withoutAll, all, none, followed by tags. Default to none if empty.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'targetGroups'],
'operation': 'updateNetworkSmTargetGroup'
}
networkId = urllib.parse.quote(str(networkId), safe='')
targetGroupId = urllib.parse.quote(str(targetGroupId), safe='')
resource = f'/networks/{networkId}/sm/targetGroups/{targetGroupId}'
body_params = ['name', 'scope', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteNetworkSmTargetGroup(self, networkId: str, targetGroupId: str):
"""
**Delete a target group from a network**
https://developer.cisco.com/meraki/api-v1/#!delete-network-sm-target-group
- networkId (string): Network ID
- targetGroupId (string): Target group ID
"""
metadata = {
'tags': ['sm', 'configure', 'targetGroups'],
'operation': 'deleteNetworkSmTargetGroup'
}
networkId = urllib.parse.quote(str(networkId), safe='')
targetGroupId = urllib.parse.quote(str(targetGroupId), safe='')
resource = f'/networks/{networkId}/sm/targetGroups/{targetGroupId}'
return self._session.delete(metadata, resource)
def getNetworkSmTrustedAccessConfigs(self, networkId: str, total_pages=1, direction='next', **kwargs):
"""
**List Trusted Access Configs**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-trusted-access-configs
- networkId (string): Network ID
- total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages
- direction (string): direction to paginate, either "next" (default) or "prev" page
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 100.
- startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
- endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'trustedAccessConfigs'],
'operation': 'getNetworkSmTrustedAccessConfigs'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/trustedAccessConfigs'
query_params = ['perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get_pages(metadata, resource, params, total_pages, direction)
def getNetworkSmUserAccessDevices(self, networkId: str, total_pages=1, direction='next', **kwargs):
"""
**List User Access Devices and its Trusted Access Connections**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-user-access-devices
- networkId (string): Network ID
- total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages
- direction (string): direction to paginate, either "next" (default) or "prev" page
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 100.
- startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
- endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure', 'userAccessDevices'],
'operation': 'getNetworkSmUserAccessDevices'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/userAccessDevices'
query_params = ['perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get_pages(metadata, resource, params, total_pages, direction)
def deleteNetworkSmUserAccessDevice(self, networkId: str, userAccessDeviceId: str):
"""
**Delete a User Access Device**
https://developer.cisco.com/meraki/api-v1/#!delete-network-sm-user-access-device
- networkId (string): Network ID
- userAccessDeviceId (string): User access device ID
"""
metadata = {
'tags': ['sm', 'configure', 'userAccessDevices'],
'operation': 'deleteNetworkSmUserAccessDevice'
}
networkId = urllib.parse.quote(str(networkId), safe='')
userAccessDeviceId = urllib.parse.quote(str(userAccessDeviceId), safe='')
resource = f'/networks/{networkId}/sm/userAccessDevices/{userAccessDeviceId}'
return self._session.delete(metadata, resource)
def getNetworkSmUsers(self, networkId: str, **kwargs):
"""
**List the owners in an SM network with various specified fields and filters**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-users
- networkId (string): Network ID
- ids (array): Filter users by id(s).
- usernames (array): Filter users by username(s).
- emails (array): Filter users by email(s).
- scope (array): Specifiy a scope (one of all, none, withAny, withAll, withoutAny, withoutAll) and a set of tags.
"""
kwargs.update(locals())
metadata = {
'tags': ['sm', 'configure'],
'operation': 'getNetworkSmUsers'
}
networkId = urllib.parse.quote(str(networkId), safe='')
resource = f'/networks/{networkId}/sm/users'
query_params = ['ids', 'usernames', 'emails', 'scope', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['ids', 'usernames', 'emails', 'scope', ]
for k, v in kwargs.items():
if k.strip() in array_params:
params[f'{k.strip()}[]'] = kwargs[f'{k}']
params.pop(k.strip())
return self._session.get(metadata, resource, params)
def getNetworkSmUserDeviceProfiles(self, networkId: str, userId: str):
"""
**Get the profiles associated with a user**
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-user-device-profiles