RestDataExport¶
RestDataExport service subscribes to any topic from EIIMessageBus and starts publishing meta data via POST requests to any external HTTP servers. It has an internal HTTP server running to respond to any GET requests for a required frame from any HTTP clients.
IMPORTANT: RestDataExport service can subscribe classified results from both VideoAnalytics(video) or InfluxDBConnector(time-series) use cases. Please ensure the required service to subscribe from is mentioned in the Subscribers configuration in config.json.
The following figure illustrates the block diagram for the component.

RestExport POST Request Pipeline¶

RestExport Get Request Pipeline¶

RestExport APIs¶
The RestExport API source code is found in [WORK_DIR]/rest_export/RestExport.go. It is responsible for reading the RestExport configuration and managing the lifecycle of the RestExport pipeline.

RestExport POST Request API¶
Sample POST request API:
POST /metadata
Example request
POST /metadata HTTP/1.1
Host: localhost:8082
Accept: application/json
Example response:
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
[{
"channel":3,
"topic":"camera1_stream_results",
"encoding_level":100,
"defects": "[]",
"encoding_type":"jpg",
"height":1200,
"width":1920,
"img_handle": "b7aa16b8",
"user_data":1
}]
Request Headers
Accept - application/json, plaintext
Authorization - TLS based authentication
Response Headers
Content-Type - application/json, plaintext
Status Codes
200 OK - no error
RestExport GET Request API¶
Sample GET request API:
GET /image
Example request:
GET /image HTTP/1.1
Host: localhost:8084
Accept: plaintext
Example response:
HTTP/1.1 200 OK
Vary: Accept
Content-Type: plaintext
[
"01a3b9e4"
]
Request Headers
Accept - plaintext
Authorization - TLS based authentication
Response Headers
Content-Type - plaintext
Status Codes
200 OK - no error
Configuration¶
For more details on Etcd secrets and messagebus endpoint configuration, visit Etcd_Secrets_Configuration.md and MessageBus Configuration respectively.
Pre-requisites¶
If using the HttpTestServer, make sure that the server’s IP has been added to ‘no_proxy/NO_PROXY’ vars in:
/etc/environment (Needs restart/relogin)
./docker-compose.yml (Needs to re-run the ‘builder’ step)
environment: AppName: "RestDataExport" DEV_MODE: ${DEV_MODE} no_proxy: ${ETCD_HOST}, <IP of HttpTestServer>
Run the below one-time command to install python etcd3
$ pip3 install -r requirements.txt
Ensure EII is provisioned and built.
Ensure the pre-requisites for starting the TestServer application are enabled by following README.md.
RestDataExport is pre-equipped with a python tool to insert data into etcd which can be used to insert the required HttpServer ca cert into the config of RestDataExport before running it. The below commands should be run for running the tool which is a pre-requisite before starting RestDataExport:
$ set -a && \ source ../build/.env && \ set +a # Required if running in PROD mode only $ sudo chmod -R 777 ../build/provision/Certificates/ $ python3 etcd_update.py --http_cert <path to ca cert of HttpServer> --ca_cert <path to etcd client ca cert> --cert <path to etcd client cert> --key <path to etcd client key> --hostname <IP address of host system> --port <ETCD PORT> Eg: # Required if running in PROD mode $ python3 etcd_update.py --http_cert "../tools/HttpTestServer/certificates/ca_cert.pem" --ca_cert "../build/provision/Certificates/ca/ca_certificate.pem" --cert "../build/provision/Certificates/root/root_client_certificate.pem" --key "../build/provision/Certificates/root/root_client_key.pem" --hostname <IP address of host system> --port <ETCD PORT> # Required if running with k8s helm in PROD mode $ python3 etcd_update.py --http_cert "../tools/HttpTestServer/certificates/ca_cert.pem" --ca_cert "../build/helm-eii/eii-provision/Certificates/ca/ca_certificate.pem" --cert "../build/helm-eii/eii-provision/Certificates/root/root_client_certificate.pem" --key "../build/helm-eii/eii-provision/Certificates/root/root_client_key.pem" --hostname <IP address of ETCD host system> --port 32379 # Required if running in DEV mode $ python3 etcd_update.py
Start the TestServer application by following README.md.
Ensure ImageStore application is running by following README.md
Enure the topics you subscribe to are also added in the config with HttpServer endpoint specified
Update the config.json file with the following settings:
{ "camera1_stream_results": "http://IP Address of Test Server:8082", "point_classifier_results": "http://IP Address of Test Server:8082", "http_server_ca": "/opt/intel/eii/cert.pem", "rest_export_server_host": "0.0.0.0", "rest_export_server_port": "8087" }
Service bring up¶
Please go through the below sections to have RestDataExport service built and launch it:
FAQs¶
Following are some of the FAQs of RestDataExport
For setting environment proxy settings¶
sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf (update host-ip)
sudo vi /etc/systemd/system/docker.service.d/https-proxy.conf (update hot-ip)
env | grep proxy
export no_proxy=$no_proxy,
sudo vi .docker/config.json (update host-ip in no_proxy)
sudo systemctl daemon-reload
sudo systemctl restart docker