forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetworks.py
More file actions
1888 lines (1319 loc) · 82.2 KB
/
Copy pathnetworks.py
File metadata and controls
1888 lines (1319 loc) · 82.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
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
class Networks(object):
def __init__(self, session):
super(Networks, self).__init__()
self._session = session
def getNetwork(self, networkId: str):
"""
**Return a network**
https://developer.cisco.com/meraki/api-v1/#!get-network
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure'],
'operation': 'getNetwork'
}
resource = f'/networks/{networkId}'
return self._session.get(metadata, resource)
def updateNetwork(self, networkId: str, **kwargs):
"""
**Update a network**
https://developer.cisco.com/meraki/api-v1/#!update-network
- networkId (string): (required)
- name (string): The name of the network
- timeZone (string): The timezone of the network. For a list of allowed timezones, please see the 'TZ' column in the table in <a target='_blank' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>this article.</a>
- tags (array): A list of tags to be applied to the network
- enrollmentString (string): A unique identifier which can be used for device enrollment or easy access through the Meraki SM Registration page or the Self Service Portal. Please note that changing this field may cause existing bookmarks to break.
- notes (string): Add any notes or additional information about this network here.
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'configure'],
'operation': 'updateNetwork'
}
resource = f'/networks/{networkId}'
body_params = ['name', 'timeZone', 'tags', 'enrollmentString', 'notes', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteNetwork(self, networkId: str):
"""
**Delete a network**
https://developer.cisco.com/meraki/api-v1/#!delete-network
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure'],
'operation': 'deleteNetwork'
}
resource = f'/networks/{networkId}'
return self._session.delete(metadata, resource)
def getNetworkAlertsSettings(self, networkId: str):
"""
**Return the alert configuration for this network**
https://developer.cisco.com/meraki/api-v1/#!get-network-alerts-settings
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'alerts', 'settings'],
'operation': 'getNetworkAlertsSettings'
}
resource = f'/networks/{networkId}/alerts/settings'
return self._session.get(metadata, resource)
def updateNetworkAlertsSettings(self, networkId: str, **kwargs):
"""
**Update the alert configuration for this network**
https://developer.cisco.com/meraki/api-v1/#!update-network-alerts-settings
- networkId (string): (required)
- defaultDestinations (object): The network-wide destinations for all alerts on the network.
- alerts (array): Alert-specific configuration for each type. Only alerts that pertain to the network can be updated.
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'configure', 'alerts', 'settings'],
'operation': 'updateNetworkAlertsSettings'
}
resource = f'/networks/{networkId}/alerts/settings'
body_params = ['defaultDestinations', 'alerts', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def bindNetwork(self, networkId: str, configTemplateId: str, **kwargs):
"""
**Bind a network to a template.**
https://developer.cisco.com/meraki/api-v1/#!bind-network
- networkId (string): (required)
- configTemplateId (string): The ID of the template to which the network should be bound.
- autoBind (boolean): Optional boolean indicating whether the network's switches should automatically bind to profiles of the same model. Defaults to false if left unspecified. This option only affects switch networks and switch templates. Auto-bind is not valid unless the switch template has at least one profile and has at most one profile per switch model.
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'configure'],
'operation': 'bindNetwork'
}
resource = f'/networks/{networkId}/bind'
body_params = ['configTemplateId', 'autoBind', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkBluetoothClients(self, networkId: str, total_pages=1, direction='next', **kwargs):
"""
**List the Bluetooth clients seen by APs in this network**
https://developer.cisco.com/meraki/api-v1/#!get-network-bluetooth-clients
- networkId (string): (required)
- 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
- t0 (string): The beginning of the timespan for the data. The maximum lookback period is 7 days from today.
- timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameter t0. The value must be in seconds and be less than or equal to 7 days. The default is 1 day.
- perPage (integer): The number of entries per page returned. Acceptable range is 5 - 1000. Default is 10.
- 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.
- includeConnectivityHistory (boolean): Include the connectivity history for this client
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'monitor', 'bluetoothClients'],
'operation': 'getNetworkBluetoothClients'
}
resource = f'/networks/{networkId}/bluetoothClients'
query_params = ['t0', 'timespan', 'perPage', 'startingAfter', 'endingBefore', 'includeConnectivityHistory', ]
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 getNetworkBluetoothClient(self, networkId: str, bluetoothClientId: str, **kwargs):
"""
**Return a Bluetooth client**
https://developer.cisco.com/meraki/api-v1/#!get-network-bluetooth-client
- networkId (string): (required)
- bluetoothClientId (string): (required)
- includeConnectivityHistory (boolean): Include the connectivity history for this client
- connectivityHistoryTimespan (integer): The timespan, in seconds, for the connectivityHistory data. By default 1 day, 86400, will be used.
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'monitor', 'bluetoothClients'],
'operation': 'getNetworkBluetoothClient'
}
resource = f'/networks/{networkId}/bluetoothClients/{bluetoothClientId}'
query_params = ['includeConnectivityHistory', 'connectivityHistoryTimespan', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def getNetworkClients(self, networkId: str, total_pages=1, direction='next', **kwargs):
"""
**List the clients that have used this network in the timespan**
https://developer.cisco.com/meraki/api-v1/#!get-network-clients
- networkId (string): (required)
- 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
- t0 (string): The beginning of the timespan for the data. The maximum lookback period is 31 days from today.
- timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameter t0. The value must be in seconds and be less than or equal to 31 days. The default is 1 day.
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 10.
- 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': ['networks', 'monitor', 'clients'],
'operation': 'getNetworkClients'
}
resource = f'/networks/{networkId}/clients'
query_params = ['t0', 'timespan', '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 getNetworkClientsApplicationUsage(self, networkId: str, clients: str, total_pages=1, direction='next', **kwargs):
"""
**Return the application usage data for clients**
https://developer.cisco.com/meraki/api-v1/#!get-network-clients-application-usage
- networkId (string): (required)
- clients (string): A list of client keys, MACs or IPs separated by comma.
- 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
- ssidNumber (integer): An SSID number to include. If not specified, eveusage histories application usagents for all SSIDs will be returned.
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 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.
- t0 (string): The beginning of the timespan for the data. The maximum lookback period is 31 days from today.
- t1 (string): The end of the timespan for the data. t1 can be a maximum of 31 days after t0.
- timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameters t0 and t1. The value must be in seconds and be less than or equal to 31 days. The default is 1 day.
"""
kwargs.update(locals())
if 'ssidNumber' in kwargs:
options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
assert kwargs['ssidNumber'] in options, f'''"ssidNumber" cannot be "{kwargs['ssidNumber']}", & must be set to one of: {options}'''
metadata = {
'tags': ['networks', 'monitor', 'clients', 'applicationUsage'],
'operation': 'getNetworkClientsApplicationUsage'
}
resource = f'/networks/{networkId}/clients/applicationUsage'
query_params = ['clients', 'ssidNumber', 'perPage', 'startingAfter', 'endingBefore', 't0', 't1', 'timespan', ]
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 provisionNetworkClients(self, networkId: str, clients: list, devicePolicy: str, **kwargs):
"""
**Provisions a client with a name and policy**
https://developer.cisco.com/meraki/api-v1/#!provision-network-clients
- networkId (string): (required)
- clients (array): The array of clients to provision
- devicePolicy (string): The policy to apply to the specified client. Can be 'Group policy', 'Allowed', 'Blocked', 'Per connection' or 'Normal'. Required.
- groupPolicyId (string): The ID of the desired group policy to apply to the client. Required if 'devicePolicy' is set to "Group policy". Otherwise this is ignored.
- policiesBySecurityAppliance (object): An object, describing what the policy-connection association is for the security appliance. (Only relevant if the security appliance is actually within the network)
- policiesBySsid (object): An object, describing the policy-connection associations for each active SSID within the network. Keys should be the number of enabled SSIDs, mapping to an object describing the client's policy
"""
kwargs.update(locals())
if 'devicePolicy' in kwargs:
options = ['Group policy', 'Allowed', 'Blocked', 'Per connection', 'Normal']
assert kwargs['devicePolicy'] in options, f'''"devicePolicy" cannot be "{kwargs['devicePolicy']}", & must be set to one of: {options}'''
metadata = {
'tags': ['networks', 'configure', 'clients'],
'operation': 'provisionNetworkClients'
}
resource = f'/networks/{networkId}/clients/provision'
body_params = ['clients', 'devicePolicy', 'groupPolicyId', 'policiesBySecurityAppliance', 'policiesBySsid', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkClientsUsageHistories(self, networkId: str, clients: str, total_pages=1, direction='next', **kwargs):
"""
**Return the usage histories for clients**
https://developer.cisco.com/meraki/api-v1/#!get-network-clients-usage-histories
- networkId (string): (required)
- clients (string): A list of client keys, MACs or IPs separated by comma.
- 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
- ssidNumber (integer): An SSID number to include. If not specified, events for all SSIDs will be returned.
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 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.
- t0 (string): The beginning of the timespan for the data. The maximum lookback period is 31 days from today.
- t1 (string): The end of the timespan for the data. t1 can be a maximum of 31 days after t0.
- timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameters t0 and t1. The value must be in seconds and be less than or equal to 31 days. The default is 1 day.
"""
kwargs.update(locals())
if 'ssidNumber' in kwargs:
options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
assert kwargs['ssidNumber'] in options, f'''"ssidNumber" cannot be "{kwargs['ssidNumber']}", & must be set to one of: {options}'''
metadata = {
'tags': ['networks', 'monitor', 'clients', 'usageHistories'],
'operation': 'getNetworkClientsUsageHistories'
}
resource = f'/networks/{networkId}/clients/usageHistories'
query_params = ['clients', 'ssidNumber', 'perPage', 'startingAfter', 'endingBefore', 't0', 't1', 'timespan', ]
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 getNetworkClient(self, networkId: str, clientId: str):
"""
**Return the client associated with the given identifier**
https://developer.cisco.com/meraki/api-v1/#!get-network-client
- networkId (string): (required)
- clientId (string): (required)
"""
metadata = {
'tags': ['networks', 'monitor', 'clients'],
'operation': 'getNetworkClient'
}
resource = f'/networks/{networkId}/clients/{clientId}'
return self._session.get(metadata, resource)
def getNetworkClientPolicy(self, networkId: str, clientId: str):
"""
**Return the policy assigned to a client on the network**
https://developer.cisco.com/meraki/api-v1/#!get-network-client-policy
- networkId (string): (required)
- clientId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'clients', 'policy'],
'operation': 'getNetworkClientPolicy'
}
resource = f'/networks/{networkId}/clients/{clientId}/policy'
return self._session.get(metadata, resource)
def updateNetworkClientPolicy(self, networkId: str, clientId: str, devicePolicy: str, **kwargs):
"""
**Update the policy assigned to a client on the network**
https://developer.cisco.com/meraki/api-v1/#!update-network-client-policy
- networkId (string): (required)
- clientId (string): (required)
- devicePolicy (string): The policy to assign. Can be 'Whitelisted', 'Blocked', 'Normal' or 'Group policy'. Required.
- groupPolicyId (string): [optional] If 'devicePolicy' is set to 'Group policy' this param is used to specify the group policy ID.
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'configure', 'clients', 'policy'],
'operation': 'updateNetworkClientPolicy'
}
resource = f'/networks/{networkId}/clients/{clientId}/policy'
body_params = ['devicePolicy', 'groupPolicyId', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkClientSplashAuthorizationStatus(self, networkId: str, clientId: str):
"""
**Return the splash authorization for a client, for each SSID they've associated with through splash**
https://developer.cisco.com/meraki/api-v1/#!get-network-client-splash-authorization-status
- networkId (string): (required)
- clientId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'clients', 'splashAuthorizationStatus'],
'operation': 'getNetworkClientSplashAuthorizationStatus'
}
resource = f'/networks/{networkId}/clients/{clientId}/splashAuthorizationStatus'
return self._session.get(metadata, resource)
def updateNetworkClientSplashAuthorizationStatus(self, networkId: str, clientId: str, ssids: dict):
"""
**Update a client's splash authorization**
https://developer.cisco.com/meraki/api-v1/#!update-network-client-splash-authorization-status
- networkId (string): (required)
- clientId (string): (required)
- ssids (object): The target SSIDs. Each SSID must be enabled and must have Click-through splash enabled. For each SSID where isAuthorized is true, the expiration time will automatically be set according to the SSID's splash frequency. Not all networks support configuring all SSIDs
"""
kwargs = locals()
metadata = {
'tags': ['networks', 'configure', 'clients', 'splashAuthorizationStatus'],
'operation': 'updateNetworkClientSplashAuthorizationStatus'
}
resource = f'/networks/{networkId}/clients/{clientId}/splashAuthorizationStatus'
body_params = ['ssids', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkClientTrafficHistory(self, networkId: str, clientId: str, total_pages=1, direction='next', **kwargs):
"""
**Return the client's network traffic data over time**
https://developer.cisco.com/meraki/api-v1/#!get-network-client-traffic-history
- networkId (string): (required)
- clientId (string): (required)
- 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.
- 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': ['networks', 'monitor', 'clients', 'trafficHistory'],
'operation': 'getNetworkClientTrafficHistory'
}
resource = f'/networks/{networkId}/clients/{clientId}/trafficHistory'
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 getNetworkClientUsageHistory(self, networkId: str, clientId: str):
"""
**Return the client's daily usage history**
https://developer.cisco.com/meraki/api-v1/#!get-network-client-usage-history
- networkId (string): (required)
- clientId (string): (required)
"""
metadata = {
'tags': ['networks', 'monitor', 'clients', 'usageHistory'],
'operation': 'getNetworkClientUsageHistory'
}
resource = f'/networks/{networkId}/clients/{clientId}/usageHistory'
return self._session.get(metadata, resource)
def getNetworkDevices(self, networkId: str):
"""
**List the devices in a network**
https://developer.cisco.com/meraki/api-v1/#!get-network-devices
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'devices'],
'operation': 'getNetworkDevices'
}
resource = f'/networks/{networkId}/devices'
return self._session.get(metadata, resource)
def claimNetworkDevices(self, networkId: str, serials: list):
"""
**Claim devices into a network. (Note: for recently claimed devices, it may take a few minutes for API requsts against that device to succeed)**
https://developer.cisco.com/meraki/api-v1/#!claim-network-devices
- networkId (string): (required)
- serials (array): A list of serials of devices to claim
"""
kwargs = locals()
metadata = {
'tags': ['networks', 'configure', 'devices'],
'operation': 'claimNetworkDevices'
}
resource = f'/networks/{networkId}/devices/claim'
body_params = ['serials', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def removeNetworkDevices(self, networkId: str, serial: str):
"""
**Remove a single device**
https://developer.cisco.com/meraki/api-v1/#!remove-network-devices
- networkId (string): (required)
- serial (string): The serial of a device
"""
kwargs = locals()
metadata = {
'tags': ['networks', 'configure', 'devices'],
'operation': 'removeNetworkDevices'
}
resource = f'/networks/{networkId}/devices/remove'
body_params = ['serial', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkEvents(self, networkId: str, total_pages=1, direction='prev', event_log_end_time=None, **kwargs):
"""
**List the events for the network**
https://developer.cisco.com/meraki/api-v1/#!get-network-events
- networkId (string): (required)
- 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" or "prev" (default) page
- event_log_end_time (string): ISO8601 Zulu/UTC time, to use in conjunction with startingAfter, to retrieve events within a time window
- productType (string): The product type to fetch events for. This parameter is required for networks with multiple device types. Valid types are wireless, appliance, switch, systemsManager, camera, cellularGateway, and environmental
- includedEventTypes (array): A list of event types. The returned events will be filtered to only include events with these types.
- excludedEventTypes (array): A list of event types. The returned events will be filtered to exclude events with these types.
- deviceMac (string): The MAC address of the Meraki device which the list of events will be filtered with
- deviceSerial (string): The serial of the Meraki device which the list of events will be filtered with
- deviceName (string): The name of the Meraki device which the list of events will be filtered with
- clientIp (string): The IP of the client which the list of events will be filtered with. Only supported for track-by-IP networks.
- clientMac (string): The MAC address of the client which the list of events will be filtered with. Only supported for track-by-MAC networks.
- clientName (string): The name, or partial name, of the client which the list of events will be filtered with
- smDeviceMac (string): The MAC address of the Systems Manager device which the list of events will be filtered with
- smDeviceName (string): The name of the Systems Manager device which the list of events will be filtered with
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 10.
- 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': ['networks', 'monitor', 'events'],
'operation': 'getNetworkEvents'
}
resource = f'/networks/{networkId}/events'
query_params = ['productType', 'includedEventTypes', 'excludedEventTypes', 'deviceMac', 'deviceSerial', 'deviceName', 'clientIp', 'clientMac', 'clientName', 'smDeviceMac', 'smDeviceName', 'perPage', 'startingAfter', 'endingBefore', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['includedEventTypes', 'excludedEventTypes', ]
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, event_log_end_time)
def getNetworkEventsEventTypes(self, networkId: str):
"""
**List the event type to human-readable description**
https://developer.cisco.com/meraki/api-v1/#!get-network-events-event-types
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'monitor', 'events', 'eventTypes'],
'operation': 'getNetworkEventsEventTypes'
}
resource = f'/networks/{networkId}/events/eventTypes'
return self._session.get(metadata, resource)
def getNetworkFirmwareUpgrades(self, networkId: str):
"""
**Get firmware upgrade information for a network**
https://developer.cisco.com/meraki/api-v1/#!get-network-firmware-upgrades
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'firmwareUpgrades'],
'operation': 'getNetworkFirmwareUpgrades'
}
resource = f'/networks/{networkId}/firmwareUpgrades'
return self._session.get(metadata, resource)
def updateNetworkFirmwareUpgrades(self, networkId: str, **kwargs):
"""
**Update firmware upgrade information for a network**
https://developer.cisco.com/meraki/api-v1/#!update-network-firmware-upgrades
- networkId (string): (required)
- upgradeWindow (object): Upgrade window for devices in network
- timezone (string): The timezone for the network
- products (object): Contains information about the network to update
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'configure', 'firmwareUpgrades'],
'operation': 'updateNetworkFirmwareUpgrades'
}
resource = f'/networks/{networkId}/firmwareUpgrades'
body_params = ['upgradeWindow', 'timezone', 'products', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def createNetworkFirmwareUpgradesRollback(self, networkId: str, reasons: list, **kwargs):
"""
**Rollback a Firmware Upgrade For A Network**
https://developer.cisco.com/meraki/api-v1/#!create-network-firmware-upgrades-rollback
- networkId (string): (required)
- reasons (array): Reasons for the rollback
- product (string): Product type to rollback (if the network is a combined network)
- time (string): Scheduled time for the rollback
- toVersion (object): Version to downgrade to (if the network has firmware flexibility)
"""
kwargs.update(locals())
if 'product' in kwargs:
options = ['wireless', 'switch', 'appliance', 'camera', 'vmxHost', 'cellularGateway']
assert kwargs['product'] in options, f'''"product" cannot be "{kwargs['product']}", & must be set to one of: {options}'''
metadata = {
'tags': ['networks', 'configure', 'firmwareUpgrades', 'rollbacks'],
'operation': 'createNetworkFirmwareUpgradesRollback'
}
resource = f'/networks/{networkId}/firmwareUpgrades/rollbacks'
body_params = ['product', 'time', 'reasons', 'toVersion', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkFloorPlans(self, networkId: str):
"""
**List the floor plans that belong to your network**
https://developer.cisco.com/meraki/api-v1/#!get-network-floor-plans
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'floorPlans'],
'operation': 'getNetworkFloorPlans'
}
resource = f'/networks/{networkId}/floorPlans'
return self._session.get(metadata, resource)
def createNetworkFloorPlan(self, networkId: str, name: str, imageContents: str, **kwargs):
"""
**Upload a floor plan**
https://developer.cisco.com/meraki/api-v1/#!create-network-floor-plan
- networkId (string): (required)
- name (string): The name of your floor plan.
- imageContents (string): The file contents (a base 64 encoded string) of your image. Supported formats are PNG, GIF, and JPG. Note that all images are saved as PNG files, regardless of the format they are uploaded in.
- center (object): The longitude and latitude of the center of your floor plan. The 'center' or two adjacent corners (e.g. 'topLeftCorner' and 'bottomLeftCorner') must be specified. If 'center' is specified, the floor plan is placed over that point with no rotation. If two adjacent corners are specified, the floor plan is rotated to line up with the two specified points. The aspect ratio of the floor plan's image is preserved regardless of which corners/center are specified. (This means if that more than two corners are specified, only two corners may be used to preserve the floor plan's aspect ratio.). No two points can have the same latitude, longitude pair.
- bottomLeftCorner (object): The longitude and latitude of the bottom left corner of your floor plan.
- bottomRightCorner (object): The longitude and latitude of the bottom right corner of your floor plan.
- topLeftCorner (object): The longitude and latitude of the top left corner of your floor plan.
- topRightCorner (object): The longitude and latitude of the top right corner of your floor plan.
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'configure', 'floorPlans'],
'operation': 'createNetworkFloorPlan'
}
resource = f'/networks/{networkId}/floorPlans'
body_params = ['name', 'center', 'bottomLeftCorner', 'bottomRightCorner', 'topLeftCorner', 'topRightCorner', 'imageContents', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkFloorPlan(self, networkId: str, floorPlanId: str):
"""
**Find a floor plan by ID**
https://developer.cisco.com/meraki/api-v1/#!get-network-floor-plan
- networkId (string): (required)
- floorPlanId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'floorPlans'],
'operation': 'getNetworkFloorPlan'
}
resource = f'/networks/{networkId}/floorPlans/{floorPlanId}'
return self._session.get(metadata, resource)
def updateNetworkFloorPlan(self, networkId: str, floorPlanId: str, **kwargs):
"""
**Update a floor plan's geolocation and other meta data**
https://developer.cisco.com/meraki/api-v1/#!update-network-floor-plan
- networkId (string): (required)
- floorPlanId (string): (required)
- name (string): The name of your floor plan.
- center (object): The longitude and latitude of the center of your floor plan. If you want to change the geolocation data of your floor plan, either the 'center' or two adjacent corners (e.g. 'topLeftCorner' and 'bottomLeftCorner') must be specified. If 'center' is specified, the floor plan is placed over that point with no rotation. If two adjacent corners are specified, the floor plan is rotated to line up with the two specified points. The aspect ratio of the floor plan's image is preserved regardless of which corners/center are specified. (This means if that more than two corners are specified, only two corners may be used to preserve the floor plan's aspect ratio.). No two points can have the same latitude, longitude pair.
- bottomLeftCorner (object): The longitude and latitude of the bottom left corner of your floor plan.
- bottomRightCorner (object): The longitude and latitude of the bottom right corner of your floor plan.
- topLeftCorner (object): The longitude and latitude of the top left corner of your floor plan.
- topRightCorner (object): The longitude and latitude of the top right corner of your floor plan.
- imageContents (string): The file contents (a base 64 encoded string) of your new image. Supported formats are PNG, GIF, and JPG. Note that all images are saved as PNG files, regardless of the format they are uploaded in. If you upload a new image, and you do NOT specify any new geolocation fields ('center, 'topLeftCorner', etc), the floor plan will be recentered with no rotation in order to maintain the aspect ratio of your new image.
"""
kwargs.update(locals())
metadata = {
'tags': ['networks', 'configure', 'floorPlans'],
'operation': 'updateNetworkFloorPlan'
}
resource = f'/networks/{networkId}/floorPlans/{floorPlanId}'
body_params = ['name', 'center', 'bottomLeftCorner', 'bottomRightCorner', 'topLeftCorner', 'topRightCorner', 'imageContents', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteNetworkFloorPlan(self, networkId: str, floorPlanId: str):
"""
**Destroy a floor plan**
https://developer.cisco.com/meraki/api-v1/#!delete-network-floor-plan
- networkId (string): (required)
- floorPlanId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'floorPlans'],
'operation': 'deleteNetworkFloorPlan'
}
resource = f'/networks/{networkId}/floorPlans/{floorPlanId}'
return self._session.delete(metadata, resource)
def getNetworkGroupPolicies(self, networkId: str):
"""
**List the group policies in a network**
https://developer.cisco.com/meraki/api-v1/#!get-network-group-policies
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'groupPolicies'],
'operation': 'getNetworkGroupPolicies'
}
resource = f'/networks/{networkId}/groupPolicies'
return self._session.get(metadata, resource)
def createNetworkGroupPolicy(self, networkId: str, name: str, **kwargs):
"""
**Create a group policy**
https://developer.cisco.com/meraki/api-v1/#!create-network-group-policy
- networkId (string): (required)
- name (string): The name for your group policy. Required.
- scheduling (object): The schedule for the group policy. Schedules are applied to days of the week.
- bandwidth (object): The bandwidth settings for clients bound to your group policy.
- firewallAndTrafficShaping (object): The firewall and traffic shaping rules and settings for your policy.
- contentFiltering (object): The content filtering settings for your group policy
- splashAuthSettings (string): Whether clients bound to your policy will bypass splash authorization or behave according to the network's rules. Can be one of 'network default' or 'bypass'. Only available if your network has a wireless configuration.
- vlanTagging (object): The VLAN tagging settings for your group policy. Only available if your network has a wireless configuration.
- bonjourForwarding (object): The Bonjour settings for your group policy. Only valid if your network has a wireless configuration.
"""
kwargs.update(locals())
if 'splashAuthSettings' in kwargs:
options = ['network default', 'bypass']
assert kwargs['splashAuthSettings'] in options, f'''"splashAuthSettings" cannot be "{kwargs['splashAuthSettings']}", & must be set to one of: {options}'''
metadata = {
'tags': ['networks', 'configure', 'groupPolicies'],
'operation': 'createNetworkGroupPolicy'
}
resource = f'/networks/{networkId}/groupPolicies'
body_params = ['name', 'scheduling', 'bandwidth', 'firewallAndTrafficShaping', 'contentFiltering', 'splashAuthSettings', 'vlanTagging', 'bonjourForwarding', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkGroupPolicy(self, networkId: str, groupPolicyId: str):
"""
**Display a group policy**
https://developer.cisco.com/meraki/api-v1/#!get-network-group-policy
- networkId (string): (required)
- groupPolicyId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'groupPolicies'],
'operation': 'getNetworkGroupPolicy'
}
resource = f'/networks/{networkId}/groupPolicies/{groupPolicyId}'
return self._session.get(metadata, resource)
def updateNetworkGroupPolicy(self, networkId: str, groupPolicyId: str, **kwargs):
"""
**Update a group policy**
https://developer.cisco.com/meraki/api-v1/#!update-network-group-policy
- networkId (string): (required)
- groupPolicyId (string): (required)
- name (string): The name for your group policy.
- scheduling (object): The schedule for the group policy. Schedules are applied to days of the week.
- bandwidth (object): The bandwidth settings for clients bound to your group policy.
- firewallAndTrafficShaping (object): The firewall and traffic shaping rules and settings for your policy.
- contentFiltering (object): The content filtering settings for your group policy
- splashAuthSettings (string): Whether clients bound to your policy will bypass splash authorization or behave according to the network's rules. Can be one of 'network default' or 'bypass'. Only available if your network has a wireless configuration.
- vlanTagging (object): The VLAN tagging settings for your group policy. Only available if your network has a wireless configuration.
- bonjourForwarding (object): The Bonjour settings for your group policy. Only valid if your network has a wireless configuration.
"""
kwargs.update(locals())
if 'splashAuthSettings' in kwargs:
options = ['network default', 'bypass']
assert kwargs['splashAuthSettings'] in options, f'''"splashAuthSettings" cannot be "{kwargs['splashAuthSettings']}", & must be set to one of: {options}'''
metadata = {
'tags': ['networks', 'configure', 'groupPolicies'],
'operation': 'updateNetworkGroupPolicy'
}
resource = f'/networks/{networkId}/groupPolicies/{groupPolicyId}'
body_params = ['name', 'scheduling', 'bandwidth', 'firewallAndTrafficShaping', 'contentFiltering', 'splashAuthSettings', 'vlanTagging', 'bonjourForwarding', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteNetworkGroupPolicy(self, networkId: str, groupPolicyId: str):
"""
**Delete a group policy**
https://developer.cisco.com/meraki/api-v1/#!delete-network-group-policy
- networkId (string): (required)
- groupPolicyId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'groupPolicies'],
'operation': 'deleteNetworkGroupPolicy'
}
resource = f'/networks/{networkId}/groupPolicies/{groupPolicyId}'
return self._session.delete(metadata, resource)
def getNetworkMerakiAuthUsers(self, networkId: str):
"""
**List the users configured under Meraki Authentication for a network (splash guest or RADIUS users for a wireless network, or client VPN users for a wired network)**
https://developer.cisco.com/meraki/api-v1/#!get-network-meraki-auth-users
- networkId (string): (required)
"""
metadata = {
'tags': ['networks', 'configure', 'merakiAuthUsers'],
'operation': 'getNetworkMerakiAuthUsers'
}
resource = f'/networks/{networkId}/merakiAuthUsers'
return self._session.get(metadata, resource)
def createNetworkMerakiAuthUser(self, networkId: str, email: str, name: str, password: str, authorizations: list, **kwargs):
"""
**Authorize a user configured with Meraki Authentication for a network (currently supports 802.1X, splash guest, and client VPN users, and currently, organizations have a 50,000 user cap)**
https://developer.cisco.com/meraki/api-v1/#!create-network-meraki-auth-user
- networkId (string): (required)
- email (string): Email address of the user
- name (string): Name of the user
- password (string): The password for this user account
- authorizations (array): Authorization zones and expiration dates for the user.
- accountType (string): Authorization type for user. Can be 'Guest' or '802.1X' for wireless networks, or 'Client VPN' for wired networks. Defaults to '802.1X'.
- emailPasswordToUser (boolean): Whether or not Meraki should email the password to user. Default is false.
"""
kwargs.update(locals())
if 'accountType' in kwargs:
options = ['Guest', '802.1X', 'Client VPN']
assert kwargs['accountType'] in options, f'''"accountType" cannot be "{kwargs['accountType']}", & must be set to one of: {options}'''
metadata = {
'tags': ['networks', 'configure', 'merakiAuthUsers'],
'operation': 'createNetworkMerakiAuthUser'
}
resource = f'/networks/{networkId}/merakiAuthUsers'
body_params = ['email', 'name', 'password', 'accountType', 'emailPasswordToUser', 'authorizations', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkMerakiAuthUser(self, networkId: str, merakiAuthUserId: str):
"""
**Return the Meraki Auth splash guest, RADIUS, or client VPN user**
https://developer.cisco.com/meraki/api-v1/#!get-network-meraki-auth-user
- networkId (string): (required)