2 Star 0 Fork 0

mirrors_CiscoDevNet/nxos-device-level-apis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
add_temp_user.py 815 Bytes
一键复制 编辑 原始数据 按行查看 历史
Your Name Comes Here 提交于 2024-08-24 03:15 +08:00 . added 9 files from original repo
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Assign requests.Session instance to session variable
session = requests.Session()
# Define URL and PAYLOAD variables
URL = "https://sbx-nxos-mgmt.cisco.com/api/aaaLogin.json"
PAYLOAD = {"aaaUser": {"attributes": {"name": "admin", "pwd": "Admin_1234!"}}}
# Obtain an authentication cookie
session.post(URL, json=PAYLOAD, verify=False)
# Define SYS_URL variable
SYS_URL = "https://sbx-nxos-mgmt.cisco.com/api/mo/sys.json"
# Obtain system information by making session.get call
# then convert it to JSON format then filter to system attributes
response = session.get(SYS_URL, verify=False).json()
# Now, access the JSON data as you were doing before
sys_info = response["imdata"][0]["topSystem"]["attributes"]
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_CiscoDevNet/nxos-device-level-apis.git
[email protected]:mirrors_CiscoDevNet/nxos-device-level-apis.git
mirrors_CiscoDevNet
nxos-device-level-apis
nxos-device-level-apis
main

搜索帮助