-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcisco_restconf.py
More file actions
38 lines (25 loc) · 801 Bytes
/
Copy pathcisco_restconf.py
File metadata and controls
38 lines (25 loc) · 801 Bytes
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
import requests
import json
def get_token():
url = "https://sandboxapicem.cisco.com/api/v1/ticket"
payload = {"username": "devnetuser",
"password": "Cisco123!"}
headers = {
'content-type': 'application/json',
}
r = requests.request("POST", url, headers=headers, data=json.dumps(payload)).json()
token = r["response"]["serviceTicket"]
return token
def get_network_config(token):
url = "https://sandboxapicem.cisco.com/api/v1/network-device/config"
headers = {
'X-AUTH-TOKEN': token
}
response = requests.request("GET", url, headers=headers).json()
return response
def main():
token = get_token()
network_config = get_network_config(token)
print(network_config)
if __name__ == "__main__":
main()