forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch_settings.py
More file actions
437 lines (329 loc) · 17.7 KB
/
Copy pathswitch_settings.py
File metadata and controls
437 lines (329 loc) · 17.7 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
class SwitchSettings(object):
def __init__(self, session):
super(SwitchSettings, self).__init__()
self._session = session
def getNetworkSwitchSettings(self, networkId: str):
"""
**Returns the switch network settings**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettings',
}
resource = f'/networks/{networkId}/switch/settings'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettings(self, networkId: str, **kwargs):
"""
**Update switch network settings**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings
- networkId (string)
- vlan (integer): Management VLAN
- useCombinedPower (boolean): The use Combined Power as the default behavior of secondary power supplies on supported devices.
- powerExceptions (array): Exceptions on a per switch basis to "useCombinedPower"
"""
kwargs.update(locals())
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettings',
}
resource = f'/networks/{networkId}/switch/settings'
body_params = ['vlan', 'useCombinedPower', 'powerExceptions']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsDhcpServerPolicy(self, networkId: str):
"""
**Return the DHCP server policy**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-dhcp-server-policy
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsDhcpServerPolicy',
}
resource = f'/networks/{networkId}/switch/settings/dhcpServerPolicy'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettingsDhcpServerPolicy(self, networkId: str, **kwargs):
"""
**Update the DHCP server policy**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-dhcp-server-policy
- networkId (string)
- defaultPolicy (string): 'allow' or 'block' new DHCP servers. Default value is 'allow'.
- allowedServers (array): List the MAC addresses of DHCP servers to permit on the network. Applicable only if defaultPolicy is set to block. An empty array will clear the entries.
- blockedServers (array): List the MAC addresses of DHCP servers to block on the network. Applicable only if defaultPolicy is set to allow. An empty array will clear the entries.
"""
kwargs.update(locals())
if 'defaultPolicy' in kwargs:
options = ['allow', 'block']
assert kwargs['defaultPolicy'] in options, f'''"defaultPolicy" cannot be "{kwargs['defaultPolicy']}", & must be set to one of: {options}'''
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsDhcpServerPolicy',
}
resource = f'/networks/{networkId}/switch/settings/dhcpServerPolicy'
body_params = ['defaultPolicy', 'allowedServers', 'blockedServers']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsDscpToCosMappings(self, networkId: str):
"""
**Return the DSCP to CoS mappings**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-dscp-to-cos-mappings
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsDscpToCosMappings',
}
resource = f'/networks/{networkId}/switch/settings/dscpToCosMappings'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettingsDscpToCosMappings(self, networkId: str, mappings: list):
"""
**Update the DSCP to CoS mappings**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-dscp-to-cos-mappings
- networkId (string)
- mappings (array): An array of DSCP to CoS mappings. An empty array will reset the mappings to default.
"""
kwargs = locals()
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsDscpToCosMappings',
}
resource = f'/networks/{networkId}/switch/settings/dscpToCosMappings'
body_params = ['mappings']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsMtu(self, networkId: str):
"""
**Return the MTU configuration**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-mtu
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsMtu',
}
resource = f'/networks/{networkId}/switch/settings/mtu'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettingsMtu(self, networkId: str, **kwargs):
"""
**Update the MTU configuration**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-mtu
- networkId (string)
- defaultMtuSize (integer): MTU size for the entire network. Default value is 9578.
- overrides (array): Override MTU size for individual switches or switch profiles. An empty array will clear overrides.
"""
kwargs.update(locals())
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsMtu',
}
resource = f'/networks/{networkId}/switch/settings/mtu'
body_params = ['defaultMtuSize', 'overrides']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsMulticast(self, networkId: str):
"""
**Return multicast settings for a network**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-multicast
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsMulticast',
}
resource = f'/networks/{networkId}/switch/settings/multicast'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettingsMulticast(self, networkId: str, **kwargs):
"""
**Update multicast settings for a network**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-multicast
- networkId (string)
- defaultSettings (object): Default multicast setting for entire network. IGMP snooping and Flood unknown multicast traffic settings are enabled by default.
- overrides (array): Array of paired switches/stacks/profiles and corresponding multicast settings. An empty array will clear the multicast settings.
"""
kwargs.update(locals())
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsMulticast',
}
resource = f'/networks/{networkId}/switch/settings/multicast'
body_params = ['defaultSettings', 'overrides']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsQosRules(self, networkId: str):
"""
**List quality of service rules**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-qos-rules
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsQosRules',
}
resource = f'/networks/{networkId}/switch/settings/qosRules'
return self._session.get(metadata, resource)
def createNetworkSwitchSettingsQosRule(self, networkId: str, vlan: int, **kwargs):
"""
**Add a quality of service rule**
https://developer.cisco.com/meraki/api/#!create-network-switch-settings-qos-rule
- networkId (string)
- vlan (integer): The VLAN of the incoming packet. A null value will match any VLAN.
- protocol (string): The protocol of the incoming packet. Can be one of "ANY", "TCP" or "UDP". Default value is "ANY"
- srcPort (integer): The source port of the incoming packet. Applicable only if protocol is TCP or UDP.
- srcPortRange (string): The source port range of the incoming packet. Applicable only if protocol is set to TCP or UDP. Example: 70-80
- dstPort (integer): The destination port of the incoming packet. Applicable only if protocol is TCP or UDP.
- dstPortRange (string): The destination port range of the incoming packet. Applicable only if protocol is set to TCP or UDP. Example: 70-80
- dscp (integer): DSCP tag. Set this to -1 to trust incoming DSCP. Default value is 0
"""
kwargs.update(locals())
if 'protocol' in kwargs:
options = ['ANY', 'TCP', 'UDP']
assert kwargs['protocol'] in options, f'''"protocol" cannot be "{kwargs['protocol']}", & must be set to one of: {options}'''
metadata = {
'tags': ['Switch settings'],
'operation': 'createNetworkSwitchSettingsQosRule',
}
resource = f'/networks/{networkId}/switch/settings/qosRules'
body_params = ['vlan', 'protocol', 'srcPort', 'srcPortRange', 'dstPort', 'dstPortRange', 'dscp']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkSwitchSettingsQosRulesOrder(self, networkId: str):
"""
**Return the quality of service rule IDs by order in which they will be processed by the switch**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-qos-rules-order
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsQosRulesOrder',
}
resource = f'/networks/{networkId}/switch/settings/qosRules/order'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettingsQosRulesOrder(self, networkId: str, ruleIds: list):
"""
**Update the order in which the rules should be processed by the switch**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-qos-rules-order
- networkId (string)
- ruleIds (array): A list of quality of service rule IDs arranged in order in which they should be processed by the switch.
"""
kwargs = locals()
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsQosRulesOrder',
}
resource = f'/networks/{networkId}/switch/settings/qosRules/order'
body_params = ['ruleIds']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsQosRule(self, networkId: str, qosRuleId: str):
"""
**Return a quality of service rule**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-qos-rule
- networkId (string)
- qosRuleId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsQosRule',
}
resource = f'/networks/{networkId}/switch/settings/qosRules/{qosRuleId}'
return self._session.get(metadata, resource)
def deleteNetworkSwitchSettingsQosRule(self, networkId: str, qosRuleId: str):
"""
**Delete a quality of service rule**
https://developer.cisco.com/meraki/api/#!delete-network-switch-settings-qos-rule
- networkId (string)
- qosRuleId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'deleteNetworkSwitchSettingsQosRule',
}
resource = f'/networks/{networkId}/switch/settings/qosRules/{qosRuleId}'
return self._session.delete(metadata, resource)
def updateNetworkSwitchSettingsQosRule(self, networkId: str, qosRuleId: str, **kwargs):
"""
**Update a quality of service rule**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-qos-rule
- networkId (string)
- qosRuleId (string)
- vlan (integer): The VLAN of the incoming packet. A null value will match any VLAN.
- protocol (string): The protocol of the incoming packet. Can be one of "ANY", "TCP" or "UDP". Default value is "ANY".
- srcPort (integer): The source port of the incoming packet. Applicable only if protocol is TCP or UDP.
- srcPortRange (string): The source port range of the incoming packet. Applicable only if protocol is set to TCP or UDP. Example: 70-80
- dstPort (integer): The destination port of the incoming packet. Applicable only if protocol is TCP or UDP.
- dstPortRange (string): The destination port range of the incoming packet. Applicable only if protocol is set to TCP or UDP. Example: 70-80
- dscp (integer): DSCP tag that should be assigned to incoming packet. Set this to -1 to trust incoming DSCP. Default value is 0.
"""
kwargs.update(locals())
if 'protocol' in kwargs:
options = ['ANY', 'TCP', 'UDP']
assert kwargs['protocol'] in options, f'''"protocol" cannot be "{kwargs['protocol']}", & must be set to one of: {options}'''
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsQosRule',
}
resource = f'/networks/{networkId}/switch/settings/qosRules/{qosRuleId}'
body_params = ['vlan', 'protocol', 'srcPort', 'srcPortRange', 'dstPort', 'dstPortRange', 'dscp']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsStormControl(self, networkId: str):
"""
**Return the storm control configuration for a switch network**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-storm-control
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsStormControl',
}
resource = f'/networks/{networkId}/switch/settings/stormControl'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettingsStormControl(self, networkId: str, **kwargs):
"""
**Update the storm control configuration for a switch network**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-storm-control
- networkId (string)
- broadcastThreshold (integer): Percentage (1 to 99) of total available port bandwidth for broadcast traffic type. Default value 100 percent rate is to clear the configuration.
- multicastThreshold (integer): Percentage (1 to 99) of total available port bandwidth for multicast traffic type. Default value 100 percent rate is to clear the configuration.
- unknownUnicastThreshold (integer): Percentage (1 to 99) of total available port bandwidth for unknown unicast (dlf-destination lookup failure) traffic type. Default value 100 percent rate is to clear the configuration.
"""
kwargs.update(locals())
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsStormControl',
}
resource = f'/networks/{networkId}/switch/settings/stormControl'
body_params = ['broadcastThreshold', 'multicastThreshold', 'unknownUnicastThreshold']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getNetworkSwitchSettingsStp(self, networkId: str):
"""
**Returns STP settings**
https://developer.cisco.com/meraki/api/#!get-network-switch-settings-stp
- networkId (string)
"""
metadata = {
'tags': ['Switch settings'],
'operation': 'getNetworkSwitchSettingsStp',
}
resource = f'/networks/{networkId}/switch/settings/stp'
return self._session.get(metadata, resource)
def updateNetworkSwitchSettingsStp(self, networkId: str, **kwargs):
"""
**Updates STP settings**
https://developer.cisco.com/meraki/api/#!update-network-switch-settings-stp
- networkId (string)
- rstpEnabled (boolean): The spanning tree protocol status in network
- stpBridgePriority (array): STP bridge priority for switches/stacks or switch profiles. An empty array will clear the STP bridge priority settings.
"""
kwargs.update(locals())
metadata = {
'tags': ['Switch settings'],
'operation': 'updateNetworkSwitchSettingsStp',
}
resource = f'/networks/{networkId}/switch/settings/stp'
body_params = ['rstpEnabled', 'stpBridgePriority']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)