show port-security
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 port-security",
  "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 port-security",
        "msg": "Success",
        "code": "200",
        "body": {
          "total_addr": [
            "4",
            "4"
          ],
          "max_sys_limit": "8188",
          "TABLE_eth_port_sec_interfaces": {
            "ROW_eth_port_sec_interfaces": [
              {
                "num_elems": "1",
                "cmdid_show_index": "0"
              },
              {
                "secure_port": "Ethernet1/2",
                "port_state": "1",
                "max_secure_addr": "789",
                "security_violation": "0",
                "security_action": "shutdown",
                "current_addr": "5",
                "num_val": "1",
                "num_elems": "1",
                "cmdid_show_index": "1"
              }
            ]
          }
        }
      }
    }
  }
}