show spanning-tree vlan 10
Python
Copy
import json

"""
Modify these please
"""
url='http://<IP_Address>/ins'
switchuser='<User_ID>'
switchpassword='<Password>'

myheaders={'content-type':'application/json'}
payload={
  "ins_api":{
  "version": "1.0",
  "type": "cli_show",
  "chunk": "0",
  "sid": "1",
  "input": "show spanning-tree vlan 10  ",
  "output_format": "json"
}

response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json()
output = json.dumps(response, indent=4, sort_keys=True)


{
  "ins_api": {
    "type": "cli_show",
    "version": "1.0",
    "sid": "eoc",
    "outputs": {
      "output": {
        "input": "show spanning-tree vlan 10  ",
        "msg": "Success",
        "code": "200",
        "body": {
          "TABLE_tree": {
            "ROW_tree": {
              "tree_id": "10",
              "tree_tree_type": "vlan",
              "tree_protocol": "rstp",
              "port_count": "9",
              "bridge_mac": "0023.04ee.be64",
              "bridge_priority": "32778",
              "tree_designated_root": "0023.04ee.c1e8",
              "tree_designated_root_priority": "4106",
              "stp_active": "enabled",
              "root_path_cost": "2",
              "root_port_if_index": "port-channel100",
              "root_port_priority": "128",
              "root_port_number": "4195",
              "topology_change": "false",
              "topology_change_detected": "false",
              "topology_change_count": "0",
              "topology_change_time_since_last": "35446",
              "tc_initiator_if_index": null,
              "bridge_forward_delay": "15",
              "bridge_max_age": "20",
              "bridge_hello_time": "2",
              "max_age": "20",
              "hello_time": "2",
              "forward_delay": "15",
              "hold_time": "1",
              "hello_timer": "0",
              "topology_change_timer": "0",
              "tcn_timer": "0",
              "aging_timer": "0",
              "disabled": "0",
              "blocking": "0",
              "listening": "0",
              "learning": "0",
              "forwarding": "9",
              "invalid": "0",
              "TABLE_port": {
                "ROW_port": {
                  "if_index": "port-channel1"
                }
              }
            }
          }
        }
      }
    }
  }
}