Skip to content

Instantly share code, notes, and snippets.

@tundragon
Created August 20, 2022 12:47
Show Gist options
  • Save tundragon/afce1dd2387f9cfc3e4469ca18efacb4 to your computer and use it in GitHub Desktop.
Save tundragon/afce1dd2387f9cfc3e4469ca18efacb4 to your computer and use it in GitHub Desktop.
import requests
import json
from pprint import pprint
from dotenv import load_dotenv, find_dotenv
import os
load_dotenv(find_dotenv())
CISCOU = os.environ.get("CISCOU")
CISCOP = os.environ.get("CISCOP")
device = {
"ip": "10.1.1.103",
"username": CISCOU,
"password": CISCOP,
"port": "443",
}
headers = {
"Accept" : "application/yang-data+json",
"Content-Type" : "application/yang-data+json",
}
payload = {
"ietf-interfaces:interface": [
{
"name": "gi3",
"description": "HELLO"
}
]
}
# retreive all details
url = f"https://{device['ip']}/restconf/data/ietf-interfaces:interfaces/interface"
print(url)
requests.packages.urllib3.disable_warnings()
response = requests.patch(url,
headers=headers,
data=json.dumps(payload),
auth=(device['username'],
device['password']),
verify=False)
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment