[ES] – CDN Purge Using VIMS API

Purge specific cache content from the CDN using VIMS API REST

To authenticate you will need an API Token which must be included in the header of each request. You can get your API token in VIMS Console by clicking on your email address on the top-right corner and then selecting the API tokens tab.

 

Getting information

To get information from your CDN: GET /api/services/cdn/

curl "https://vims.planisys.
net/api/services/cdn/" -H "Authorization: sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

List all CDN type services

Response 200 OK

 {
 "count": 1,
 "data": [
 {
 "active": true,
 "bundle": {},
 "company": {
 "id": ,
 "name": "Company name"
 },
 "configs": [],
 "description": "CDN name",
 "id": ,
 "meta_service": {},
 "monitored_urls": [],
 "name": null,
 "properties": [],
 "stats": [],
 "sub_services": [
 {
 "description": "",
 "id": ,
 "type": {
 "id": ,
 "name": "CDN_HOST"
 },
 "vm": {
 "company": {
 "id": ,
 "name": ""
 },
 "id": ,
 "name": "cdn-ejemplo.planisys.net",
 "networking": [
 {
 "id": ,
 "ip": "365.124.12.xxx"
 }
 ]
 }
 }
 ],
 "tasks": [],
 "type": {
 "id": 1,
 "name": "CDN"
 },
 "vm": {}
 }
 ],
 "message": "found",
 "status": "ok"
 }
 
Delete cached content

POST /api/services/cdn/<:cdn_id>/purge

Parameters
    • target – <:vm_id> o “all”

If you wish to purge from a determined host, you can use the host ID (which you can get from VIMS Console) or choose “all” to purge from all.

    • pattern – regex o “*”

The “*” is to purge all. In case you wish to purge based on a pattern, you have to use a  regular expression.

Response 200 OK
{
  "message": "purge running",
  "status": "ok",
  "task_id": <:task_id>
}
Response 400
{
  "message": "failed creation : some reason",
  "status": "error"
}
Bash example
curl "https://vims.planisys.net/api/services/cdn/<:cdn_id>/purge" -H "Content-Type: application/json"-H 'Authorization: sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -X POST -d '{"target":"<:vm_id>", "pattern":"jpg"}'
Check on purge result

GET /api/tasks/<:task_id>

Bash example
curl "https://vims.planisys.net/api/task/<:task_id>" -H 'Authorization: sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
Response 200 OK
{
  "data": {
    "comment": null,
    "end": "Wed, 04 Feb 2015 18:11:15 GMT",
    "hn": {},
    "id": <:task_id>,
    "name": "Task name",
    "output": "Command failed: ['output']",
    "percentage": 100,
    "service": {
      "description": "CDN Name",
      "id": <:cdn_id>,
      "name": null
    },
    "start": "Wed, 04 Feb 2015 18:06:06 GMT",
    "status": "FAILURE",
    "task_remote_id": "28e8a51e-1a9d-xxxx-xxxx-65e81117742a",
    "task_type": "celery",
    "user": {
      "email": "user@domain.com",
      "id": <:user_id>
    },
    "vims_task_type": "cdn_purge",
    "vm": {}
  },
  "message": "bundle found",
  "status": "ok"
}