Restconf Cisco API Automation Tutorial:REST API GET request from Python and parse IOS interfaces

Опубликовано: 17 Сентябрь 2023
на канале: NetworkEvolution
535
4

#networkautomation #networkengineers #restapis
Unlock the Power of Network Automation: Enroll in our Comprehensive Udemy Course Today
https://www.udemy.com/course/python-f...

𝗣𝗹𝗮𝘆𝗹𝗶𝘀𝘁: 𝗣𝘆𝘁𝗵𝗼𝗻 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗡𝗲𝘁𝘄𝗼𝗿𝗸 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝘀(𝟭𝟮𝟬+ 𝗩𝗶𝗱𝗲𝗼𝘀)
   • Welcome to NetworkEvolution !!  

☸𝗣𝗹𝗲𝗮𝘀𝗲 𝗳𝗼𝗹𝗹𝗼𝘄 𝗯𝗲𝗹𝗼𝘄 𝗚𝗶𝘁𝗛𝘂𝗯 𝗣𝗮𝗴𝗲 𝗳𝗼𝗿 𝘁𝗵𝗲 𝗹𝗮𝘁𝗲𝘀𝘁 𝗰𝗼𝗱𝗲𝘀:
https://github.com/network-evolution

𝗣𝗹𝗮𝘆𝗹𝗶𝘀𝘁: 𝗖𝗶𝘀𝗰𝗼 𝗡𝗫𝗔𝗣𝗜-𝗖𝗟𝗜 𝗣𝘆𝘁𝗵𝗼𝗻 𝗔𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗼𝗻: 𝗡𝗲𝘅𝘂𝘀 𝟵𝗸 :𝗣𝗮𝗿𝘀𝗲 𝗷𝘀𝗼𝗻 𝗫𝗠𝗟 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝗗𝗮𝘁𝗮
   • Cisco Nexus 9K installation and API s...  

𝗣𝗹𝗮𝘆𝗹𝗶𝘀𝘁: 𝗟𝗲𝗮𝗿𝗻 𝘁𝗼 𝗣𝗮𝗿𝘀𝗲 𝗖𝗶𝘀𝗰𝗼 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝘂𝘀𝗶𝗻𝗴 𝗣𝘆𝘁𝗵𝗼𝗻 𝗥𝗲𝗴𝗘𝘅:𝗿𝗲 𝗧𝘂𝘁𝗼𝗿𝗶𝗮𝗹(𝟭𝟱+ 𝗩𝗶𝗱𝗲𝗼𝘀)
   • Learn to write your own RegEx Parser ...  

In this tutorial we will see how to trigger cisco IOS rest conf API get request from Python
Python request library tutorial
python api tutorial
how to trigger api request to cisco ios using python
rest api beginner example
rest api tutorial
rest api header example
get all the interface configurations
application/yang-data+json
get the api response in text format
resolve requests.exceptions.SSLError
cisco api header, data, ssl verify false example
request library url, header and data format for cisco automation
how to get cisco api response in json format
response.json() in api requests
convert text data in to dictionary format using json python library. tutorial on json loads
how to parse cisco interface using python
cisco api automation for interface configuration
GigabitEthernet interface parsing using cisco restconf api


######
Code
import json
from pprint import pprint
import requests
from urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

url = "https://192.168.0.63:443/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet"

payload={}
headers = {
'Accept': 'application/yang-data+json',
'Authorization': 'Basic YWRtaW46YWRtaW4='
}

response = requests.request("GET", url, headers=headers, data=payload, verify=False)
print(dir(response))
print(type(response))
print(type(response.text))
print(type(response.json()))

t = response.text
dict_data = json.loads(t)

dict_data = response.json()
int_list = dict_data['Cisco-IOS-XE-native:GigabitEthernet']
pprint(int_list)
for intf in int_list:
try:
print("GigabitEthernet"+intf['name'], intf['ip']['address']['primary']['address'])
except KeyError:
continue


Смотрите видео Restconf Cisco API Automation Tutorial:REST API GET request from Python and parse IOS interfaces онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал NetworkEvolution 17 Сентябрь 2023. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 535 раз и оно понравилось 4 посетителям.