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.
curl -X POST -utest:test http://localhost:8002/api/v1/auth/login
curl** -X POST -utest:test http://localhost:8002/api/v1/auth/login -d '{"org": "myorg"}'
curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/agents
curl -H "Authorization: Bearer <access_token>" "http://localhost:8002/api/v1/agents?name=*server*"
curl -H "Authorization: Bearer <access_token>" -X PUT http://localhost:8002/api/v1/agents/1 -d '{"Tags": [{"ID": 2}]}'
curl -H "Authorization: Bearer <access_token>" -X PUT http://localhost:8002/api/v1/agents/1 -d '{"Tags": []}'
curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/files
curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/files/1
curl -H "Authorization: Bearer <access_token>" -X DELETE http://localhost:8002/api/v1/files/1
curl -H "Authorization: Bearer <access_token>" -X PUT http://localhost:8002/api/v1/vclgroups/1/deploy
curl -H "Authorization: Bearer <access_token>" http://localhost:8002/api/v1/apilogs
curl -X POST -H "Authorization: Refresh <refresh_token>" localhost:8002/api/v1/auth/refresh
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"}%