forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganizations.py
More file actions
3653 lines (2645 loc) · 182 KB
/
Copy pathorganizations.py
File metadata and controls
3653 lines (2645 loc) · 182 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 Organizations(object):
def __init__(self, session):
super(Organizations, self).__init__()
self._session = session
def getOrganizations(self):
"""
**List the organizations that the user has privileges on**
https://developer.cisco.com/meraki/api-v1/#!get-organizations
"""
metadata = {
'tags': ['organizations', 'configure'],
'operation': 'getOrganizations'
}
resource = f'/organizations'
return self._session.get(metadata, resource)
def createOrganization(self, name: str, **kwargs):
"""
**Create a new organization**
https://developer.cisco.com/meraki/api-v1/#!create-organization
- name (string): The name of the organization
- management (object): Information about the organization's management system
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'configure'],
'operation': 'createOrganization'
}
resource = f'/organizations'
body_params = ['name', 'management', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getOrganization(self, organizationId: str):
"""
**Return an organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure'],
'operation': 'getOrganization'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}'
return self._session.get(metadata, resource)
def updateOrganization(self, organizationId: str, **kwargs):
"""
**Update an organization**
https://developer.cisco.com/meraki/api-v1/#!update-organization
- organizationId (string): Organization ID
- name (string): The name of the organization
- management (object): Information about the organization's management system
- api (object): API-specific settings
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'configure'],
'operation': 'updateOrganization'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}'
body_params = ['name', 'management', 'api', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteOrganization(self, organizationId: str):
"""
**Delete an organization**
https://developer.cisco.com/meraki/api-v1/#!delete-organization
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure'],
'operation': 'deleteOrganization'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}'
return self._session.delete(metadata, resource)
def createOrganizationActionBatch(self, organizationId: str, actions: list, **kwargs):
"""
**Create an action batch**
https://developer.cisco.com/meraki/api-v1/#!create-organization-action-batch
- organizationId (string): Organization ID
- actions (array): A set of changes to make as part of this action (<a href='https://developer.cisco.com/meraki/api/#/rest/guides/action-batches/'>more details</a>)
- confirmed (boolean): Set to true for immediate execution. Set to false if the action should be previewed before executing. This property cannot be unset once it is true. Defaults to false.
- synchronous (boolean): Set to true to force the batch to run synchronous. There can be at most 20 actions in synchronous batch. Defaults to false.
- callback (object): Details for the callback. Please include either an httpServerId OR url and sharedSecret
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'configure', 'actionBatches'],
'operation': 'createOrganizationActionBatch'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/actionBatches'
body_params = ['confirmed', 'synchronous', 'actions', 'callback', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getOrganizationActionBatches(self, organizationId: str, **kwargs):
"""
**Return the list of action batches in the organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-action-batches
- organizationId (string): Organization ID
- status (string): Filter batches by status. Valid types are pending, completed, and failed.
"""
kwargs.update(locals())
if 'status' in kwargs:
options = ['completed', 'failed', 'pending']
assert kwargs['status'] in options, f'''"status" cannot be "{kwargs['status']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'actionBatches'],
'operation': 'getOrganizationActionBatches'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/actionBatches'
query_params = ['status', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def getOrganizationActionBatch(self, organizationId: str, actionBatchId: str):
"""
**Return an action batch**
https://developer.cisco.com/meraki/api-v1/#!get-organization-action-batch
- organizationId (string): Organization ID
- actionBatchId (string): Action batch ID
"""
metadata = {
'tags': ['organizations', 'configure', 'actionBatches'],
'operation': 'getOrganizationActionBatch'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
actionBatchId = urllib.parse.quote(str(actionBatchId), safe='')
resource = f'/organizations/{organizationId}/actionBatches/{actionBatchId}'
return self._session.get(metadata, resource)
def deleteOrganizationActionBatch(self, organizationId: str, actionBatchId: str):
"""
**Delete an action batch**
https://developer.cisco.com/meraki/api-v1/#!delete-organization-action-batch
- organizationId (string): Organization ID
- actionBatchId (string): Action batch ID
"""
metadata = {
'tags': ['organizations', 'configure', 'actionBatches'],
'operation': 'deleteOrganizationActionBatch'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
actionBatchId = urllib.parse.quote(str(actionBatchId), safe='')
resource = f'/organizations/{organizationId}/actionBatches/{actionBatchId}'
return self._session.delete(metadata, resource)
def updateOrganizationActionBatch(self, organizationId: str, actionBatchId: str, **kwargs):
"""
**Update an action batch**
https://developer.cisco.com/meraki/api-v1/#!update-organization-action-batch
- organizationId (string): Organization ID
- actionBatchId (string): Action batch ID
- confirmed (boolean): A boolean representing whether or not the batch has been confirmed. This property cannot be unset once it is true.
- synchronous (boolean): Set to true to force the batch to run synchronous. There can be at most 20 actions in synchronous batch.
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'configure', 'actionBatches'],
'operation': 'updateOrganizationActionBatch'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
actionBatchId = urllib.parse.quote(str(actionBatchId), safe='')
resource = f'/organizations/{organizationId}/actionBatches/{actionBatchId}'
body_params = ['confirmed', 'synchronous', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def getOrganizationAdaptivePolicyAcls(self, organizationId: str):
"""
**List adaptive policy ACLs in a organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-acls
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'acls'],
'operation': 'getOrganizationAdaptivePolicyAcls'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/acls'
return self._session.get(metadata, resource)
def createOrganizationAdaptivePolicyAcl(self, organizationId: str, name: str, rules: list, ipVersion: str, **kwargs):
"""
**Creates new adaptive policy ACL**
https://developer.cisco.com/meraki/api-v1/#!create-organization-adaptive-policy-acl
- organizationId (string): Organization ID
- name (string): Name of the adaptive policy ACL
- rules (array): An ordered array of the adaptive policy ACL rules.
- ipVersion (string): IP version of adpative policy ACL. One of: 'any', 'ipv4' or 'ipv6'
- description (string): Description of the adaptive policy ACL
"""
kwargs.update(locals())
if 'ipVersion' in kwargs:
options = ['any', 'ipv4', 'ipv6']
assert kwargs['ipVersion'] in options, f'''"ipVersion" cannot be "{kwargs['ipVersion']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'acls'],
'operation': 'createOrganizationAdaptivePolicyAcl'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/acls'
body_params = ['name', 'description', 'rules', 'ipVersion', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getOrganizationAdaptivePolicyAcl(self, organizationId: str, aclId: str):
"""
**Returns the adaptive policy ACL information**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-acl
- organizationId (string): Organization ID
- aclId (string): Acl ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'acls'],
'operation': 'getOrganizationAdaptivePolicyAcl'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
aclId = urllib.parse.quote(str(aclId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/acls/{aclId}'
return self._session.get(metadata, resource)
def updateOrganizationAdaptivePolicyAcl(self, organizationId: str, aclId: str, **kwargs):
"""
**Updates an adaptive policy ACL**
https://developer.cisco.com/meraki/api-v1/#!update-organization-adaptive-policy-acl
- organizationId (string): Organization ID
- aclId (string): Acl ID
- name (string): Name of the adaptive policy ACL
- description (string): Description of the adaptive policy ACL
- rules (array): An ordered array of the adaptive policy ACL rules. An empty array will clear the rules.
- ipVersion (string): IP version of adpative policy ACL. One of: 'any', 'ipv4' or 'ipv6'
"""
kwargs.update(locals())
if 'ipVersion' in kwargs:
options = ['any', 'ipv4', 'ipv6']
assert kwargs['ipVersion'] in options, f'''"ipVersion" cannot be "{kwargs['ipVersion']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'acls'],
'operation': 'updateOrganizationAdaptivePolicyAcl'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
aclId = urllib.parse.quote(str(aclId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/acls/{aclId}'
body_params = ['name', 'description', 'rules', 'ipVersion', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteOrganizationAdaptivePolicyAcl(self, organizationId: str, aclId: str):
"""
**Deletes the specified adaptive policy ACL**
https://developer.cisco.com/meraki/api-v1/#!delete-organization-adaptive-policy-acl
- organizationId (string): Organization ID
- aclId (string): Acl ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'acls'],
'operation': 'deleteOrganizationAdaptivePolicyAcl'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
aclId = urllib.parse.quote(str(aclId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/acls/{aclId}'
return self._session.delete(metadata, resource)
def getOrganizationAdaptivePolicyGroups(self, organizationId: str):
"""
**List adaptive policy groups in a organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-groups
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'groups'],
'operation': 'getOrganizationAdaptivePolicyGroups'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/groups'
return self._session.get(metadata, resource)
def createOrganizationAdaptivePolicyGroup(self, organizationId: str, name: str, sgt: int, **kwargs):
"""
**Creates a new adaptive policy group**
https://developer.cisco.com/meraki/api-v1/#!create-organization-adaptive-policy-group
- organizationId (string): Organization ID
- name (string): Name of the group
- sgt (integer): SGT value of the group
- description (string): Description of the group (default: "")
- policyObjects (array): The policy objects that belong to this group; traffic from addresses specified by these policy objects will be tagged with this group's SGT value if no other tagging scheme is being used (each requires one unique attribute) (default: [])
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'groups'],
'operation': 'createOrganizationAdaptivePolicyGroup'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/groups'
body_params = ['name', 'sgt', 'description', 'policyObjects', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getOrganizationAdaptivePolicyGroup(self, organizationId: str, id: str):
"""
**Returns an adaptive policy group**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-group
- organizationId (string): Organization ID
- id (string): ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'groups'],
'operation': 'getOrganizationAdaptivePolicyGroup'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
id = urllib.parse.quote(str(id), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/groups/{id}'
return self._session.get(metadata, resource)
def updateOrganizationAdaptivePolicyGroup(self, organizationId: str, id: str, **kwargs):
"""
**Updates an adaptive policy group**
https://developer.cisco.com/meraki/api-v1/#!update-organization-adaptive-policy-group
- organizationId (string): Organization ID
- id (string): ID
- name (string): Name of the group
- sgt (integer): SGT value of the group
- description (string): Description of the group
- policyObjects (array): The policy objects that belong to this group; traffic from addresses specified by these policy objects will be tagged with this group's SGT value if no other tagging scheme is being used (each requires one unique attribute)
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'groups'],
'operation': 'updateOrganizationAdaptivePolicyGroup'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
id = urllib.parse.quote(str(id), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/groups/{id}'
body_params = ['name', 'sgt', 'description', 'policyObjects', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteOrganizationAdaptivePolicyGroup(self, organizationId: str, id: str):
"""
**Deletes the specified adaptive policy group and any associated policies and references**
https://developer.cisco.com/meraki/api-v1/#!delete-organization-adaptive-policy-group
- organizationId (string): Organization ID
- id (string): ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'groups'],
'operation': 'deleteOrganizationAdaptivePolicyGroup'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
id = urllib.parse.quote(str(id), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/groups/{id}'
return self._session.delete(metadata, resource)
def getOrganizationAdaptivePolicyOverview(self, organizationId: str):
"""
**Returns adaptive policy aggregate statistics for an organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-overview
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'monitor', 'adaptivePolicy', 'overview'],
'operation': 'getOrganizationAdaptivePolicyOverview'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/overview'
return self._session.get(metadata, resource)
def getOrganizationAdaptivePolicyPolicies(self, organizationId: str):
"""
**List adaptive policies in an organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-policies
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'policies'],
'operation': 'getOrganizationAdaptivePolicyPolicies'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/policies'
return self._session.get(metadata, resource)
def createOrganizationAdaptivePolicyPolicy(self, organizationId: str, sourceGroup: dict, destinationGroup: dict, **kwargs):
"""
**Add an Adaptive Policy**
https://developer.cisco.com/meraki/api-v1/#!create-organization-adaptive-policy-policy
- organizationId (string): Organization ID
- sourceGroup (object): The source adaptive policy group (requires one unique attribute)
- destinationGroup (object): The destination adaptive policy group (requires one unique attribute)
- acls (array): An ordered array of adaptive policy ACLs (each requires one unique attribute) that apply to this policy (default: [])
- lastEntryRule (string): The rule to apply if there is no matching ACL (default: "default")
"""
kwargs.update(locals())
if 'lastEntryRule' in kwargs:
options = ['allow', 'default', 'deny']
assert kwargs['lastEntryRule'] in options, f'''"lastEntryRule" cannot be "{kwargs['lastEntryRule']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'policies'],
'operation': 'createOrganizationAdaptivePolicyPolicy'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/policies'
body_params = ['sourceGroup', 'destinationGroup', 'acls', 'lastEntryRule', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getOrganizationAdaptivePolicyPolicy(self, organizationId: str, id: str):
"""
**Return an adaptive policy**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-policy
- organizationId (string): Organization ID
- id (string): ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'policies'],
'operation': 'getOrganizationAdaptivePolicyPolicy'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
id = urllib.parse.quote(str(id), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/policies/{id}'
return self._session.get(metadata, resource)
def updateOrganizationAdaptivePolicyPolicy(self, organizationId: str, id: str, **kwargs):
"""
**Update an Adaptive Policy**
https://developer.cisco.com/meraki/api-v1/#!update-organization-adaptive-policy-policy
- organizationId (string): Organization ID
- id (string): ID
- sourceGroup (object): The source adaptive policy group (requires one unique attribute)
- destinationGroup (object): The destination adaptive policy group (requires one unique attribute)
- acls (array): An ordered array of adaptive policy ACLs (each requires one unique attribute) that apply to this policy
- lastEntryRule (string): The rule to apply if there is no matching ACL
"""
kwargs.update(locals())
if 'lastEntryRule' in kwargs:
options = ['allow', 'default', 'deny']
assert kwargs['lastEntryRule'] in options, f'''"lastEntryRule" cannot be "{kwargs['lastEntryRule']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'policies'],
'operation': 'updateOrganizationAdaptivePolicyPolicy'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
id = urllib.parse.quote(str(id), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/policies/{id}'
body_params = ['sourceGroup', 'destinationGroup', 'acls', 'lastEntryRule', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteOrganizationAdaptivePolicyPolicy(self, organizationId: str, id: str):
"""
**Delete an Adaptive Policy**
https://developer.cisco.com/meraki/api-v1/#!delete-organization-adaptive-policy-policy
- organizationId (string): Organization ID
- id (string): ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'policies'],
'operation': 'deleteOrganizationAdaptivePolicyPolicy'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
id = urllib.parse.quote(str(id), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/policies/{id}'
return self._session.delete(metadata, resource)
def getOrganizationAdaptivePolicySettings(self, organizationId: str):
"""
**Returns global adaptive policy settings in an organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-adaptive-policy-settings
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'settings'],
'operation': 'getOrganizationAdaptivePolicySettings'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/settings'
return self._session.get(metadata, resource)
def updateOrganizationAdaptivePolicySettings(self, organizationId: str, **kwargs):
"""
**Update global adaptive policy settings**
https://developer.cisco.com/meraki/api-v1/#!update-organization-adaptive-policy-settings
- organizationId (string): Organization ID
- enabledNetworks (array): List of network IDs with adaptive policy enabled
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'configure', 'adaptivePolicy', 'settings'],
'operation': 'updateOrganizationAdaptivePolicySettings'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/adaptivePolicy/settings'
body_params = ['enabledNetworks', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def getOrganizationAdmins(self, organizationId: str):
"""
**List the dashboard administrators in this organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-admins
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure', 'admins'],
'operation': 'getOrganizationAdmins'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/admins'
return self._session.get(metadata, resource)
def createOrganizationAdmin(self, organizationId: str, email: str, name: str, orgAccess: str, **kwargs):
"""
**Create a new dashboard administrator**
https://developer.cisco.com/meraki/api-v1/#!create-organization-admin
- organizationId (string): Organization ID
- email (string): The email of the dashboard administrator. This attribute can not be updated.
- name (string): The name of the dashboard administrator
- orgAccess (string): The privilege of the dashboard administrator on the organization. Can be one of 'full', 'read-only', 'enterprise' or 'none'
- tags (array): The list of tags that the dashboard administrator has privileges on
- networks (array): The list of networks that the dashboard administrator has privileges on
- authenticationMethod (string): The method of authentication the user will use to sign in to the Meraki dashboard. Can be one of 'Email' or 'Cisco SecureX Sign-On'. The default is Email authentication
"""
kwargs.update(locals())
if 'orgAccess' in kwargs:
options = ['enterprise', 'full', 'none', 'read-only']
assert kwargs['orgAccess'] in options, f'''"orgAccess" cannot be "{kwargs['orgAccess']}", & must be set to one of: {options}'''
if 'authenticationMethod' in kwargs:
options = ['Cisco SecureX Sign-On', 'Email']
assert kwargs['authenticationMethod'] in options, f'''"authenticationMethod" cannot be "{kwargs['authenticationMethod']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'admins'],
'operation': 'createOrganizationAdmin'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/admins'
body_params = ['email', 'name', 'orgAccess', 'tags', 'networks', 'authenticationMethod', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def updateOrganizationAdmin(self, organizationId: str, adminId: str, **kwargs):
"""
**Update an administrator**
https://developer.cisco.com/meraki/api-v1/#!update-organization-admin
- organizationId (string): Organization ID
- adminId (string): Admin ID
- name (string): The name of the dashboard administrator
- orgAccess (string): The privilege of the dashboard administrator on the organization. Can be one of 'full', 'read-only', 'enterprise' or 'none'
- tags (array): The list of tags that the dashboard administrator has privileges on
- networks (array): The list of networks that the dashboard administrator has privileges on
"""
kwargs.update(locals())
if 'orgAccess' in kwargs:
options = ['enterprise', 'full', 'none', 'read-only']
assert kwargs['orgAccess'] in options, f'''"orgAccess" cannot be "{kwargs['orgAccess']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'admins'],
'operation': 'updateOrganizationAdmin'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
adminId = urllib.parse.quote(str(adminId), safe='')
resource = f'/organizations/{organizationId}/admins/{adminId}'
body_params = ['name', 'orgAccess', 'tags', 'networks', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteOrganizationAdmin(self, organizationId: str, adminId: str):
"""
**Revoke all access for a dashboard administrator within this organization**
https://developer.cisco.com/meraki/api-v1/#!delete-organization-admin
- organizationId (string): Organization ID
- adminId (string): Admin ID
"""
metadata = {
'tags': ['organizations', 'configure', 'admins'],
'operation': 'deleteOrganizationAdmin'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
adminId = urllib.parse.quote(str(adminId), safe='')
resource = f'/organizations/{organizationId}/admins/{adminId}'
return self._session.delete(metadata, resource)
def getOrganizationAlertsProfiles(self, organizationId: str):
"""
**List all organization-wide alert configurations**
https://developer.cisco.com/meraki/api-v1/#!get-organization-alerts-profiles
- organizationId (string): Organization ID
"""
metadata = {
'tags': ['organizations', 'configure', 'alerts', 'profiles'],
'operation': 'getOrganizationAlertsProfiles'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/alerts/profiles'
return self._session.get(metadata, resource)
def createOrganizationAlertsProfile(self, organizationId: str, type: str, alertCondition: dict, recipients: dict, networkTags: list, **kwargs):
"""
**Create an organization-wide alert configuration**
https://developer.cisco.com/meraki/api-v1/#!create-organization-alerts-profile
- organizationId (string): Organization ID
- type (string): The alert type
- alertCondition (object): The conditions that determine if the alert triggers
- recipients (object): List of recipients that will recieve the alert.
- networkTags (array): Networks with these tags will be monitored for the alert
- description (string): User supplied description of the alert
"""
kwargs.update(locals())
if 'type' in kwargs:
options = ['appOutage', 'voipJitter', 'voipMos', 'voipPacketLoss', 'wanLatency', 'wanPacketLoss', 'wanStatus', 'wanUtilization']
assert kwargs['type'] in options, f'''"type" cannot be "{kwargs['type']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'alerts', 'profiles'],
'operation': 'createOrganizationAlertsProfile'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/alerts/profiles'
body_params = ['type', 'alertCondition', 'recipients', 'networkTags', 'description', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def updateOrganizationAlertsProfile(self, organizationId: str, alertConfigId: str, **kwargs):
"""
**Update an organization-wide alert config**
https://developer.cisco.com/meraki/api-v1/#!update-organization-alerts-profile
- organizationId (string): Organization ID
- alertConfigId (string): Alert config ID
- enabled (boolean): Is the alert config enabled
- type (string): The alert type
- alertCondition (object): The conditions that determine if the alert triggers
- recipients (object): List of recipients that will recieve the alert.
- networkTags (array): Networks with these tags will be monitored for the alert
- description (string): User supplied description of the alert
"""
kwargs.update(locals())
if 'type' in kwargs:
options = ['appOutage', 'voipJitter', 'voipMos', 'voipPacketLoss', 'wanLatency', 'wanPacketLoss', 'wanStatus', 'wanUtilization']
assert kwargs['type'] in options, f'''"type" cannot be "{kwargs['type']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'configure', 'alerts', 'profiles'],
'operation': 'updateOrganizationAlertsProfile'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
alertConfigId = urllib.parse.quote(str(alertConfigId), safe='')
resource = f'/organizations/{organizationId}/alerts/profiles/{alertConfigId}'
body_params = ['enabled', 'type', 'alertCondition', 'recipients', 'networkTags', 'description', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.put(metadata, resource, payload)
def deleteOrganizationAlertsProfile(self, organizationId: str, alertConfigId: str):
"""
**Removes an organization-wide alert config**
https://developer.cisco.com/meraki/api-v1/#!delete-organization-alerts-profile
- organizationId (string): Organization ID
- alertConfigId (string): Alert config ID
"""
metadata = {
'tags': ['organizations', 'configure', 'alerts', 'profiles'],
'operation': 'deleteOrganizationAlertsProfile'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
alertConfigId = urllib.parse.quote(str(alertConfigId), safe='')
resource = f'/organizations/{organizationId}/alerts/profiles/{alertConfigId}'
return self._session.delete(metadata, resource)
def getOrganizationApiRequests(self, organizationId: str, total_pages=1, direction='next', **kwargs):
"""
**List the API requests made by an organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-api-requests
- organizationId (string): Organization 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
- 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 31 days.
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 50.
- 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.
- adminId (string): Filter the results by the ID of the admin who made the API requests
- path (string): Filter the results by the path of the API requests
- method (string): Filter the results by the method of the API requests (must be 'GET', 'PUT', 'POST' or 'DELETE')
- responseCode (integer): Filter the results by the response code of the API requests
- sourceIp (string): Filter the results by the IP address of the originating API request
- userAgent (string): Filter the results by the user agent string of the API request
- version (integer): Filter the results by the API version of the API request
- operationIds (array): Filter the results by one or more operation IDs for the API request
"""
kwargs.update(locals())
if 'method' in kwargs:
options = ['DELETE', 'GET', 'POST', 'PUT']
assert kwargs['method'] in options, f'''"method" cannot be "{kwargs['method']}", & must be set to one of: {options}'''
if 'version' in kwargs:
options = [0, 1]
assert kwargs['version'] in options, f'''"version" cannot be "{kwargs['version']}", & must be set to one of: {options}'''
metadata = {
'tags': ['organizations', 'monitor', 'apiRequests'],
'operation': 'getOrganizationApiRequests'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/apiRequests'
query_params = ['t0', 't1', 'timespan', 'perPage', 'startingAfter', 'endingBefore', 'adminId', 'path', 'method', 'responseCode', 'sourceIp', 'userAgent', 'version', 'operationIds', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['operationIds', ]
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 getOrganizationApiRequestsOverview(self, organizationId: str, **kwargs):
"""
**Return an aggregated overview of API requests data**
https://developer.cisco.com/meraki/api-v1/#!get-organization-api-requests-overview
- organizationId (string): Organization ID
- 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 31 days.
"""
kwargs.update(locals())
metadata = {
'tags': ['organizations', 'monitor', 'apiRequests', 'overview'],
'operation': 'getOrganizationApiRequestsOverview'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/apiRequests/overview'
query_params = ['t0', 't1', 'timespan', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
return self._session.get(metadata, resource, params)
def getOrganizationApiRequestsOverviewResponseCodesByInterval(self, organizationId: str, **kwargs):
"""
**Tracks organizations' API requests by response code across a given time period**
https://developer.cisco.com/meraki/api-v1/#!get-organization-api-requests-overview-response-codes-by-interval
- organizationId (string): Organization ID
- 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 31 days. If interval is provided, the timespan will be autocalculated.
- interval (integer): The time interval in seconds for returned data. The valid intervals are: 120, 3600, 14400, 21600. The default is 21600. Interval is calculated if time params are provided.
- version (integer): Filter by API version of the endpoint. Allowable values are: [0, 1]
- operationIds (array): Filter by operation ID of the endpoint
- sourceIps (array): Filter by source IP that made the API request
- adminIds (array): Filter by admin ID of user that made the API request
- userAgent (string): Filter by user agent string for API request. This will filter by a complete or partial match.
"""
kwargs.update(locals())
if 'version' in kwargs:
options = [0, 1]