Search
Varnish Controller

API examples

These examples use curl to perform some basic API tasks with Varnish Controller. All output and input is JSON-structured data. Full Swagger API documentation can be viewed by starting the api-gw and visiting http://localhost:8002/docs/index.html. The host and port (localhost:8002) are
where the api-gw is listening.

Login as sys admin using basic auth

curl -X POST -utest:test http://localhost:8002/api/v1/auth/login

Login as basic auth user of an existing organization

curl** -X POST -utest:test http://localhost:8002/api/v1/auth/login -d '{"org": "myorg"}'

Get all agents

curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/agents 

Get all agents using filtering

curl -H "Authorization: Bearer <access_token>" "http://localhost:8002/api/v1/agents?name=*server*"

Assign tags to agent

curl -H "Authorization: Bearer <access_token>" -X PUT http://localhost:8002/api/v1/agents/1 -d '{"Tags": [{"ID": 2}]}'

Remove all tags from agent

curl -H "Authorization: Bearer <access_token>" -X PUT http://localhost:8002/api/v1/agents/1 -d '{"Tags": []}'

Get VCLs

curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/files

Get specific VCL

curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/files/1

Delete existing VCL

curl -H "Authorization: Bearer <access_token>" -X DELETE http://localhost:8002/api/v1/files/1

Deploy VCLGroup

curl -H "Authorization: Bearer <access_token>" -X PUT http://localhost:8002/api/v1/vclgroups/1/deploy

Get API log entries

curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/apilogs

Get new access/refresh token pair based on refresh token

curl -X POST -H "Authorization: Refresh <refresh_token>" localhost:8002/api/v1/auth/refresh

Errors

If an error occurs for a request, an error structure will be reported back. It will contain a trace ID (used in the system logs from the processes) that can be used to trace the error from the API-GW back to the agents. A human-readable error message and an errorKey that describes the scope of the error is reported back.

Example:

curl -H "Authorization: Bearer <access_token>" -X PUT http://localhost:8002/api/v1/vclgroups/2/deploy

{"traceId":"1coNQFLrcGkVcSXrOtfs0VtG3Ua","errorKey":"deploy","errorMsg":"id 2 not found"}%

®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203