Version Controller APIs ======================= This section shows the Rest API end-points of Version Controller. .. contents:: Table of contents :local: :backlinks: none :depth: 3 .. _Register Device: Register Device +++++++++++++++ .. http:post:: /api/device/register Register a device. :reqheader Content-Type: application/json :reqheader X-Access-Token: JWT-TOKEN **Example request**: .. tabs:: .. code-tab:: bash cURL $ curl --location --request POST 'https://vc-server/api/device/register' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: ' \ --data-raw '{ "mac": "your-device-mac", "firmware_version": "1.0", "name": "device-name", }' .. code-tab:: js var request = require('request'); var options = { 'method': 'POST', 'url': 'https://vc-server/api/device/register', 'headers': { 'Content-Type': 'application/json', 'X-Access-Token': '' }, body: JSON.stringify({"mac":"your-device-mac","firmware_version":"1.0","name":"device-name"}) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); .. code-tab:: python import requests url = "https://vc-server/api/device/register" payload = "{\n\t\"mac\": \"your-device-mac\",\n\t\"firmware_version\": \"1.0\",\n\t\"name\": \"device-name\"\n}" headers = { 'Content-Type': 'application/json', 'X-Access-Token': '' } response = requests.request("POST", url, headers=headers, data = payload) print(response.text.encode('utf8')) .. code-tab:: php setRequestUrl('https://vc-server/api/device/register'); $request->setRequestMethod('POST'); $body = new http\Message\Body; $body->append('{ "mac": "your-device-mac", "firmware_version": "1.0", "name": "device-name", }'); $request->setBody($body); $request->setOptions(array()); $request->setHeaders(array( 'Content-Type' => 'application/json', 'X-Access-Token': '' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); **Example response**: .. sourcecode:: json { "message": "Device inserted!" } .. sourcecode:: json { "message": "Device exists!" } :resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid .. Delete Device: Delete Device +++++++++++++++ .. http:delete:: /api/device/ Delete a device. :reqheader Content-Type: application/json :reqheader X-Access-Token: JWT-TOKEN **Example request**: .. tabs:: .. code-tab:: bash cURL $ curl --location --request DELETE 'https://vc-server/api/device/' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: ' \ --data-raw '{ "mac": "your-device-mac", }' **Example response**: .. sourcecode:: json { "message": "Device deleted!" } .. sourcecode:: json { "message": "Device does't exist!" } :resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid .. Get Device: Get Device +++++++++++++++ .. http:get:: /api/device/:mac Get a device. :reqheader Content-Type: application/json :reqheader X-Access-Token: JWT-TOKEN **Example request**: .. tabs:: .. code-tab:: bash cURL $ curl --location --request GET 'https://vc-server/api/device/' \ --header 'X-Access-Token: ' **Example response**: .. sourcecode:: json { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" } .. sourcecode:: json { "message": "Device does't exist!" } :resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid .. Get All Devices: Get All Devices +++++++++++++++ .. http:get:: /api/device/ Get all devices. :reqheader Content-Type: application/json :reqheader X-Access-Token: JWT-TOKEN **Example request**: .. tabs:: .. code-tab:: bash cURL $ curl --location --request GET 'https://vc-server/api/device/' \ --header 'X-Access-Token: ' **Example response**: .. sourcecode:: json [ { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" }, { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" } ] :resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid Get Report +++++++++++++++ .. http:get:: /api/report/:type Get report in json, xml, and pdf format. :reqheader Content-Type: application/json :reqheader X-Access-Token: JWT-TOKEN **Example request**: .. tabs:: .. code-tab:: bash cURL $ curl --location --request GET 'https://vc-server/api/report/' \ --header 'X-Access-Token: ' **Example response**: .. sourcecode:: json [ { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" }, { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" } ] .. sourcecode:: xml device-firmware-version device-mac device-name device-firmware-version device-mac device-name .. sourcecode:: pdf :resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid .. _Next Rollout: Next Rollout ++++++++++++ .. http:post:: /api/device/next/rollout Check next rollout :reqheader Content-Type: application/json :reqheader X-Access-Token: JWT-TOKEN **Example request**: .. tabs:: .. code-tab:: bash cURL curl --location --request POST 'https://vc-server/api/device/next/rollout' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: ' \ --data-raw '{ "mac": "your-device-mac", "firmware_version": "1.0" }' .. code-tab:: js var request = require('request'); var options = { 'method': 'POST', 'url': 'https://vc-server/api/device/next/rollout', 'headers': { 'Content-Type': 'application/json', 'X-Access-Token': '' }, body: JSON.stringify({"mac":"your-device-mac","firmware_version":"1.0"}) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); .. code-tab:: python import requests url = "https://vc-server/api/device/next/rollout" payload = "{\n\t\"mac\": \"your-device-mac\",\n\t\"firmware_version\": \"1.0\"\n}" headers = { 'Content-Type': 'application/json', 'X-Access-Token': '' } response = requests.request("POST", url, headers=headers, data = payload) print(response.text.encode('utf8')) .. code-tab:: php setRequestUrl('https://vc-server/api/device/next/rollout'); $request->setRequestMethod('POST'); $body = new http\Message\Body; $body->append('{ "mac": "your-device-mac", "firmware_version": "1.0" }'); $request->setBody($body); $request->setOptions(array()); $request->setHeaders(array( 'Content-Type' => 'application/json', 'X-Access-Token': '' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); **Example response**: .. sourcecode:: json { "rollout_id": "84", "rollout_name": "new-demo-rollout", "priority": "1", "start_date": "2021-04-02 09:30:00", "version": "2.0", "firmware_id": "11" } **If no rollout exists:** .. sourcecode:: json {} :resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid .. _Rollout Success: Rollout Success +++++++++++++++ .. http:post:: /api/device/success/rollout Inform rollout status :reqheader Content-Type: application/json :reqheader X-Access-Token: JWT-TOKEN **Example request**: .. tabs:: .. code-tab:: bash cURL curl --location --request POST 'https://vc-server/api/device/success/rollout' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: ' \ --data-raw '{ "mac": "your-device-mac", "firmware_version": "2.0" "rollout_id": "84" }' .. code-tab:: js var request = require('request'); var options = { 'method': 'POST', 'url': 'https://vc-server/api/device/success/rollout', 'headers': { 'Content-Type': 'application/json', 'X-Access-Token': '' }, body: JSON.stringify({"mac":"your-device-mac","firmware_version":"2.0","rollout_id":"84"}) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); .. code-tab:: python import requests url = "https://vc-server/api/device/success/rollout" payload = "{\n\t\"mac\": \"your-device-mac\",\n\t\"firmware_version\": \"2.0\",\n\t\"rollout_id\": \"84\"\n}" headers = { 'Content-Type': 'application/json', 'X-Access-Token': '' } response = requests.request("POST", url, headers=headers, data = payload) print(response.text.encode('utf8')) .. code-tab:: php setRequestUrl('https://vc-server/api/device/success/rollout'); $request->setRequestMethod('POST'); $body = new http\Message\Body; $body->append('{ "mac": "your-device-mac", "firmware_version": "2.0", "rollout_id": "84" }'); $request->setBody($body); $request->setOptions(array()); $request->setHeaders(array( 'Content-Type' => 'application/json', 'X-Access-Token': '' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); **Example response**: .. sourcecode:: json { "message": "Successfully inserted!" } .. sourcecode:: json { "message": "Existing Record" } :resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid