forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch_stacks.py
More file actions
124 lines (93 loc) · 3.88 KB
/
Copy pathswitch_stacks.py
File metadata and controls
124 lines (93 loc) · 3.88 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
class SwitchStacks(object):
def __init__(self, session):
super(SwitchStacks, self).__init__()
self._session = session
def getNetworkSwitchStacks(self, networkId: str):
"""
**List the switch stacks in a network**
https://developer.cisco.com/meraki/api/#!get-network-switch-stacks
- networkId (string)
"""
metadata = {
'tags': ['Switch stacks'],
'operation': 'getNetworkSwitchStacks',
}
resource = f'/networks/{networkId}/switchStacks'
return self._session.get(metadata, resource)
def createNetworkSwitchStack(self, networkId: str, name: str, serials: list):
"""
**Create a stack**
https://developer.cisco.com/meraki/api/#!create-network-switch-stack
- networkId (string)
- name (string): The name of the new stack
- serials (array): An array of switch serials to be added into the new stack
"""
kwargs = locals()
metadata = {
'tags': ['Switch stacks'],
'operation': 'createNetworkSwitchStack',
}
resource = f'/networks/{networkId}/switchStacks'
body_params = ['name', 'serials']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.post(metadata, resource, payload)
def getNetworkSwitchStack(self, networkId: str, switchStackId: str):
"""
**Show a switch stack**
https://developer.cisco.com/meraki/api/#!get-network-switch-stack
- networkId (string)
- switchStackId (string)
"""
metadata = {
'tags': ['Switch stacks'],
'operation': 'getNetworkSwitchStack',
}
resource = f'/networks/{networkId}/switchStacks/{switchStackId}'
return self._session.get(metadata, resource)
def deleteNetworkSwitchStack(self, networkId: str, switchStackId: str):
"""
**Delete a stack**
https://developer.cisco.com/meraki/api/#!delete-network-switch-stack
- networkId (string)
- switchStackId (string)
"""
metadata = {
'tags': ['Switch stacks'],
'operation': 'deleteNetworkSwitchStack',
}
resource = f'/networks/{networkId}/switchStacks/{switchStackId}'
return self._session.delete(metadata, resource)
def addNetworkSwitchStack(self, networkId: str, switchStackId: str, serial: str):
"""
**Add a switch to a stack**
https://developer.cisco.com/meraki/api/#!add-network-switch-stack
- networkId (string)
- switchStackId (string)
- serial (string): The serial of the switch to be added
"""
kwargs = locals()
metadata = {
'tags': ['Switch stacks'],
'operation': 'addNetworkSwitchStack',
}
resource = f'/networks/{networkId}/switchStacks/{switchStackId}/add'
body_params = ['serial']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.post(metadata, resource, payload)
def removeNetworkSwitchStack(self, networkId: str, switchStackId: str, serial: str):
"""
**Remove a switch from a stack**
https://developer.cisco.com/meraki/api/#!remove-network-switch-stack
- networkId (string)
- switchStackId (string)
- serial (string): The serial of the switch to be removed
"""
kwargs = locals()
metadata = {
'tags': ['Switch stacks'],
'operation': 'removeNetworkSwitchStack',
}
resource = f'/networks/{networkId}/switchStacks/{switchStackId}/remove'
body_params = ['serial']
payload = {k: v for (k, v) in kwargs.items() if k in body_params}
return self._session.post(metadata, resource, payload)