-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete.py
25 lines (18 loc) · 862 Bytes
/
delete.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests
from requests.auth import HTTPBasicAuth
import json
requests.packages.urllib3.disable_warnings()
USER = 'arista'
PASS = 'arista'
headers = {'Content-Type': 'application/yang-data+json', 'Accept': 'application/yang-data+json'}
api_call = "https://10.73.1.105:6020/restconf/data/ietf-interfaces:interfaces/interface=Loopback100"
# check if int lo100 exists
print("get int lo100")
result_get = requests.get(api_call, auth=HTTPBasicAuth(USER, PASS), headers=headers, verify=False)
print("status_code is %s" % (result_get.status_code))
if result_get.status_code == 200:
print("content is %s" % (result_get.json()))
# delete int lo100
print("deleting int lo100")
result_delete = requests.delete(api_call, auth=HTTPBasicAuth(USER, PASS), headers=headers, verify=False)
print("status_code is %s" % (result_delete.status_code))