Skip to content

REST Server

CVEDIA-RT provides a REST server that allows interfacing with the system remotely.

Enabling REST Server

CVEDIA-RT Rest Server can be configured in the global.config system-wide configuration file. Its IP address and port can also be defined there.

Postman collection

CVEDIA-RT provides a postman collection to easily understand the API and test it.

The postman_collection.json file is included within the Linux release. It can also be downloaded here.

If you're not familiar with postman, you can set it up like this:

  1. Download postman from postman's website
  2. Download CVEDIA-RT's postman collection here
  3. Within postman, click Import then select CVEDIA-RT's postman_collection.json
  4. Within postman, go in CVEDIA-RT collection -> Variables tab -> set Current Value of SERVER_URL to where you're running CVEDIA-RT API, then click Save at the top.

API Endpoints

GET /api/instance/get

If no parameters are given, all instances are returned

Request uri parameters

  • instance_name : Instance name to get information from (Optional)
  • solution : Parent Solution from Instance (Optional)

Returns

Json with instance list and state

[
  {
    "instance_name": "Demo",
    "solution": "Base Demo",
    "state": 1
  }
]

Instance State Values:

  • INSTANCE_NONE = 0,
  • INSTANCE_STOPPED = 1,
  • INSTANCE_STARTING = 2,
  • INSTANCE_PAUSED = 3,
  • INSTANCE_RUNNING = 4,
  • INSTANCE_FAIL = 5

Example

http://127.0.0.1:8080/api/instance/get

http://127.0.0.1:8080/api/instance/get?instance_name=thermal_areas

http://127.0.0.1:8080/api/instance/get?solution=perimeter-security

http://127.0.0.1:8080/api/instance/get?solution=perimeter-security&instance_name=thermal_areas

GET /api/solution/reload

Update Solutions and Instances list from the disk, it there is a change in the disk files or json config, this should be called to refresh the list. WARNING: This should be called when no Instance is running, as it could corrupt running Instances state.

Example

http://127.0.0.1:8080/api/solution/reload

GET /api/instance/reload

Update Solutions and Instances list from the disk, it there is a change in the disk files or json config done, this should be called to refresh the list. WARNING: This should be called when no Instance is running, as it could corrupt running Instances state.

Example

http://127.0.0.1:8080/api/instance/reload

GET /api/solution/get

If no parameters are given, all solutions are returned

Request uri parameters

  • solution : Solution name to get (Optional)

Example

http://127.0.0.1:8080/api/solution/get

http://127.0.0.1:8080/api/solution/get?solution=perimeter-security

POST /api/instance/start

Start an existing Instance

Request Body

  • instance_name : Instance name to start
  • solution : Parent Solution from Instance

POST /api/instance/stop

Stop an existing Instance

Request Body

  • instance_name : Instance name to stop
  • solution : Parent Solution from Instance

POST /api/instance/add

Add a new Instance, can be based on existing one

Request Body

  • instance_name : Instance name to add
  • solution : Parent Solution from Instance
  • base_on_instance : Instance to base on (Optional)

POST /api/instance/delete

Delete an existing Instance

Request Body

  • instance_name : Instance name to stop
  • solution : Parent Solution from Instance

GET /api/instance/get_state

Get an Instance State dictionary

Request uri parameters

  • instance_name : Instance name
  • solution : Parent Solution from Instance
  • path : State Dictionary Path to get data from
  • runtime_vars (Optional Default: false) : Get also runtime variables from State Dictionary (Can return large sized data with base64 encoded images)

POST /api/instance/set_state

Set the Instance State dictionary on a given path

Request Body

  • instance_name : Instance name
  • solution : Parent Solution from Instance
  • path : State Dictionary Path to set data
  • value : Json valid data to set on State Dictionary Path

POST /api/instance/save_state

Save the Instance State dictionary to disk

Request Body

  • instance_name : Instance name
  • solution : Parent Solution from Instance

GET /api/instance/get_zones

Request uri parameters

  • instance_name : Instance name to get zones from
  • solution : Parent Solution from Instance

Example

http://127.0.0.1:8080/api/instance/get_zones?solution=perimeter-security&instance_name=thermal_areas

POST /api/instance/add_zone

Request Body

  • instance_name : Instance name to add zones to (Required)
  • solution : Parent Solution from Instance (Required)
  • shape : Zone shape. Format [[x1,y1],[x2,y2],...] (Required)
  • color : Zone color. Format [r,g,b,a] (Optional, Default: [0,0,0,0])
  • name : Zone Name. String Format (Optional, Default: "New Zone")
  • zoneid : Zone ID. Must be unique. Used for deletion. (Optional, Default: Random GUID)
  • type : Zone Type. Must be "Occupancy" or "Mask". String Format (Optional, Default: "Occupancy")

POST /api/instance/delete_zone

Request Body

  • instance_name : Instance name to remove zones from
  • solution : Parent Solution from Instance
  • zoneid : Zone ID to delete