VPS Management ============== Index ----------------- - [List all VPS servers](#vpss) - [Get a VPS detail](#vps) - [Get VNC console](#vps-console) - [Reboot VPS](#vps-reboot) - [Hard reboot VPS](#vps-hard) - [CPU stats](#vps-cpu-stats) - [List all VPS snapshots](#vps-snapshot-list) - [Create VPS snapshot](#vps-snapshot-create) - [Restore VPS from a snapshot](#vps-snapshot-restore) - [Delete VPS snapshot](#vps-snapshot-delete) List all VPS servers {#vpss} ---------------------------- Get a list of Virtual Private Servers (VPS). >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:id/vps HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "items": [ { "id": 123456, "name": "vpsname" } ], "pager": { "page": 1, "pagesize": null, "items": 1 } } ``` Get a VPS detail {#vps} ----------------------- Get VPS detail by id or name. >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:id/vps/:id-or-name HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "id": 123456, "name": "vpsname", "status": "ACTIVE", "created": 1381882379, "updated": 1393440856, "progress": 0, "ips": [ "195.210.123.123" ], "reverse_dns": { "195.210.123.123": "vpsname.vps.websupport.sk" }, "flavor": { "disk": 10, "vcpus": 1, "ram": 1024, "name": "vpsname.1" } } ``` Get VNC console {#vps-console} ------------------------------ >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/vnc" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/vnc HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "id": 51203, "name": "katalyzer", "vnc": { "url": "https://novnc.scaledo.com:6080/vnc_auto.html?token=4bc2c4fc-73a5-434f-aed0-12ab8fcc6abd", "token": "4bc2c4fc-73a5-434f-aed0-12ab8fcc6abd", "websocket": "novnc.scaledo.com:6080/websockify" } } ``` Reboot VPS {#vps-reboot} -------------------------- >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/reboot" -X PUT -u key:signature -H "Date: request_date_time" ``` >Request ```http PUT https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/reboot HTTP/1.1 Accept: application/json ``` >Response `200` (success) ```json { "status": "success", "item": { "id": 51203, "name": "katalyzer" }, "errors": {} } ``` Hard reboot VPS {#vps-hard} -------------------------- >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/hard-reboot" -X PUT -u key:signature -H "Date: request_date_time" ``` >Request ```http PUT https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/hard-reboot HTTP/1.1 Accept: application/json ``` >Response `200` (success) ```json { "status": "success", "item": { "id": 51203, "name": "katalyzer" }, "errors": {} } ``` CPU stats {#vps-cpu-stats} -------------------------- Paramaters for changing time interval and period: - **interval** (string) `day`, `hour` or `minute` - **length** (integer) number of shown measurements (time period depends on choosen interval) Example: - get CPU usage for last 24 hour in hour intervals: `?interval=hour&length=24` - get CPU usage for last month in day intervals: `?interval=day&length=31` >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/cpu-stats" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/cpu-stats HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "range": [ 1402824473, 1403256472 ], "items": [ { "timestamp": 1402786800, "write_bytes": 307200, "memory_vms": 9362419712, "memory_rss": 1524166656, "system": 1140, "read_bytes": 7, "user": 2781 }, { "timestamp": 1402873200, "write_bytes": 143360, "memory_vms": 9362419712, "memory_rss": 1524355072, "system": 1110, "read_bytes": 4, "user": 2796 }, { "timestamp": 1402959600, "write_bytes": 4993024, "memory_vms": 9362419712, "memory_rss": 1525071872, "system": 1046, "read_bytes": 5, "user": 2724 } // etc. ] } ``` Traffic stats {#vps-cpu-traffic} -------------------------- Paramaters for changing time interval and period: - **interval** (string) `day`, `hour` or `minute` - **length** (integer) number of shown measurements (time period depends on choosen interval) >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/traffic-stats" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/traffic-stats HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "range": [ 1402841985, 1405520384 ], { "timestamp": 1402869600, "obyt": 0, "opkt": 0, "ibyt": 205638, "ipkt": 2668 }, { "timestamp": 1402956000, "obyt": 0, "opkt": 0, "ibyt": 585400, "ipkt": 2627 }, { "timestamp": 1403042400, "obyt": 0, "opkt": 0, "ibyt": 294021, "ipkt": 2139 } // etc. ] } ``` List all VPS snapshots {#vps-snapshot-list} ------------------------------------------- Retrieve a list of all snapshots for the specified VPS >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/snapshot" -v -u key:signature -H "Date: request_date_time" ``` >Request ```http GET https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/snapshot HTTP/1.1 Accept: application/json ``` >Response `200` ```json { "items": [{ "created": 1402869600, "name": "vps.snapshot.1", "description": "my description", "status": "available" }] } ``` Create VPS snapshot {#vps-snapshot-create} --------------------------------------------- Saves the current state of the specified VPS into a snapshot. It is recommended to shut off your server before snapshotting, otherwise we will not be able to guarantee the consistency of the snapshot. This may lead to problems when you decide to restore your server from the snapshot. #### Parameters | Name | Type | Required | |----------------|--------|----------| | description | string | no | >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/snapshot" -X POST -d '{"description": "my description"}' -v -u key:signature -H "Date: request_date_time" ``` >Request ```http POST https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/snapshot HTTP/1.1 Accept: application/json Content-Type: application/json { "description": "my description" } ``` >Response `201` ```json { "created": 1402869600, "name": "vps.snapshot.1", "description": "my description", "status": "creating" } ``` >Response `403` ```json { "code": 403, "message": "Snapshot limit exceeded" } ``` Restore VPS from a snapshot {#vps-snapshot-restore} ----------------------------------------------------- Rollbacks the specified VPS to the state of the specified snapshot. >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/snapshot/:snapshot-name" -X POST -v -u key:signature -H "Date: request_date_time" ``` >Request ```http POST https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/:snapshot-name HTTP/1.1 Accept: application/json ``` >Response: 204 ```json ``` Delete VPS snapshot {#vps-snapshot-delete} -------------------------------------------- Deletes the specified VPS snapshot >Curl ```sh curl "https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/snapshot/:snapshot-name" -X DELETE -v -u key:signature -H "Date: request_date_time" ``` >Request ```http DELETE https://rest.websupport.sk/v1/user/:id/vps/:id-or-name/:snapshot-name HTTP/1.1 Accept: application/json ``` >Response: 204 ```json ```