...
HTTP Verv | CRUD | ROS | Description |
---|---|---|---|
GET | Read | To get the records. | |
PATCH | Update/Modify | set | To update a single record. |
PUT | Create | add | To create a new record. |
DELETE | Delete | remove | To delete a single record. |
POST | Universal method to get access to all console commands. |
URL Format
GET
This method allows getting the list of all records or a single record from the specified menu encoded in the URL.
For example, get all IP addresses (equivalent to the "'ip/address/print"
command ' command from the CLI):
Code Block | ||||
---|---|---|---|---|
| ||||
$ curl -k -u admin: https://10.155.101.214/rest/ip/address [{".id":"*1","actual-interface":"ether2","address":"10.0.0.111/24","disabled":"false", "dynamic":"false","interface":"ether2","invalid":"false","network":"10.0.0.0"}, {".id":"*2","actual-interface":"ether3","address":"10.0.0.109/24","disabled":"true", "dynamic":"false","interface":"ether3","invalid":"false","network":"10.0.0.0"}] |
...
Code Block | ||||
---|---|---|---|---|
| ||||
$ curl -k -u admin: "https://10.155.101.214/rest/ip/address?network=10.155.101.0&dynamic=true" [{".id":"*8","actual-interface":"sfp12","address":"10.155.101.214/24","disabled":"false", "dynamic":"true","interface":"sfp12","invalid":"false","network":"10.155.101.0"}] |
Another example to return returns only addresses on the "dummy" interface and with the comment "test":
...
If you want to return only specific properties, you can use the '.proplist
', followed by the '=' and a lost list of comma-separated properties. For example, to show only the address and if it's disabled:
...
REST response is structured similar to API response:
- If the response contains '
!re
' sentences (records), the JSON reply will contain a list of objects. - If the '
!done
' sentence contains data, the JSON reply will contain an object with the data. - If there are no records or data in the the '
!done
' sentence, the response will hold an empty list.
There are two special keys: .proplist
and .query
, which are used with the print
command word. Read more about APIs responses, proplistsprop lists, and queries in the API documentation.
Proplist
The '.proplist
' key is used to create .proplist
attribute word. The values can be a single string with comma-separated values:
...
Code Block | ||||
---|---|---|---|---|
| ||||
$ curl -k -u admin: -X POST https://10.155.101.214/rest/ip/address/print\ --data '{"_proplist": ["address","interface"]}' -H "content-type: application/json" [{"address":"192.168.99.2/24","interface":"dummy"}, {"address":"172.16.5.1/24","interface":"sfpplus1"}, {"address":"172.16.6.1/24","interface":"sfp2"}, {"address":"172.16.7.1/24","interface":"sfp3"}, {"address":"10.155.101.214/24","interface":"sfp12"}, {"address":"192.168.111.111/32","interface":"dummy"}] |
Query
The '.query
' key is used to create a query stack. The value is a list of query words. For example this POST request :
...
Code Block | ||
---|---|---|
| ||
/interface/print ?type=ether ?type=vlan ?#|! |
For example, lets let's combine 'query' and 'proplist', to return '.id', 'address', and 'interface' properties for all dynamic records and records with the network 192.168.111.111
...
If the command runs indefinitely, it will timeout and the connection will be closed with an error. Current The current timeout interval is 60 seconds. To avoid timeout errors, add a parameter that would sufficiently limit the command execution time.
Note |
---|
Timeout is not affected by the parameters passed to the commands. If the command is set to run for an hour, it will terminate early and return an error message. |
For example, lets let's see what we get when the ping command exceeds the timeout and how to prevent this by add adding a count parameter:
Code Block | ||||
---|---|---|---|---|
| ||||
$ curl -k -u admin: -X POST https://10.155.101.214/rest/ping \ --data '{"address":"10.155.101.1"}' \ -H "content-type: application/json" {"detail":"Session closed","error":400,"message":"Bad Request"} $ curl -k -u admin: -X POST https://10.155.101.214/rest/ping \ --data '{"address":"10.155.101.1","count":"4"}' \ -H "content-type: application/json" [{"avg-rtt":"453us","host":"10.155.101.1","max-rtt":"453us","min-rtt":"453us","packet-loss":"0","received":"1","sent":"1","seq":"0","size":"56","time":"453us","ttl":"64"}, {"avg-rtt":"417us","host":"10.155.101.1","max-rtt":"453us","min-rtt":"382us","packet-loss":"0","received":"2","sent":"2","seq":"1","size":"56","time":"382us","ttl":"64"}, {"avg-rtt":"495us","host":"10.155.101.1","max-rtt":"650us","min-rtt":"382us","packet-loss":"0","received":"3","sent":"3","seq":"2","size":"56","time":"650us","ttl":"64"}, {"avg-rtt":"461us","host":"10.155.101.1","max-rtt":"650us","min-rtt":"359us","packet-loss":"0","received":"4","sent":"4","seq":"3","size":"56","time":"359us","ttl":"64"}] |
...