About a REST API
An API, or application programming interface, is a set of rules that define how applications or devices can connect to and communicate with each other. A REST API is an API that conforms to the design principles of the REST, or representational state transfer architectural style. For this reason, REST APIs are sometimes referred to RESTful APIs.
A REST API allows developers to work with Roxy-WI: to start, stop and restart the services, to add, to edit and to delete ACLs, etc. It communicates via JSON requests and JSON responses. Request headers and parameters are also important in REST API calls because they include important identifier information such as metadata, authorizations, uniform resource identifiers (URIs), caching, cookies and more. Request headers and response headers, along with conventional HTTP status codes, are used within well-designed REST APIs.
How to get the list of all available endpoints
To get the list of all available endpoints perform the following command:
How to login (get token)
You need an authorization token to use the API. Make the following request to get a token:
How to start/stop/restart HAProxy service
Make the following request to stop the HAProxy service:
You should get the following response:
How to add an ACL to a section
Make the following request to add an ACL to a section:
The if parameter may take the following values:
- host_starts
- host_ends
- path_starts
- path_ends
- path_ends
- src_ip
The then parameter may take the following values:
- use_backend
- redirect
- allow
- deny
- return
- set-header
The action parameter may take the following values:
- save
- test
- restart
- reload
How to delete an ACL from a section
Make the following request to delete an ACL from a section:
The if parameter may take the following values:
- host_starts
- host_ends
- path_starts
- path_ends
- path_ends
- src_ip
The then parameter may take the following values:
- use_backend
- redirect
- allow
- deny
- return
- set-header
The action parameter may take the following values:
- save
- test
- restart
- reload