-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnso.py
More file actions
27 lines (21 loc) · 695 Bytes
/
nso.py
File metadata and controls
27 lines (21 loc) · 695 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
import requests
def main():
api_path = "http://10.32.1.188:8080/api"
basic_auth = ("admin", "admin")
accept_list = [
"application/vnd.yang.api+json",
"application/vnd.yang.datastore+json",
"application/vnd.yang.data+json",
"application/vnd.yang.collection+json",
]
get_headers = {"Accept": ",".join(accept_list)}
post_headers = {"Content-Type": "application/vnd.yang.data+json"}
get_resp = requests.get(
f"{api_path}/running/devices/device",
auth=basic_auth,
headers=get_headers
)
devices = get_resp.json()["collection"]["tailf-ncs:device"]
print(devices)
if __name__ == "__main__":
main()