To get any device ports we can use the following API call:
curl -s -k -X GET -u 'u:p' 'https://D42-IP/api/1.0/switchports/?switch_id=device_id' --insecure
Where
switch_id can be any device ID on the system
To check if the port has any connectivity to other port on the system we can use the following parameter:
curl -s -k -X GET -u 'admin:adm!nd42' 'https://D42-IP/api/1.0/switchports/?switch_id=device_id&include_cols=port,is_connected' --insecure
To check all available parameters you can refer to this link:
https://api.device42.com/#get-all-switch-ports
To change the port type
curl -X POST -d 'port=FastEthernet0&switch=CARVZN&port_type=logical' -u 'u:p' 'https://D42-IP/api/1.0/switchports/' --insecure
To rename the port
curl -X POST -d 'port=FastEthernet0&switch=CARVZN&new_port=FastEthernet0-0' -u 'u:p' 'https://D42-IP/api/1.0/switchports/' --insecure
for renaming we use "new_port" parameter
To create a port
curl -X POST -d 'port=FastEthernet0-1&switch=CARVZN' -u 'u:p' 'https://D42-IP/api/1.0/switchports/' --insecure
To create a child port
curl -s -k -X POST -u 'u:p' -d 'port=FastEthernet01&parent_port=FastEthernet0-1&parent_port_device=CARVZN' 'https://D42-IP/api/1.0/switchports/' --insecure | jq
here we used "parent_port" parameter to indicate the parent port for which we need to create the child port.
For all available attributes and options you can refer to this link:
Comments
0 comments
Article is closed for comments.