forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnmp_settings.py
More file actions
100 lines (77 loc) · 4.2 KB
/
Copy pathsnmp_settings.py
File metadata and controls
100 lines (77 loc) · 4.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
class SNMPSettings(object):
def __init__(self, session):
super(SNMPSettings, self).__init__()
self._session = session
def getNetworkSnmpSettings(self, networkId: str):
"""
**Return the SNMP settings for a network**
https://developer.cisco.com/meraki/api/#!get-network-snmp-settings
- networkId (string)
"""
metadata = {
'tags': ['SNMP settings'],
'operation': 'getNetworkSnmpSettings',
}
resource = f'/networks/{networkId}/snmpSettings'
return self._session.get(metadata, resource)
def updateNetworkSnmpSettings(self, networkId: str, **kwargs):
"""
**Update the SNMP settings for a network**
https://developer.cisco.com/meraki/api/#!update-network-snmp-settings
- networkId (string)
- access (string): The type of SNMP access. Can be one of 'none' (disabled), 'community' (V1/V2c), or 'users' (V3).
- communityString (string): The SNMP community string. Only relevant if 'access' is set to 'community'.
- users (array): The list of SNMP users. Only relevant if 'access' is set to 'users'.
"""
kwargs.update(locals())
if 'access' in kwargs:
options = ['none', 'community', 'users']
assert kwargs['access'] in options, f'''"access" cannot be "{kwargs['access']}", & must be set to one of: {options}'''
metadata = {
'tags': ['SNMP settings'],
'operation': 'updateNetworkSnmpSettings',
}
resource = f'/networks/{networkId}/snmpSettings'
body_params = ['access', 'communityString', 'users']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)
def getOrganizationSnmp(self, organizationId: str):
"""
**Return the SNMP settings for an organization**
https://developer.cisco.com/meraki/api/#!get-organization-snmp
- organizationId (string)
"""
metadata = {
'tags': ['SNMP settings'],
'operation': 'getOrganizationSnmp',
}
resource = f'/organizations/{organizationId}/snmp'
return self._session.get(metadata, resource)
def updateOrganizationSnmp(self, organizationId: str, **kwargs):
"""
**Update the SNMP settings for an organization**
https://developer.cisco.com/meraki/api/#!update-organization-snmp
- organizationId (string)
- v2cEnabled (boolean): Boolean indicating whether SNMP version 2c is enabled for the organization.
- v3Enabled (boolean): Boolean indicating whether SNMP version 3 is enabled for the organization.
- v3AuthMode (string): The SNMP version 3 authentication mode. Can be either 'MD5' or 'SHA'.
- v3AuthPass (string): The SNMP version 3 authentication password. Must be at least 8 characters if specified.
- v3PrivMode (string): The SNMP version 3 privacy mode. Can be either 'DES' or 'AES128'.
- v3PrivPass (string): The SNMP version 3 privacy password. Must be at least 8 characters if specified.
- peerIps (string): The IPs that are allowed to access the SNMP server. This list should be IPv4 addresses separated by semi-colons (ie. "1.2.3.4;2.3.4.5").
"""
kwargs.update(locals())
if 'v3AuthMode' in kwargs:
options = ['MD5', 'SHA']
assert kwargs['v3AuthMode'] in options, f'''"v3AuthMode" cannot be "{kwargs['v3AuthMode']}", & must be set to one of: {options}'''
if 'v3PrivMode' in kwargs:
options = ['DES', 'AES128']
assert kwargs['v3PrivMode'] in options, f'''"v3PrivMode" cannot be "{kwargs['v3PrivMode']}", & must be set to one of: {options}'''
metadata = {
'tags': ['SNMP settings'],
'operation': 'updateOrganizationSnmp',
}
resource = f'/organizations/{organizationId}/snmp'
body_params = ['v2cEnabled', 'v3Enabled', 'v3AuthMode', 'v3AuthPass', 'v3PrivMode', 'v3PrivPass', 'peerIps']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.put(metadata, resource, payload)