nornir-collection 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nornir_collection/__init__.py +0 -0
- nornir_collection/batfish/__init__.py +0 -0
- nornir_collection/batfish/assert_config.py +358 -0
- nornir_collection/batfish/utils.py +129 -0
- nornir_collection/cisco/__init__.py +0 -0
- nornir_collection/cisco/configuration_management/__init__.py +0 -0
- nornir_collection/cisco/configuration_management/cli/__init__.py +0 -0
- nornir_collection/cisco/configuration_management/cli/config_tasks.py +569 -0
- nornir_collection/cisco/configuration_management/cli/config_workflow.py +107 -0
- nornir_collection/cisco/configuration_management/cli/show_tasks.py +677 -0
- nornir_collection/cisco/configuration_management/netconf/__init__.py +0 -0
- nornir_collection/cisco/configuration_management/netconf/config_tasks.py +564 -0
- nornir_collection/cisco/configuration_management/netconf/config_workflow.py +298 -0
- nornir_collection/cisco/configuration_management/netconf/nr_cfg_iosxe_netconf.py +186 -0
- nornir_collection/cisco/configuration_management/netconf/ops_tasks.py +307 -0
- nornir_collection/cisco/configuration_management/processor.py +151 -0
- nornir_collection/cisco/configuration_management/pyats.py +236 -0
- nornir_collection/cisco/configuration_management/restconf/__init__.py +0 -0
- nornir_collection/cisco/configuration_management/restconf/cisco_rpc.py +514 -0
- nornir_collection/cisco/configuration_management/restconf/config_workflow.py +95 -0
- nornir_collection/cisco/configuration_management/restconf/tasks.py +325 -0
- nornir_collection/cisco/configuration_management/utils.py +511 -0
- nornir_collection/cisco/software_upgrade/__init__.py +0 -0
- nornir_collection/cisco/software_upgrade/cisco_software_upgrade.py +283 -0
- nornir_collection/cisco/software_upgrade/utils.py +794 -0
- nornir_collection/cisco/support_api/__init__.py +0 -0
- nornir_collection/cisco/support_api/api_calls.py +1173 -0
- nornir_collection/cisco/support_api/cisco_maintenance_report.py +221 -0
- nornir_collection/cisco/support_api/cisco_support.py +727 -0
- nornir_collection/cisco/support_api/reports.py +747 -0
- nornir_collection/cisco/support_api/utils.py +316 -0
- nornir_collection/fortinet/__init__.py +0 -0
- nornir_collection/fortinet/utils.py +36 -0
- nornir_collection/git.py +224 -0
- nornir_collection/netbox/__init__.py +0 -0
- nornir_collection/netbox/custom_script.py +107 -0
- nornir_collection/netbox/inventory.py +360 -0
- nornir_collection/netbox/scan_prefixes_and_update_ip_addresses.py +989 -0
- nornir_collection/netbox/set_device_status.py +67 -0
- nornir_collection/netbox/sync_datasource.py +111 -0
- nornir_collection/netbox/update_cisco_inventory_data.py +158 -0
- nornir_collection/netbox/update_cisco_support_plugin_data.py +339 -0
- nornir_collection/netbox/update_fortinet_inventory_data.py +161 -0
- nornir_collection/netbox/update_purestorage_inventory_data.py +144 -0
- nornir_collection/netbox/utils.py +261 -0
- nornir_collection/netbox/verify_device_primary_ip.py +202 -0
- nornir_collection/nornir_plugins/__init__.py +0 -0
- nornir_collection/nornir_plugins/inventory/__init__.py +0 -0
- nornir_collection/nornir_plugins/inventory/netbox.py +250 -0
- nornir_collection/nornir_plugins/inventory/staggered_yaml.py +143 -0
- nornir_collection/nornir_plugins/inventory/utils.py +277 -0
- nornir_collection/purestorage/__init__.py +0 -0
- nornir_collection/purestorage/utils.py +53 -0
- nornir_collection/utils.py +741 -0
- nornir_collection-0.0.1.dist-info/LICENSE +21 -0
- nornir_collection-0.0.1.dist-info/METADATA +136 -0
- nornir_collection-0.0.1.dist-info/RECORD +59 -0
- nornir_collection-0.0.1.dist-info/WHEEL +5 -0
- nornir_collection-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1173 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
This module contains classes to call the Cisco support APIs.
|
4
|
+
Its a deviation from https://github.com/rothdennis/cisco_support as this repo seems not to be updated anymore.
|
5
|
+
|
6
|
+
The classes are ordered as followed:
|
7
|
+
- SNI (Serial Number Information)
|
8
|
+
- EOX End-of-Life Information
|
9
|
+
- SS (Software Suggestion)
|
10
|
+
- ASD (Automated Software Distribution)
|
11
|
+
- Bug (Software Bug)
|
12
|
+
- Case (TAC Support Case)
|
13
|
+
- PI (Product Information)
|
14
|
+
- RMA (Service Order Return)
|
15
|
+
"""
|
16
|
+
|
17
|
+
|
18
|
+
import requests
|
19
|
+
|
20
|
+
|
21
|
+
# pylint: disable=invalid-name,too-many-arguments,too-many-lines
|
22
|
+
|
23
|
+
#### Constants ##############################################################################################
|
24
|
+
|
25
|
+
|
26
|
+
# Set the requests timeout for connect and read separatly
|
27
|
+
REQUESTS_TIMEOUT = (3.05, 27)
|
28
|
+
|
29
|
+
|
30
|
+
#### Utils ##################################################################################################
|
31
|
+
|
32
|
+
|
33
|
+
def get_cisco_support_token(client_id: str, client_secret: str, verify: bool, proxies: dict) -> str:
|
34
|
+
"""
|
35
|
+
Get Cisco Support API Token
|
36
|
+
"""
|
37
|
+
url = "https://id.cisco.com/oauth2/default/v1/token"
|
38
|
+
params = {"grant_type": "client_credentials", "client_id": client_id, "client_secret": client_secret}
|
39
|
+
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
40
|
+
|
41
|
+
response = requests.post(
|
42
|
+
url=url, params=params, headers=headers, verify=verify, proxies=proxies, timeout=REQUESTS_TIMEOUT
|
43
|
+
)
|
44
|
+
|
45
|
+
return response.json()["access_token"]
|
46
|
+
|
47
|
+
|
48
|
+
#### Serial Number Information ##############################################################################
|
49
|
+
|
50
|
+
|
51
|
+
class SNI:
|
52
|
+
"""
|
53
|
+
Serial Number Information
|
54
|
+
"""
|
55
|
+
|
56
|
+
__headers = None
|
57
|
+
__verify = None
|
58
|
+
__proxies = None
|
59
|
+
|
60
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
61
|
+
"""
|
62
|
+
Class init function
|
63
|
+
"""
|
64
|
+
self.__verify = verify
|
65
|
+
self.__proxies = proxies
|
66
|
+
|
67
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
68
|
+
|
69
|
+
self.__headers = {"Authorization": f"Bearer {token}", "Accept": "application/json"}
|
70
|
+
|
71
|
+
def getCoverageStatusBySerialNumbers(self, sr_no: list) -> dict:
|
72
|
+
"""
|
73
|
+
Get Coverage Status by Serial Numbers
|
74
|
+
"""
|
75
|
+
params = {}
|
76
|
+
|
77
|
+
sr_no = ",".join(sr_no)
|
78
|
+
|
79
|
+
url = f"https://apix.cisco.com/sn2info/v2/coverage/status/serial_numbers/{sr_no}"
|
80
|
+
|
81
|
+
response = requests.get(
|
82
|
+
url=url,
|
83
|
+
headers=self.__headers,
|
84
|
+
params=params,
|
85
|
+
verify=self.__verify,
|
86
|
+
proxies=self.__proxies,
|
87
|
+
timeout=REQUESTS_TIMEOUT,
|
88
|
+
)
|
89
|
+
|
90
|
+
return response.json()
|
91
|
+
|
92
|
+
def getCoverageSummaryByInstanceNumbers(self, instance_no: list, page_index: int = 1) -> dict:
|
93
|
+
"""
|
94
|
+
Get Coverage Summary by Instance Numbers
|
95
|
+
"""
|
96
|
+
params = {"page_index": page_index}
|
97
|
+
|
98
|
+
instance_no = ",".join(instance_no)
|
99
|
+
|
100
|
+
url = f"https://apix.cisco.com/sn2info/v2/coverage/summary/instance_numbers/{instance_no}"
|
101
|
+
|
102
|
+
response = requests.get(
|
103
|
+
url=url,
|
104
|
+
headers=self.__headers,
|
105
|
+
params=params,
|
106
|
+
verify=self.__verify,
|
107
|
+
proxies=self.__proxies,
|
108
|
+
timeout=REQUESTS_TIMEOUT,
|
109
|
+
)
|
110
|
+
|
111
|
+
return response.json()
|
112
|
+
|
113
|
+
def getCoverageSummaryBySerialNumbers(self, sr_no: list, page_index: int = 1) -> dict:
|
114
|
+
"""
|
115
|
+
Get Coverage Summary by Serial Numbers
|
116
|
+
"""
|
117
|
+
params = {"page_index": page_index}
|
118
|
+
|
119
|
+
sr_no = ",".join(sr_no)
|
120
|
+
|
121
|
+
url = f"https://apix.cisco.com/sn2info/v2/coverage/summary/serial_numbers/{sr_no}"
|
122
|
+
|
123
|
+
response = requests.get(
|
124
|
+
url=url,
|
125
|
+
headers=self.__headers,
|
126
|
+
params=params,
|
127
|
+
verify=self.__verify,
|
128
|
+
proxies=self.__proxies,
|
129
|
+
timeout=REQUESTS_TIMEOUT,
|
130
|
+
)
|
131
|
+
|
132
|
+
return response.json()
|
133
|
+
|
134
|
+
def getOrderableProductIDsBySerialNumbers(self, sr_no: list) -> dict:
|
135
|
+
"""
|
136
|
+
Get Orderable Pruduct ID by Serial Numbers
|
137
|
+
"""
|
138
|
+
params = {}
|
139
|
+
|
140
|
+
sr_no = ",".join(sr_no)
|
141
|
+
|
142
|
+
url = f"https://apix.cisco.com/sn2info/v2/identifiers/orderable/serial_numbers/{sr_no}"
|
143
|
+
|
144
|
+
response = requests.get(
|
145
|
+
url=url,
|
146
|
+
headers=self.__headers,
|
147
|
+
params=params,
|
148
|
+
verify=self.__verify,
|
149
|
+
proxies=self.__proxies,
|
150
|
+
timeout=REQUESTS_TIMEOUT,
|
151
|
+
)
|
152
|
+
|
153
|
+
return response.json()
|
154
|
+
|
155
|
+
def getOwnerCoverageStatusBySerialNumbers(self, sr_no: list) -> dict:
|
156
|
+
"""
|
157
|
+
Get Owner Coverage Status by Serial Numbers
|
158
|
+
"""
|
159
|
+
params = {}
|
160
|
+
|
161
|
+
sr_no = ",".join(sr_no)
|
162
|
+
|
163
|
+
url = f"https://apix.cisco.com/sn2info/v2/coverage/owner_status/serial_numbers/{sr_no}"
|
164
|
+
|
165
|
+
response = requests.get(
|
166
|
+
url=url,
|
167
|
+
headers=self.__headers,
|
168
|
+
params=params,
|
169
|
+
verify=self.__verify,
|
170
|
+
proxies=self.__proxies,
|
171
|
+
timeout=REQUESTS_TIMEOUT,
|
172
|
+
)
|
173
|
+
|
174
|
+
return response.json()
|
175
|
+
|
176
|
+
|
177
|
+
#### End-of-Life Information ################################################################################
|
178
|
+
|
179
|
+
|
180
|
+
class EOX:
|
181
|
+
"""
|
182
|
+
End-of-Life Information
|
183
|
+
"""
|
184
|
+
|
185
|
+
__headers = None
|
186
|
+
__verify = None
|
187
|
+
__proxies = None
|
188
|
+
|
189
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
190
|
+
"""
|
191
|
+
Class init function
|
192
|
+
"""
|
193
|
+
self.__verify = verify
|
194
|
+
self.__proxies = proxies
|
195
|
+
|
196
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
197
|
+
|
198
|
+
self.__headers = {"Authorization": f"Bearer {token}", "Accept": "application/json"}
|
199
|
+
|
200
|
+
def getByDates( # pylint: disable=dangerous-default-value
|
201
|
+
self, startDate: str, endDate: str, pageIndex: int = 1, eoxAttrib: list = []
|
202
|
+
) -> dict:
|
203
|
+
"""
|
204
|
+
Get EoX by Dates
|
205
|
+
|
206
|
+
Args:
|
207
|
+
startDate (str): Start date of the date range of records to return in the following format:
|
208
|
+
YYYY-MM-DD. For example: 2010-01-01
|
209
|
+
endDate (str): End date of the date range of records to return in the following format:
|
210
|
+
YYYY-MM-DD. For example: 2010-01-01
|
211
|
+
pageIndex (int, optional): Index number of the page to return; a maximum of 50 records per page
|
212
|
+
are returned. Defaults to 1.
|
213
|
+
eoxAttrib (list, optional): Attribute or attributes of the records to return. Enter multiple
|
214
|
+
values separated by commas. Defaults to [].
|
215
|
+
|
216
|
+
Returns:
|
217
|
+
dict: {PaginationResponseRecord, EOXRecord}
|
218
|
+
"""
|
219
|
+
params = {"eoxAttrib": ",".join(eoxAttrib), "responseencoding": "json"}
|
220
|
+
|
221
|
+
url = f"https://apix.cisco.com/supporttools/eox/rest/5/EOXByDates/{pageIndex}/{startDate}/{endDate}"
|
222
|
+
|
223
|
+
response = requests.get(
|
224
|
+
url=url,
|
225
|
+
headers=self.__headers,
|
226
|
+
params=params,
|
227
|
+
verify=self.__verify,
|
228
|
+
proxies=self.__proxies,
|
229
|
+
timeout=REQUESTS_TIMEOUT,
|
230
|
+
)
|
231
|
+
|
232
|
+
return response.json()
|
233
|
+
|
234
|
+
def getByProductIDs(self, productID: list, pageIndex: int = 1) -> dict:
|
235
|
+
"""
|
236
|
+
Get EOX by Product IDs
|
237
|
+
|
238
|
+
Args:
|
239
|
+
productID (list): Product IDs for the products to retrieve from the database. Enter up to 20 PIDs
|
240
|
+
eparated by commas. For example: 15216-OADM1-35=,M92S1K9-1.3.3C Note: To enhance search
|
241
|
+
capabilities, the Cisco Support Tools allows wildcards with the productIDs parameter.
|
242
|
+
A minimum of 3 characters is required. For example, only the following inputs are valid:
|
243
|
+
*VPN*, *VPN, VPN*, and VPN. Using wildcards can result in multiple PIDs in the output.
|
244
|
+
pageIndex (int, optional): Index number of the page to return; a maximum of 50 records per page
|
245
|
+
are returned. Defaults to 1.
|
246
|
+
|
247
|
+
Returns:
|
248
|
+
dict: {PaginationResponseRecord, EOXRecord}
|
249
|
+
"""
|
250
|
+
params = {"responseencoding": "json"}
|
251
|
+
|
252
|
+
productID = ",".join(productID)
|
253
|
+
|
254
|
+
url = f"https://apix.cisco.com/supporttools/eox/rest/5/EOXByProductID/{pageIndex}/{productID}"
|
255
|
+
|
256
|
+
response = requests.get(
|
257
|
+
url=url,
|
258
|
+
headers=self.__headers,
|
259
|
+
params=params,
|
260
|
+
verify=self.__verify,
|
261
|
+
proxies=self.__proxies,
|
262
|
+
timeout=REQUESTS_TIMEOUT,
|
263
|
+
)
|
264
|
+
|
265
|
+
return response.json()
|
266
|
+
|
267
|
+
def getBySerialNumbers(self, serialNumber: list, pageIndex: int = 1) -> dict:
|
268
|
+
"""
|
269
|
+
Get EOX by Serial Numbers
|
270
|
+
|
271
|
+
Args:
|
272
|
+
serialNumber (list): Device serial number or numbers for which to return results. You can enter
|
273
|
+
up to 20 serial numbers (each with a maximum length of 40) separated by commas.
|
274
|
+
pageIndex (int, optional): Index number of the page to return; a maximum of 50 records per page
|
275
|
+
are returned. Defaults to 1.
|
276
|
+
|
277
|
+
Returns:
|
278
|
+
dict: {PaginationResponseRecord, EOXRecord}
|
279
|
+
"""
|
280
|
+
params = {"responseencoding": "json"}
|
281
|
+
|
282
|
+
serialNumber = ",".join(serialNumber)
|
283
|
+
|
284
|
+
url = f"https://apix.cisco.com/supporttools/eox/rest/5/EOXBySerialNumber/{pageIndex}/{serialNumber}"
|
285
|
+
|
286
|
+
response = requests.get(
|
287
|
+
url=url,
|
288
|
+
headers=self.__headers,
|
289
|
+
params=params,
|
290
|
+
verify=self.__verify,
|
291
|
+
proxies=self.__proxies,
|
292
|
+
timeout=REQUESTS_TIMEOUT,
|
293
|
+
)
|
294
|
+
|
295
|
+
return response.json()
|
296
|
+
|
297
|
+
def getBySoftwareReleaseStrings(self, software: list, pageIndex: int = 1) -> dict:
|
298
|
+
"""
|
299
|
+
Get EOX by Software Release Strings
|
300
|
+
|
301
|
+
Args:
|
302
|
+
software (list): String for software release and type of operating system (optional) for the
|
303
|
+
requested product. For example: 12.2,IOS You can enter up to 20 software release and
|
304
|
+
operating system type combinations. Each combination can return multiple EoX records.
|
305
|
+
pageIndex (int, optional): Index number of the page to return. For example, 1 returns the first
|
306
|
+
page of the total number of available pages. Defaults to 1.
|
307
|
+
|
308
|
+
Returns:
|
309
|
+
dict: {PaginationResponseRecord, EOXRecord}
|
310
|
+
"""
|
311
|
+
params = {"responseencoding": "json"}
|
312
|
+
|
313
|
+
for i, sw in enumerate(software):
|
314
|
+
params.update({f"input{i + 1}": sw})
|
315
|
+
|
316
|
+
url = f"https://apix.cisco.com/supporttools/eox/rest/5/EOXBySWReleaseString/{pageIndex}"
|
317
|
+
|
318
|
+
response = requests.get(
|
319
|
+
url=url,
|
320
|
+
headers=self.__headers,
|
321
|
+
params=params,
|
322
|
+
verify=self.__verify,
|
323
|
+
proxies=self.__proxies,
|
324
|
+
timeout=REQUESTS_TIMEOUT,
|
325
|
+
)
|
326
|
+
|
327
|
+
return response.json()
|
328
|
+
|
329
|
+
|
330
|
+
#### Software Suggestion ####################################################################################
|
331
|
+
|
332
|
+
|
333
|
+
class SS:
|
334
|
+
"""
|
335
|
+
Software Suggestion
|
336
|
+
"""
|
337
|
+
|
338
|
+
__headers = None
|
339
|
+
__verify = None
|
340
|
+
__proxies = None
|
341
|
+
|
342
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
343
|
+
"""
|
344
|
+
Class init function
|
345
|
+
"""
|
346
|
+
self.__verify = verify
|
347
|
+
self.__proxies = proxies
|
348
|
+
|
349
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
350
|
+
|
351
|
+
self.__headers = {"Authorization": f"Bearer {token}", "Accept": "application/json"}
|
352
|
+
|
353
|
+
def getSuggestedReleasesAndImagesByProductIDs(self, productIds: list, pageIndex: int = 1) -> dict:
|
354
|
+
"""
|
355
|
+
Get Suggested Release and Images by Product IDs
|
356
|
+
"""
|
357
|
+
params = {"pageIndex": pageIndex}
|
358
|
+
|
359
|
+
productIds = ",".join(productIds)
|
360
|
+
|
361
|
+
url = f"https://apix.cisco.com/software/suggestion/v2/suggestions/software/productIds/{productIds}"
|
362
|
+
|
363
|
+
response = requests.get(
|
364
|
+
url=url,
|
365
|
+
headers=self.__headers,
|
366
|
+
params=params,
|
367
|
+
verify=self.__verify,
|
368
|
+
proxies=self.__proxies,
|
369
|
+
timeout=REQUESTS_TIMEOUT,
|
370
|
+
)
|
371
|
+
|
372
|
+
return response.json()
|
373
|
+
|
374
|
+
def getSuggestedReleasesByProductIDs(self, productIds: list, pageIndex: int = 1) -> dict:
|
375
|
+
"""
|
376
|
+
Get Suggested Release By Product IDs
|
377
|
+
"""
|
378
|
+
params = {"pageIndex": pageIndex}
|
379
|
+
|
380
|
+
productIds = ",".join(productIds)
|
381
|
+
|
382
|
+
url = f"https://apix.cisco.com/software/suggestion/v2/suggestions/releases/productIds/{productIds}"
|
383
|
+
|
384
|
+
response = requests.get(
|
385
|
+
url=url,
|
386
|
+
headers=self.__headers,
|
387
|
+
params=params,
|
388
|
+
verify=self.__verify,
|
389
|
+
proxies=self.__proxies,
|
390
|
+
timeout=REQUESTS_TIMEOUT,
|
391
|
+
)
|
392
|
+
|
393
|
+
return response.json()
|
394
|
+
|
395
|
+
def getCompatibleAndSuggestedSoftwareReleasesByProductID(
|
396
|
+
self,
|
397
|
+
productId: str,
|
398
|
+
currentImage: str = None,
|
399
|
+
currentRelease: str = None,
|
400
|
+
pageIndex: int = 1,
|
401
|
+
supportedFeatures: list = None,
|
402
|
+
supportedHardware: list = None,
|
403
|
+
) -> dict:
|
404
|
+
"""
|
405
|
+
Get Compatible and Suggested Software Release by Product ID
|
406
|
+
"""
|
407
|
+
|
408
|
+
if supportedHardware:
|
409
|
+
supportedHardware = "/".join(supportedHardware)
|
410
|
+
else:
|
411
|
+
supportedHardware = None
|
412
|
+
|
413
|
+
if supportedFeatures:
|
414
|
+
supportedFeatures = ",".join(supportedFeatures)
|
415
|
+
else:
|
416
|
+
supportedFeatures = None
|
417
|
+
|
418
|
+
params = {
|
419
|
+
"currentImage": currentImage,
|
420
|
+
"currentRelease": currentRelease,
|
421
|
+
"supportedFeatures": supportedFeatures,
|
422
|
+
"supportedHardware": supportedHardware,
|
423
|
+
"pageIndex": pageIndex,
|
424
|
+
}
|
425
|
+
|
426
|
+
url = f"https://apix.cisco.com/software/suggestion/v2/suggestions/compatible/productId/{productId}"
|
427
|
+
|
428
|
+
response = requests.get(
|
429
|
+
url=url,
|
430
|
+
headers=self.__headers,
|
431
|
+
params=params,
|
432
|
+
verify=self.__verify,
|
433
|
+
proxies=self.__proxies,
|
434
|
+
timeout=REQUESTS_TIMEOUT,
|
435
|
+
)
|
436
|
+
|
437
|
+
return response.json()
|
438
|
+
|
439
|
+
def getSuggestedReleasesAndImagesByMDFIDs(self, mdfIds: list, pageIndex: int = 1) -> dict:
|
440
|
+
"""
|
441
|
+
Get Suggested Release and Images by MDFIDs
|
442
|
+
"""
|
443
|
+
params = {"pageIndex": pageIndex}
|
444
|
+
|
445
|
+
mdfIds = ",".join(mdfIds)
|
446
|
+
|
447
|
+
url = f"https://apix.cisco.com/software/suggestion/v2/suggestions/software/mdfIds/{mdfIds}"
|
448
|
+
|
449
|
+
response = requests.get(
|
450
|
+
url=url,
|
451
|
+
headers=self.__headers,
|
452
|
+
params=params,
|
453
|
+
verify=self.__verify,
|
454
|
+
proxies=self.__proxies,
|
455
|
+
timeout=REQUESTS_TIMEOUT,
|
456
|
+
)
|
457
|
+
|
458
|
+
return response.json()
|
459
|
+
|
460
|
+
def getSuggestedReleasesByMDFIDs(self, mdfIds: list, pageIndex: int = 1) -> dict:
|
461
|
+
"""
|
462
|
+
Get Suggested Release by MDFIDs
|
463
|
+
"""
|
464
|
+
params = {"pageIndex": pageIndex}
|
465
|
+
|
466
|
+
mdfIds = ",".join(mdfIds)
|
467
|
+
|
468
|
+
url = f"https://apix.cisco.com/software/suggestion/v2/suggestions/releases/mdfIds/{mdfIds}"
|
469
|
+
|
470
|
+
response = requests.get(
|
471
|
+
url=url,
|
472
|
+
headers=self.__headers,
|
473
|
+
params=params,
|
474
|
+
verify=self.__verify,
|
475
|
+
proxies=self.__proxies,
|
476
|
+
timeout=REQUESTS_TIMEOUT,
|
477
|
+
)
|
478
|
+
|
479
|
+
return response.json()
|
480
|
+
|
481
|
+
def getCompatibleAndSuggestedSoftwareReleasesByMDFID(
|
482
|
+
self,
|
483
|
+
mdfId: str,
|
484
|
+
currentImage: str = None,
|
485
|
+
currentRelease: str = None,
|
486
|
+
pageIndex: int = 1,
|
487
|
+
supportedFeatures: list = None,
|
488
|
+
supportedHardware: list = None,
|
489
|
+
) -> dict:
|
490
|
+
"""
|
491
|
+
Get Compatible and Suggested Software Release by MDFID
|
492
|
+
"""
|
493
|
+
|
494
|
+
if supportedHardware:
|
495
|
+
supportedHardware = "/".join(supportedHardware)
|
496
|
+
else:
|
497
|
+
supportedHardware = None
|
498
|
+
|
499
|
+
if supportedFeatures:
|
500
|
+
supportedFeatures = ",".join(supportedFeatures)
|
501
|
+
else:
|
502
|
+
supportedFeatures = None
|
503
|
+
|
504
|
+
params = {
|
505
|
+
"pageIndex": pageIndex,
|
506
|
+
"currentImage": currentImage,
|
507
|
+
"currentRelease": currentRelease,
|
508
|
+
"supportedFeatures": supportedFeatures,
|
509
|
+
"supportedHardware": supportedHardware,
|
510
|
+
}
|
511
|
+
|
512
|
+
url = f"https://apix.cisco.com/software/suggestion/v2/suggestions/compatible/mdfId/{mdfId}"
|
513
|
+
|
514
|
+
response = requests.get(
|
515
|
+
url=url,
|
516
|
+
headers=self.__headers,
|
517
|
+
params=params,
|
518
|
+
verify=self.__verify,
|
519
|
+
proxies=self.__proxies,
|
520
|
+
timeout=REQUESTS_TIMEOUT,
|
521
|
+
)
|
522
|
+
|
523
|
+
return response.json()
|
524
|
+
|
525
|
+
|
526
|
+
#### Automated Software Distribution ########################################################################
|
527
|
+
|
528
|
+
|
529
|
+
class ASD:
|
530
|
+
"""
|
531
|
+
Automated Software Distribution
|
532
|
+
"""
|
533
|
+
|
534
|
+
__headers = None
|
535
|
+
__verify = None
|
536
|
+
__proxies = None
|
537
|
+
|
538
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
539
|
+
"""
|
540
|
+
Class init function
|
541
|
+
"""
|
542
|
+
self.__verify = verify
|
543
|
+
self.__proxies = proxies
|
544
|
+
|
545
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
546
|
+
|
547
|
+
self.__headers = {
|
548
|
+
"Authorization": f"Bearer {token}",
|
549
|
+
"Accept": "application/json",
|
550
|
+
"Content-Type": "application/json",
|
551
|
+
}
|
552
|
+
|
553
|
+
def getByProductIDAndRelease(
|
554
|
+
self,
|
555
|
+
pid: str,
|
556
|
+
currentReleaseVersion: str,
|
557
|
+
outputReleaseVersion: str = "latest",
|
558
|
+
pageIndex: int = 1,
|
559
|
+
perPage: int = 25,
|
560
|
+
) -> dict:
|
561
|
+
"""
|
562
|
+
Get Release by Product ID and Release
|
563
|
+
"""
|
564
|
+
data = {
|
565
|
+
"pid": pid,
|
566
|
+
"currentReleaseVersion": currentReleaseVersion,
|
567
|
+
"outputReleaseVersion": outputReleaseVersion,
|
568
|
+
"pageIndex": pageIndex,
|
569
|
+
"perPage": perPage,
|
570
|
+
}
|
571
|
+
|
572
|
+
url = "https://apix.cisco.com/software/v4.0/metadata/pidrelease"
|
573
|
+
|
574
|
+
response = requests.post(
|
575
|
+
url=url,
|
576
|
+
params=data,
|
577
|
+
headers=self.__headers,
|
578
|
+
verify=self.__verify,
|
579
|
+
proxies=self.__proxies,
|
580
|
+
timeout=REQUESTS_TIMEOUT,
|
581
|
+
)
|
582
|
+
|
583
|
+
return response.json()
|
584
|
+
|
585
|
+
def getByProductIDAndImage(self) -> dict:
|
586
|
+
"""
|
587
|
+
Get by Product ID and Image
|
588
|
+
"""
|
589
|
+
|
590
|
+
|
591
|
+
#### Bug ####################################################################################################
|
592
|
+
|
593
|
+
|
594
|
+
class Bug:
|
595
|
+
"""
|
596
|
+
Bug
|
597
|
+
"""
|
598
|
+
|
599
|
+
__headers = None
|
600
|
+
__verify = None
|
601
|
+
__proxies = None
|
602
|
+
|
603
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
604
|
+
"""
|
605
|
+
Class Init Function
|
606
|
+
"""
|
607
|
+
self.__verify = verify
|
608
|
+
self.__proxies = proxies
|
609
|
+
self.baseurl = "https://apix.cisco.com/bug/v2.0/bugs"
|
610
|
+
|
611
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
612
|
+
|
613
|
+
self.__headers = {"Authorization": f"Bearer {token}", "Accept": "application/json"}
|
614
|
+
|
615
|
+
def getByIDs(self, bug_ids: list) -> dict:
|
616
|
+
"""
|
617
|
+
Get Bug by IDs
|
618
|
+
"""
|
619
|
+
params = {}
|
620
|
+
|
621
|
+
bug_ids = ",".join(bug_ids)
|
622
|
+
|
623
|
+
url = f"{self.baseurl}/bug_ids/{bug_ids}"
|
624
|
+
|
625
|
+
response = requests.get(
|
626
|
+
url=url,
|
627
|
+
headers=self.__headers,
|
628
|
+
params=params,
|
629
|
+
verify=self.__verify,
|
630
|
+
proxies=self.__proxies,
|
631
|
+
timeout=REQUESTS_TIMEOUT,
|
632
|
+
)
|
633
|
+
|
634
|
+
return response.json()
|
635
|
+
|
636
|
+
def getByBaseProductIDs(
|
637
|
+
self,
|
638
|
+
base_pid: str,
|
639
|
+
page_index: int = 1,
|
640
|
+
status: str = None,
|
641
|
+
modified_date: str = 2,
|
642
|
+
severity: str = None,
|
643
|
+
sort_by: str = None,
|
644
|
+
) -> dict:
|
645
|
+
"""
|
646
|
+
Get Bug by Base Product IDS
|
647
|
+
"""
|
648
|
+
params = {
|
649
|
+
"page_index": page_index,
|
650
|
+
"modified_date": modified_date,
|
651
|
+
"status": status,
|
652
|
+
"severity": severity,
|
653
|
+
"sort_by": sort_by,
|
654
|
+
}
|
655
|
+
|
656
|
+
url = f"{self.baseurl}/products/product_id/{base_pid}"
|
657
|
+
|
658
|
+
response = requests.get(
|
659
|
+
url=url,
|
660
|
+
headers=self.__headers,
|
661
|
+
params=params,
|
662
|
+
verify=self.__verify,
|
663
|
+
proxies=self.__proxies,
|
664
|
+
timeout=REQUESTS_TIMEOUT,
|
665
|
+
)
|
666
|
+
|
667
|
+
return response.json()
|
668
|
+
|
669
|
+
def getByBaseProductIDsAndSoftwareReleases(
|
670
|
+
self,
|
671
|
+
base_pid: str,
|
672
|
+
software_releases: str,
|
673
|
+
page_index: int = 1,
|
674
|
+
status: str = None,
|
675
|
+
modified_date: str = 2,
|
676
|
+
severity: str = None,
|
677
|
+
sort_by: str = None,
|
678
|
+
) -> dict:
|
679
|
+
"""
|
680
|
+
Get Bug by Base Pruduct IDs and Software Release
|
681
|
+
"""
|
682
|
+
params = {
|
683
|
+
"page_index": page_index,
|
684
|
+
"modified_date": modified_date,
|
685
|
+
"status": status,
|
686
|
+
"severity": severity,
|
687
|
+
"sort_by": sort_by,
|
688
|
+
}
|
689
|
+
|
690
|
+
url = f"{self.baseurl}/products/product_id/{base_pid}/software_releases/{software_releases}"
|
691
|
+
|
692
|
+
response = requests.get(
|
693
|
+
url=url,
|
694
|
+
headers=self.__headers,
|
695
|
+
params=params,
|
696
|
+
verify=self.__verify,
|
697
|
+
proxies=self.__proxies,
|
698
|
+
timeout=REQUESTS_TIMEOUT,
|
699
|
+
)
|
700
|
+
|
701
|
+
return response.json()
|
702
|
+
|
703
|
+
def getByKeywords(
|
704
|
+
self,
|
705
|
+
keyword: list,
|
706
|
+
page_index: int = 1,
|
707
|
+
status: str = None,
|
708
|
+
modified_date: str = 2,
|
709
|
+
severity: str = None,
|
710
|
+
sort_by: str = None,
|
711
|
+
) -> dict:
|
712
|
+
"""
|
713
|
+
Get Bug by Keywords
|
714
|
+
"""
|
715
|
+
params = {
|
716
|
+
"page_index": page_index,
|
717
|
+
"modified_date": modified_date,
|
718
|
+
"status": status,
|
719
|
+
"severity": severity,
|
720
|
+
"sort_by": sort_by,
|
721
|
+
}
|
722
|
+
|
723
|
+
keyword = ",".join(keyword)
|
724
|
+
|
725
|
+
url = f"{self.baseurl}/keyword/{keyword}"
|
726
|
+
|
727
|
+
response = requests.get(
|
728
|
+
url=url,
|
729
|
+
headers=self.__headers,
|
730
|
+
params=params,
|
731
|
+
verify=self.__verify,
|
732
|
+
proxies=self.__proxies,
|
733
|
+
timeout=REQUESTS_TIMEOUT,
|
734
|
+
)
|
735
|
+
|
736
|
+
return response.json()
|
737
|
+
|
738
|
+
def getByProductSeriesAndAffectedSoftwareRelease(
|
739
|
+
self,
|
740
|
+
product_series: str,
|
741
|
+
affected_releases: list,
|
742
|
+
page_index: int = 1,
|
743
|
+
status: str = None,
|
744
|
+
modified_date: str = None,
|
745
|
+
severity: str = None,
|
746
|
+
sort_by: str = None,
|
747
|
+
) -> dict:
|
748
|
+
"""
|
749
|
+
Get Bug by Product Series and Affected Software Release
|
750
|
+
"""
|
751
|
+
affected_releases = ",".join(affected_releases)
|
752
|
+
|
753
|
+
params = {
|
754
|
+
"page_index": page_index,
|
755
|
+
"modified_date": modified_date,
|
756
|
+
"status": status,
|
757
|
+
"severity": severity,
|
758
|
+
"sort_by": sort_by,
|
759
|
+
}
|
760
|
+
|
761
|
+
url = f"{self.baseurl}/product_series/{product_series}/affected_releases/{affected_releases}"
|
762
|
+
|
763
|
+
response = requests.get(
|
764
|
+
url=url,
|
765
|
+
headers=self.__headers,
|
766
|
+
params=params,
|
767
|
+
verify=self.__verify,
|
768
|
+
proxies=self.__proxies,
|
769
|
+
timeout=REQUESTS_TIMEOUT,
|
770
|
+
)
|
771
|
+
|
772
|
+
return response.json()
|
773
|
+
|
774
|
+
def getByProductSeriesAndFixedInSoftwareRelease(
|
775
|
+
self,
|
776
|
+
product_series: str,
|
777
|
+
fixed_in_releases: list,
|
778
|
+
page_index: str = 1,
|
779
|
+
status: str = None,
|
780
|
+
modified_date: str = 2,
|
781
|
+
severity: str = None,
|
782
|
+
sort_by: str = None,
|
783
|
+
) -> dict:
|
784
|
+
"""
|
785
|
+
Get Bug by Product Series and Fixed in Software Release
|
786
|
+
"""
|
787
|
+
fixed_in_releases = ",".join(fixed_in_releases)
|
788
|
+
|
789
|
+
params = {
|
790
|
+
"page_index": page_index,
|
791
|
+
"modified_date": modified_date,
|
792
|
+
"status": status,
|
793
|
+
"severity": severity,
|
794
|
+
"sort_by": sort_by,
|
795
|
+
}
|
796
|
+
|
797
|
+
url = f"{self.baseurl}/product_series/{product_series}/fixed_in_releases/{fixed_in_releases}"
|
798
|
+
|
799
|
+
response = requests.get(
|
800
|
+
url=url,
|
801
|
+
headers=self.__headers,
|
802
|
+
params=params,
|
803
|
+
verify=self.__verify,
|
804
|
+
proxies=self.__proxies,
|
805
|
+
timeout=REQUESTS_TIMEOUT,
|
806
|
+
)
|
807
|
+
|
808
|
+
return response.json()
|
809
|
+
|
810
|
+
def getByProductNameAndAffectedSoftwareRelease(
|
811
|
+
self,
|
812
|
+
product_name: str,
|
813
|
+
affected_releases: list,
|
814
|
+
page_index: str = 1,
|
815
|
+
status: str = None,
|
816
|
+
modified_date: str = 2,
|
817
|
+
severity: str = None,
|
818
|
+
sort_by: str = None,
|
819
|
+
) -> dict:
|
820
|
+
"""
|
821
|
+
Get Bug by Product Name and Affected Software Release
|
822
|
+
"""
|
823
|
+
affected_releases = ",".join(affected_releases)
|
824
|
+
|
825
|
+
params = {
|
826
|
+
"page_index": page_index,
|
827
|
+
"modified_date": modified_date,
|
828
|
+
"status": status,
|
829
|
+
"severity": severity,
|
830
|
+
"sort_by": sort_by,
|
831
|
+
}
|
832
|
+
|
833
|
+
url = f"{self.baseurl}/product_name/{product_name}/affected_releases/{affected_releases}"
|
834
|
+
|
835
|
+
response = requests.get(
|
836
|
+
url=url,
|
837
|
+
headers=self.__headers,
|
838
|
+
params=params,
|
839
|
+
verify=self.__verify,
|
840
|
+
proxies=self.__proxies,
|
841
|
+
timeout=REQUESTS_TIMEOUT,
|
842
|
+
)
|
843
|
+
|
844
|
+
return response.json()
|
845
|
+
|
846
|
+
def getByProductNameAndFixedInSoftwareRelease(
|
847
|
+
self,
|
848
|
+
product_name: str,
|
849
|
+
fixed_in_releases: list,
|
850
|
+
page_index: str = 1,
|
851
|
+
status: str = None,
|
852
|
+
modified_date: str = 2,
|
853
|
+
severity: str = None,
|
854
|
+
sort_by: str = None,
|
855
|
+
) -> dict:
|
856
|
+
"""
|
857
|
+
Get Bug by Product Name and Fixed In Software Release
|
858
|
+
"""
|
859
|
+
fixed_in_releases = ",".join(fixed_in_releases)
|
860
|
+
|
861
|
+
params = {
|
862
|
+
"page_index": page_index,
|
863
|
+
"modified_date": modified_date,
|
864
|
+
"status": status,
|
865
|
+
"severity": severity,
|
866
|
+
"sort_by": sort_by,
|
867
|
+
}
|
868
|
+
|
869
|
+
url = f"{self.baseurl}/product_name/{product_name}/fixed_in_releases/{fixed_in_releases}"
|
870
|
+
|
871
|
+
response = requests.get(
|
872
|
+
url=url,
|
873
|
+
headers=self.__headers,
|
874
|
+
params=params,
|
875
|
+
verify=self.__verify,
|
876
|
+
proxies=self.__proxies,
|
877
|
+
timeout=REQUESTS_TIMEOUT,
|
878
|
+
)
|
879
|
+
|
880
|
+
return response.json()
|
881
|
+
|
882
|
+
|
883
|
+
#### Case ###################################################################################################
|
884
|
+
|
885
|
+
|
886
|
+
class Case:
|
887
|
+
"""
|
888
|
+
Case
|
889
|
+
"""
|
890
|
+
|
891
|
+
__headers = None
|
892
|
+
__verify = None
|
893
|
+
__proxies = None
|
894
|
+
|
895
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
896
|
+
"""
|
897
|
+
Class Init Function
|
898
|
+
"""
|
899
|
+
self.__verify = verify
|
900
|
+
self.__proxies = proxies
|
901
|
+
|
902
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
903
|
+
|
904
|
+
self.__headers = {
|
905
|
+
"Authorization": f"Bearer {token}",
|
906
|
+
"Accept": "application/json",
|
907
|
+
}
|
908
|
+
|
909
|
+
def getCaseSummary(self, case_ids: list, sort_by: str = "UPDATED_DATE") -> dict:
|
910
|
+
"""
|
911
|
+
Get Case Summary
|
912
|
+
"""
|
913
|
+
params = {"sort_by": sort_by}
|
914
|
+
|
915
|
+
case_ids = ",".join(case_ids)
|
916
|
+
|
917
|
+
url = f"https://apix.cisco.com/case/v3/cases/case_ids/{case_ids}"
|
918
|
+
|
919
|
+
response = requests.get(
|
920
|
+
url=url,
|
921
|
+
headers=self.__headers,
|
922
|
+
params=params,
|
923
|
+
verify=self.__verify,
|
924
|
+
proxies=self.__proxies,
|
925
|
+
timeout=REQUESTS_TIMEOUT,
|
926
|
+
)
|
927
|
+
|
928
|
+
return response.json()
|
929
|
+
|
930
|
+
def getCaseDetails(self, case_id: str) -> dict:
|
931
|
+
"""
|
932
|
+
Get Case Details
|
933
|
+
"""
|
934
|
+
params = {}
|
935
|
+
|
936
|
+
url = f"https://apix.cisco.com/case/v3/cases/details/case_id/{case_id}"
|
937
|
+
|
938
|
+
response = requests.get(
|
939
|
+
url=url,
|
940
|
+
headers=self.__headers,
|
941
|
+
params=params,
|
942
|
+
verify=self.__verify,
|
943
|
+
proxies=self.__proxies,
|
944
|
+
timeout=REQUESTS_TIMEOUT,
|
945
|
+
)
|
946
|
+
|
947
|
+
return response.json()
|
948
|
+
|
949
|
+
def getByContractID(
|
950
|
+
self,
|
951
|
+
contract_ids: list,
|
952
|
+
date_created_from: str,
|
953
|
+
date_created_to: str,
|
954
|
+
status_flag: str = "O",
|
955
|
+
sort_by: str = "UPDATED_DATE",
|
956
|
+
page_index: int = 1,
|
957
|
+
) -> dict:
|
958
|
+
"""
|
959
|
+
Get Case by Contract ID
|
960
|
+
"""
|
961
|
+
params = {
|
962
|
+
"date_created_from": date_created_from,
|
963
|
+
"date_created_to": date_created_to,
|
964
|
+
"sort_by": sort_by,
|
965
|
+
"status_flag": status_flag,
|
966
|
+
"page_index": page_index,
|
967
|
+
}
|
968
|
+
|
969
|
+
contract_ids = ",".join(contract_ids)
|
970
|
+
|
971
|
+
url = f"https://apix.cisco.com/case/v3/cases/contracts/contract_ids/{contract_ids}"
|
972
|
+
|
973
|
+
response = requests.get(
|
974
|
+
url=url,
|
975
|
+
headers=self.__headers,
|
976
|
+
params=params,
|
977
|
+
verify=self.__verify,
|
978
|
+
proxies=self.__proxies,
|
979
|
+
timeout=REQUESTS_TIMEOUT,
|
980
|
+
)
|
981
|
+
|
982
|
+
return response.json()
|
983
|
+
|
984
|
+
def getByUserID(
|
985
|
+
self,
|
986
|
+
user_ids: list,
|
987
|
+
date_created_from: str = None,
|
988
|
+
date_created_to: str = None,
|
989
|
+
status_flag: str = "O",
|
990
|
+
sort_by: str = "UPDATED_DATE",
|
991
|
+
page_index: int = 1,
|
992
|
+
) -> dict:
|
993
|
+
"""
|
994
|
+
Get Case by User ID
|
995
|
+
"""
|
996
|
+
params = {
|
997
|
+
"date_created_from": date_created_from,
|
998
|
+
"date_created_to": date_created_to,
|
999
|
+
"sort_by": sort_by,
|
1000
|
+
"status_flag": status_flag,
|
1001
|
+
"page_index": page_index,
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
user_ids = ",".join(user_ids)
|
1005
|
+
|
1006
|
+
url = f"https://apix.cisco.com/case/v3/cases/users/user_ids/{user_ids}"
|
1007
|
+
|
1008
|
+
response = requests.get(
|
1009
|
+
url=url,
|
1010
|
+
headers=self.__headers,
|
1011
|
+
params=params,
|
1012
|
+
verify=self.__verify,
|
1013
|
+
proxies=self.__proxies,
|
1014
|
+
timeout=REQUESTS_TIMEOUT,
|
1015
|
+
)
|
1016
|
+
|
1017
|
+
return response.json()
|
1018
|
+
|
1019
|
+
|
1020
|
+
#### Product Information ####################################################################################
|
1021
|
+
|
1022
|
+
|
1023
|
+
class PI:
|
1024
|
+
"""
|
1025
|
+
Product Information
|
1026
|
+
"""
|
1027
|
+
|
1028
|
+
__headers = None
|
1029
|
+
__verify = None
|
1030
|
+
__proxies = None
|
1031
|
+
|
1032
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
1033
|
+
"""
|
1034
|
+
Class Init Function
|
1035
|
+
"""
|
1036
|
+
self.__verify = verify
|
1037
|
+
self.__proxies = proxies
|
1038
|
+
|
1039
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
1040
|
+
|
1041
|
+
self.__headers = {"Authorization": f"Bearer {token}", "Accept": "application/json"}
|
1042
|
+
|
1043
|
+
def getBySerialNumbers(self, serial_numbers: list, page_index: int = 1) -> dict:
|
1044
|
+
"""
|
1045
|
+
Get Product Information by Serial Numbers
|
1046
|
+
"""
|
1047
|
+
params = {"page_index": page_index}
|
1048
|
+
|
1049
|
+
serial_numbers = ",".join(serial_numbers)
|
1050
|
+
|
1051
|
+
url = f"https://apix.cisco.com/product/v1/information/serial_numbers/{serial_numbers}"
|
1052
|
+
|
1053
|
+
response = requests.get(
|
1054
|
+
url=url,
|
1055
|
+
headers=self.__headers,
|
1056
|
+
params=params,
|
1057
|
+
verify=self.__verify,
|
1058
|
+
proxies=self.__proxies,
|
1059
|
+
timeout=REQUESTS_TIMEOUT,
|
1060
|
+
)
|
1061
|
+
|
1062
|
+
return response.json()
|
1063
|
+
|
1064
|
+
def getByProductIDs(self, product_ids: list, page_index: int = 1) -> dict:
|
1065
|
+
"""
|
1066
|
+
Get Product Information by Product IDs
|
1067
|
+
"""
|
1068
|
+
params = {"page_index": page_index}
|
1069
|
+
|
1070
|
+
product_ids = ",".join(product_ids)
|
1071
|
+
|
1072
|
+
url = f"https://apix.cisco.com/product/v1/information/product_ids/{product_ids}"
|
1073
|
+
|
1074
|
+
response = requests.get(
|
1075
|
+
url=url,
|
1076
|
+
headers=self.__headers,
|
1077
|
+
params=params,
|
1078
|
+
verify=self.__verify,
|
1079
|
+
proxies=self.__proxies,
|
1080
|
+
timeout=REQUESTS_TIMEOUT,
|
1081
|
+
)
|
1082
|
+
|
1083
|
+
return response.json()
|
1084
|
+
|
1085
|
+
def getMDFInformationByProductIDs(self, product_ids: list, page_index: int = 1) -> dict:
|
1086
|
+
"""
|
1087
|
+
Get Product Information by Product IDs
|
1088
|
+
"""
|
1089
|
+
params = {"page_index": page_index}
|
1090
|
+
|
1091
|
+
product_ids = ",".join(product_ids)
|
1092
|
+
|
1093
|
+
url = f"https://apix.cisco.com/product/v1/information/product_ids/{product_ids}"
|
1094
|
+
|
1095
|
+
response = requests.get(
|
1096
|
+
url=url,
|
1097
|
+
headers=self.__headers,
|
1098
|
+
params=params,
|
1099
|
+
verify=self.__verify,
|
1100
|
+
proxies=self.__proxies,
|
1101
|
+
timeout=REQUESTS_TIMEOUT,
|
1102
|
+
)
|
1103
|
+
|
1104
|
+
return response.json()
|
1105
|
+
|
1106
|
+
|
1107
|
+
#### RMA ####################################################################################################
|
1108
|
+
|
1109
|
+
|
1110
|
+
class RMA:
|
1111
|
+
"""
|
1112
|
+
RMA
|
1113
|
+
"""
|
1114
|
+
|
1115
|
+
__headers = None
|
1116
|
+
__verify = None
|
1117
|
+
__proxies = None
|
1118
|
+
|
1119
|
+
def __init__(self, key: str, secret: str, verify: bool = True, proxies: dict = None) -> None:
|
1120
|
+
"""
|
1121
|
+
Class Init Function
|
1122
|
+
"""
|
1123
|
+
self.__verify = verify
|
1124
|
+
self.__proxies = proxies
|
1125
|
+
|
1126
|
+
token = get_cisco_support_token(key, secret, verify, proxies)
|
1127
|
+
|
1128
|
+
self.__headers = {"Authorization": f"Bearer {token}", "Accept": "application/json"}
|
1129
|
+
|
1130
|
+
def getByRMANumber(self, rma_numbers: str) -> dict:
|
1131
|
+
"""
|
1132
|
+
Get RMA by RMA Number
|
1133
|
+
"""
|
1134
|
+
params = {}
|
1135
|
+
|
1136
|
+
url = f"https://apix.cisco.com/return/v1.0/returns/rma_numbers/{rma_numbers}"
|
1137
|
+
|
1138
|
+
response = requests.get(
|
1139
|
+
url=url,
|
1140
|
+
headers=self.__headers,
|
1141
|
+
params=params,
|
1142
|
+
verify=self.__verify,
|
1143
|
+
proxies=self.__proxies,
|
1144
|
+
timeout=REQUESTS_TIMEOUT,
|
1145
|
+
)
|
1146
|
+
|
1147
|
+
return response.json()
|
1148
|
+
|
1149
|
+
def getByUserID(
|
1150
|
+
self,
|
1151
|
+
user_ids: str,
|
1152
|
+
fromDate: str = None,
|
1153
|
+
toDate: str = None,
|
1154
|
+
status: str = None,
|
1155
|
+
sortBy: str = "orderdate",
|
1156
|
+
) -> dict:
|
1157
|
+
"""
|
1158
|
+
Get RMA by User IS
|
1159
|
+
"""
|
1160
|
+
params = {"fromDate": fromDate, "toDate": toDate, "status": status, "sortBy": sortBy}
|
1161
|
+
|
1162
|
+
url = f"https://apix.cisco.com/return/v1.0/returns/users/user_ids/{user_ids}"
|
1163
|
+
|
1164
|
+
response = requests.get(
|
1165
|
+
url=url,
|
1166
|
+
headers=self.__headers,
|
1167
|
+
params=params,
|
1168
|
+
verify=self.__verify,
|
1169
|
+
proxies=self.__proxies,
|
1170
|
+
timeout=REQUESTS_TIMEOUT,
|
1171
|
+
)
|
1172
|
+
|
1173
|
+
return response.json()
|