forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicensing.py
More file actions
241 lines (171 loc) · 11.7 KB
/
Copy pathlicensing.py
File metadata and controls
241 lines (171 loc) · 11.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
import urllib
class Licensing(object):
def __init__(self, session):
super(Licensing, self).__init__()
self._session = session
def getAdministeredLicensingSubscriptionEntitlements(self, **kwargs):
"""
**Retrieve the list of purchasable entitlements**
https://developer.cisco.com/meraki/api-v1/#!get-administered-licensing-subscription-entitlements
- skus (array): Filter to entitlements with the specified SKUs
"""
kwargs.update(locals())
metadata = {
'tags': ['licensing', 'configure', 'subscription', 'entitlements'],
'operation': 'getAdministeredLicensingSubscriptionEntitlements'
}
resource = f'/administered/licensing/subscription/entitlements'
query_params = ['skus', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['skus', ]
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(metadata, resource, params)
def getAdministeredLicensingSubscriptionSubscriptions(self, organizationIds: list, total_pages=1, direction='next', **kwargs):
"""
**List available subscriptions**
https://developer.cisco.com/meraki/api-v1/#!get-administered-licensing-subscription-subscriptions
- organizationIds (array): Organizations to get associated subscriptions for
- 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. Default is 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.
- subscriptionIds (array): List of subscription ids to fetch
- startDate (string): Filter subscriptions by start date, ISO 8601 format. To filter with a range of dates, use 'startDate[<option>]=?' in the request. Accepted options include lt, gt, lte, gte.
- endDate (string): Filter subscriptions by end date, ISO 8601 format. To filter with a range of dates, use 'endDate[<option>]=?' in the request. Accepted options include lt, gt, lte, gte.
- statuses (array): List of statuses that returned subscriptions can have
- productTypes (array): List of product types that returned subscriptions need to have entitlements for.
- skus (array): List of SKUs that returned subscriptions need to have entitlements for.
- name (string): Search for subscription name
"""
kwargs.update(locals())
metadata = {
'tags': ['licensing', 'configure', 'subscription', 'subscriptions'],
'operation': 'getAdministeredLicensingSubscriptionSubscriptions'
}
resource = f'/administered/licensing/subscription/subscriptions'
query_params = ['perPage', 'startingAfter', 'endingBefore', 'subscriptionIds', 'organizationIds', 'startDate', 'endDate', 'statuses', 'productTypes', 'skus', 'name', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['subscriptionIds', 'organizationIds', 'statuses', 'productTypes', 'skus', ]
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 claimAdministeredLicensingSubscriptionSubscriptions(self, claimKey: str, organizationId: str, **kwargs):
"""
**Claim a subscription into an organization.**
https://developer.cisco.com/meraki/api-v1/#!claim-administered-licensing-subscription-subscriptions
- claimKey (string): The subscription's claim key
- organizationId (string): The id of the organization claiming the subscription
- validate (boolean): Check if the provided claim key is valid and can be claimed into the organization.
- name (string): Friendly name to identify the subscription
- description (string): Extra details or notes about the subscription
"""
kwargs.update(locals())
metadata = {
'tags': ['licensing', 'configure', 'subscription', 'subscriptions'],
'operation': 'claimAdministeredLicensingSubscriptionSubscriptions'
}
resource = f'/administered/licensing/subscription/subscriptions/claim'
body_params = ['claimKey', 'organizationId', 'name', '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 validateAdministeredLicensingSubscriptionSubscriptionsClaimKey(self, claimKey: str):
"""
**Find a subscription by claim key**
https://developer.cisco.com/meraki/api-v1/#!validate-administered-licensing-subscription-subscriptions-claim-key
- claimKey (string): The subscription's claim key
"""
kwargs = locals()
metadata = {
'tags': ['licensing', 'configure', 'subscription', 'subscriptions', 'claimKey'],
'operation': 'validateAdministeredLicensingSubscriptionSubscriptionsClaimKey'
}
resource = f'/administered/licensing/subscription/subscriptions/claimKey/validate'
body_params = ['claimKey', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getAdministeredLicensingSubscriptionSubscriptionsComplianceStatuses(self, organizationIds: list, **kwargs):
"""
**Get compliance status for requested subscriptions**
https://developer.cisco.com/meraki/api-v1/#!get-administered-licensing-subscription-subscriptions-compliance-statuses
- organizationIds (array): Organizations to get subscription compliance information for
- subscriptionIds (array): Subscription ids
"""
kwargs.update(locals())
metadata = {
'tags': ['licensing', 'configure', 'subscription', 'subscriptions', 'compliance', 'statuses'],
'operation': 'getAdministeredLicensingSubscriptionSubscriptionsComplianceStatuses'
}
resource = f'/administered/licensing/subscription/subscriptions/compliance/statuses'
query_params = ['organizationIds', 'subscriptionIds', ]
params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params}
array_params = ['organizationIds', 'subscriptionIds', ]
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(metadata, resource, params)
def bindAdministeredLicensingSubscriptionSubscription(self, subscriptionId: str, **kwargs):
"""
**Bind networks to a subscription**
https://developer.cisco.com/meraki/api-v1/#!bind-administered-licensing-subscription-subscription
- subscriptionId (string): Subscription ID
- validate (boolean): Check if the provided networks can be bound to the subscription. Returns any licensing problems and does not commit the results.
- networkIds (array): List of network ids to bind to the subscription
"""
kwargs.update(locals())
metadata = {
'tags': ['licensing', 'configure', 'subscription', 'subscriptions'],
'operation': 'bindAdministeredLicensingSubscriptionSubscription'
}
subscriptionId = urllib.parse.quote(str(subscriptionId), safe='')
resource = f'/administered/licensing/subscription/subscriptions/{subscriptionId}/bind'
body_params = ['networkIds', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)
def getOrganizationLicensingCotermLicenses(self, organizationId: str, total_pages=1, direction='next', **kwargs):
"""
**List the licenses in a coterm organization**
https://developer.cisco.com/meraki/api-v1/#!get-organization-licensing-coterm-licenses
- 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
- perPage (integer): The number of entries per page returned. Acceptable range is 3 - 1000. Default is 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.
- invalidated (boolean): Filter for licenses that are invalidated
- expired (boolean): Filter for licenses that are expired
"""
kwargs.update(locals())
metadata = {
'tags': ['licensing', 'configure', 'coterm', 'licenses'],
'operation': 'getOrganizationLicensingCotermLicenses'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/licensing/coterm/licenses'
query_params = ['perPage', 'startingAfter', 'endingBefore', 'invalidated', 'expired', ]
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 moveOrganizationLicensingCotermLicenses(self, organizationId: str, destination: dict, licenses: list):
"""
**Moves a license to a different organization (coterm only)**
https://developer.cisco.com/meraki/api-v1/#!move-organization-licensing-coterm-licenses
- organizationId (string): Organization ID
- destination (object): Destination data for the license move
- licenses (array): The list of licenses to move
"""
kwargs = locals()
metadata = {
'tags': ['licensing', 'configure', 'coterm', 'licenses'],
'operation': 'moveOrganizationLicensingCotermLicenses'
}
organizationId = urllib.parse.quote(str(organizationId), safe='')
resource = f'/organizations/{organizationId}/licensing/coterm/licenses/move'
body_params = ['destination', 'licenses', ]
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
return self._session.post(metadata, resource, payload)