Version Controller APIs¶
Dieser Abschnitt zeigt die Rest-API-Endpunkte von Version Controller.
Inhaltsübersicht
Register Device¶
- POST /api/device/register¶
Register a device.
- Request Headers
Content-Type – application/json
X-Access-Token – JWT-TOKEN
Example request:
$ curl --location --request POST 'https://vc-server/api/device/register' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: <JWT-TOKEN>' \ --data-raw '{ "mac": "your-device-mac", "firmware_version": "1.0", "name": "device-name", }'
var request = require('request'); var options = { 'method': 'POST', 'url': 'https://vc-server/api/device/register', 'headers': { 'Content-Type': 'application/json', 'X-Access-Token': '<JWT-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); });
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': '<JWT-TOKEN>' } response = requests.request("POST", url, headers=headers, data = payload) print(response.text.encode('utf8'))
<?php $client = new http\Client; $request = new http\Client\Request; $request->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': '<JWT-TOKEN>' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();
Example response:
{ "message": "Device inserted!" }
{ "message": "Device exists!" }
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – No error
404 Not Found – Not Found
401 Unauthorized – JWT is not valid
Delete Device¶
- DELETE /api/device/¶
Delete a device.
- Request Headers
Content-Type – application/json
X-Access-Token – JWT-TOKEN
Example request:
$ curl --location --request DELETE 'https://vc-server/api/device/' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: <JWT-TOKEN>' \ --data-raw '{ "mac": "your-device-mac", }'
Example response:
{ "message": "Device deleted!" }
{ "message": "Device does't exist!" }
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – No error
404 Not Found – Not Found
401 Unauthorized – JWT is not valid
Get Device¶
- GET /api/device/:mac¶
Get a device.
- Request Headers
Content-Type – application/json
X-Access-Token – JWT-TOKEN
Example request:
$ curl --location --request GET 'https://vc-server/api/device/<device-mac>' \ --header 'X-Access-Token: <JWT-TOKEN>'
Example response:
{ "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" }
{ "message": "Device does't exist!" }
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – No error
404 Not Found – Not Found
401 Unauthorized – JWT is not valid
Get All Devices¶
- GET /api/device/¶
Get all devices.
- Request Headers
Content-Type – application/json
X-Access-Token – JWT-TOKEN
Example request:
$ curl --location --request GET 'https://vc-server/api/device/' \ --header 'X-Access-Token: <JWT-TOKEN>'
Example response:
[ { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" }, { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" } ]
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – No error
404 Not Found – Not Found
401 Unauthorized – JWT is not valid
Get Report¶
- 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:
$ curl --location --request GET 'https://vc-server/api/report/<json/xml/pdf>' \ --header 'X-Access-Token: <JWT-TOKEN>'
Example response:
[ { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" }, { "mac": "device-mac", "name": "device-name", "firmware-version": "device-firmware-version" } ]
<?xml version="1.0" encoding="UTF-8"?> <root> <element> <firmware-version>device-firmware-version</firmware-version> <mac>device-mac</mac> <name>device-name</name> </element> <element> <firmware-version>device-firmware-version</firmware-version> <mac>device-mac</mac> <name>device-name</name> </element> </root>
:resheader Content-Type: application/json :statuscode 200: No error :statuscode 404: Not Found :statuscode 401: JWT is not valid
Next Rollout¶
- POST /api/device/next/rollout¶
Check next rollout
- reqheader Content-Type
application/json
- reqheader X-Access-Token
JWT-TOKEN
Example request:
curl --location --request POST 'https://vc-server/api/device/next/rollout' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: <JWT-TOKEN>' \ --data-raw '{ "mac": "your-device-mac", "firmware_version": "1.0" }'
var request = require('request'); var options = { 'method': 'POST', 'url': 'https://vc-server/api/device/next/rollout', 'headers': { 'Content-Type': 'application/json', 'X-Access-Token': '<JWT-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); });
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': '<JWT-TOKEN>' } response = requests.request("POST", url, headers=headers, data = payload) print(response.text.encode('utf8'))
<?php $client = new http\Client; $request = new http\Client\Request; $request->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': '<JWT-TOKEN>' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();
Example response:
{ "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:
{}
- resheader Content-Type
application/json
- statuscode 200
No error
- statuscode 404
Not Found
- statuscode 401
JWT is not valid
Rollout Success¶
- POST /api/device/success/rollout¶
Inform rollout status
- Request Headers
Content-Type – application/json
X-Access-Token – JWT-TOKEN
Example request:
curl --location --request POST 'https://vc-server/api/device/success/rollout' \ --header 'Content-Type: application/json' \ --header 'X-Access-Token: <JWT-TOKEN>' \ --data-raw '{ "mac": "your-device-mac", "firmware_version": "2.0" "rollout_id": "84" }'
var request = require('request'); var options = { 'method': 'POST', 'url': 'https://vc-server/api/device/success/rollout', 'headers': { 'Content-Type': 'application/json', 'X-Access-Token': '<JWT-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); });
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': '<JWT-TOKEN>' } response = requests.request("POST", url, headers=headers, data = payload) print(response.text.encode('utf8'))
<?php $client = new http\Client; $request = new http\Client\Request; $request->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': '<JWT-TOKEN>' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();
Example response:
{ "message": "Successfully inserted!" }
{ "message": "Existing Record" }
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – No error
404 Not Found – Not Found
401 Unauthorized – JWT is not valid