Tutorials ========= These tutorials show how to use the Data Store microservice. Tutorial 1: Using Data Store Sample app to exercise Intel® Edge Insights System Message Bus(ZMQ) and gRPC Request-Response interfaces ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data Store Sample App is an Web based interactive application used to exercise all the functionality of ZMQ/gRPC Request-Response Server with pre-loaded request with test data. Also gives a sample code of execution for req-resp server in ``python`` language. The Data Store Sample App communicates with the Data Store ZMQ Request-Response Server by default. If required to switch to communicate with the Data Store **gRPC** server instead, please ensure to change the value of **server_type** in `config.json `__ from **zmq** to **grpc**. .. code:: json "config": { "cert_type": ["zmq"], "logging": { "C_LOG_LEVEL": "INFO", "PY_LOG_LEVEL": "INFO" }, "server_type": "grpc" } For building the Data Store Sample App, run the below command: .. code:: sh mv local_env .env # Source the .env using the following command: set -a && source .env && set +a # Build the Data Store Sample App docker compose build For running the Data Store Sample App, run the below command: .. code:: sh # Source the .env using the following command: set -a && source .env && set +a # Launch the Data Store Sample App docker compose -f docker-compose.yml -f docker-compose-dev.override.yml up -d Once the Sample App is been deployed, it is accessible at http://localhost:9001/ Sample App consists of pre-loaded sample of both metadata, blob and custom request: 1. Pre-loaded requests are ``Write Meta``, ``Write Blob``, ``Write both``, ``Read Meta``, ``Read Blob``, ``Read both``, ``List Meta``, ``List Blob``, ``List both``, ``Delete Meta``, ``Delete Blob``, ``Delete both``,\ ``Clear Meta``, ``Clear Blob``, ``Clear both``, ``Update Meta``. Pre-loaded request contains the request test_topic (measurement/bucket name) filled with test data. 2. ``Custom Request`` for which user has to provide the request JSON Using the Sample App ^^^^^^^^^^^^^^^^^^^^ 1. On accessing the url, sample app open web based user interactive session which communicates with Data Store over ZMQ/gRPC Request-Response server. 2. For executing the ``Pre-Loaded`` samples, select one of the options from ``Write Meta``, ``Write Blob``, ``Write both``, ``Read Meta``, ``Read Blob``, ``Read both``, ``List Meta``, ``List Blob``, ``List both``, ``Delete Meta``, ``Delete Blob``, ``Delete both``, ``Clear Meta``, ``Clear Blob``, ``Clear both``, ``Update Meta`` using the radio button and click on ``Submit`` button 3. For executing ``Custom Request``, a. Select ``Custom Request`` radio button and click on ``Submit`` button b. Prepare the the request json based type of request, for request skeleton c. Enter the prepared request packet into ``Request`` text box and click on ``Submit`` button. 4. On submitting, it will open new web page where the request packet sent and response received from ``Data Store`` will be displayed with two options of ``Go Back`` or ``Exit`` Buttons 5. On clicking ``Go back``, it will lead to main screen where you can select an option from Pre-loaded samples/Custom Request or on clicking ``Exit``, it will terminate the current session. To restart the session, refresh the page on browser. .. **Note:** To Go back to the main menu from the ``Custom Request``, reload or refresh the Web Page in Browser For more details, please refer `Intel® Edge Insights System Message Bus and gRPC interfaces <#intel®-edge-insights-system-message-bus-and-grpc-interfaces>`__ Intel® Edge Insights System Message Bus and gRPC Request-Response Endpoints ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +---------------------------+------------------------------------------+ | Path | Description | +===========================+==========================================+ | `read <#read>`__ | Return Data from database based on | | | query/blob request. | +---------------------------+------------------------------------------+ | `write <#write>`__ | Write Data to database based on the | | | request. Returns code and err(if any). | +---------------------------+------------------------------------------+ | `update <#update>`__ | Update Data in database based on the | | | time field(Applicable only for | | | Metadata). Returns status code and | | | err(if any) | +---------------------------+------------------------------------------+ | `list <#list>`__ | List API returns the list of | | | measurement/table/bucket names in the | | | respective database based on request | +---------------------------+------------------------------------------+ | `clear <#clear>`__ | Clear API clears all the data and | | | measurement/table/bucket in the | | | respective database based on request | +---------------------------+------------------------------------------+ | `delete <#delete>`__ | Delete API Deletes all the data and | | | measurement/table/bucket in the | | | respective database based on request | +---------------------------+------------------------------------------+ read '''' Return Data from database based on query/blob request or err if any. Request .. code:: json { "command": "read", "payload": { "topic": "edge_video_analytics_results", "query": "select * from edge_video_analytics_results", "blob": { "key": "img_handle" } } } **Request Fields** - **command:** (Required/String) provide type of command for ZMQ/gRPC Req-Resp server. Supported commands: **read, write, update, list, delete**. - **payload:** (Required/JSON Object) - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **query:** (Optional/String) Should contain query for requesting data from Metadata Database (Can be empty if blob only request) - **blob:** (Optional/JSON Object) (Can be empty if meta only request) - **key:** (Required/String) Should contain Blob identifier(if single read request), Key from Metadata whose values will be used as blob identifier(if bulk read based on metadata response) .. **NOTE**: Either of one query/blob should be filled in case of Single read. Response .. code:: json { "statuscode": 0, "response": { "metadata": "[{\"img_handle\":\"test_handle\",\"encoding_type\":\"jpeg\",\"encoding_level\":251,\"annotation\":\"test_data\",\"time\":\"1685090211099234630\"}]", "blobdata": ["ssadgfsbdsbasbdsadbgsadfds==/Qa"] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Based on the request, if meta data is requested this will be filled. Will be Empty string if not requested for metadata/no data for given query - **blobdata:** (Array of bytearray) Based on the request, if meta data is requested this will be filled. Will be Bulk data only if requested for both. Will be Empty array if not requested for blob. - **err:** (String) Error Message in Detail. Will be Empty string if no error Example Request: Read - Meta only (Bulk Response based on query) .. code:: json { "command": "read", "payload": { "topic": "edge_video_analytics_results", "query": "select * from edge_video_analytics_results" } } Example Request: Read - Blob only (Single Read Request) .. code:: json { "command": "read", "payload": { "topic": "edge_video_analytics_results", "blob": { "key": "blob_identifier" } } } Example Request: Read - Both (Bulk Response based on query, and blob for each row) .. code:: json { "command": "read", "payload": { "topic": "edge_video_analytics_results", "query": "select * from edge_video_analytics_results", "blob": { "key": "img_handle" } } } write ''''' Write Data to database based on the request. Returns status code and err(if any) .. _request-1: Request .. code:: json { "command": "write", "payload": { "topic": "sample_topic", "metadata": { "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25 }, "blob": { "key": "sample_image", "data": ["bytearray of blob"] } } } **Request Fields** - **command:** (Required/String) provide type of command for ZMQ/gRPC Req-Resp server. Supported commands: **read, write, update, list, delete**. - **payload:** (Required/JSON Object) - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **metadata:** (Optional/JSON Object) Filled if meta data to be inserted. Should Contains the Key value pair of JSON meta data with Key as column name and values as column value. (Can be NULL if blob only request) - **blob:** (Optional/JSON Object) (Can be empty if meta only request) - **key:** (Required/String) Blob identifier to be stored in blob DB - **data:** (Required/Array of bytearray) Blob data of the corresponding blob identifier(key). Only 0th position will be considered. .. **NOTE**: Either of one metadata/blob should be filled in case of Single write. Data type of Columns should be maintained in case of meta data else, it will be created as new columns .. _response-1: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Will be empty string. - **blobdata:** (Array of bytearray) Will be empty array - **err:** (String) Error Message in Detail. Will be Empty string if no error Example Request: write - Meta only (Single Row write Request) .. code:: json { "command": "write", "payload": { "topic": "sample_topic", "metadata": { "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25 } } } Example Request: write - Blob only (Single Blob write Request) .. code:: json { "command": "write", "payload": { "topic": "sample_topic", "blob": { "key": "sample_image", "data": ["bytearray of blob"] } } } Example Request: write - Both (Single Meta & Blob write Request) .. code:: json { "command": "write", "payload": { "topic": "sample_topic", "metadata": { "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25 }, "blob": { "key": "sample_image", "data": ["bytearray of blob"] } } } update '''''' Update Data in database based on the time field(Applicable only for Metadata). Returns status code and err(if any) .. _request-2: Request .. code:: json { "command": "update", "payload": { "topic": "sample_topic", "metadata": [{ "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25, "time": "1685090211099234630" }] } } **Request Fields** - **command:** (Required/String) provide type of command for ZMQ/gRPC Req-Resp server. Supported commands: **read, write, update, list, delete**. - **payload:** (Required/JSON Object) - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **metadata:** (Required/JSON Object) Filled if meta data to be inserted. Should Contains the Key value pair of JSON meta data with Key as column name and values as column value. .. **NOTE**: Data type of Columns should be maintained in case of meta data else, it will be created as new columns. **Time should in string format.** .. _response-2: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Will be empty string. - **blobdata:** (Array of bytearray) Will be empty array - **err:** (String) Error Message in Detail. Will be Empty string if no error Example Request: update - Meta only (Single Meta Update Request) .. code:: json { "command": "update", "payload": { "topic": "sample_topic", "metadata": [{ "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25, "time": "1685090211099234630" }] } } list '''' List API returns the list of measurement/table/bucket names in the respective database based on request .. _request-3: Request .. code:: json { "command": "list", "payload": "both" } **Request Fields** - **command:** (Required/String) provide type of command for ZMQ/gRPC Req-Resp server. Supported commands: **read, write, update, list, delete**. - **payload:** (Required/String) Option to select which database to list the topic. Options are ``meta``, ``blob`` and ``both`` .. _response-3: Response .. code:: json { "statuscode": 0, "response": { "metadata": "[\"sample_topic1\",\"sample_topic2\"]", "blobdata": ["sample_topic1","sample_topic2"] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of string as String) List of measurement/table name of meta database - **blobdata:** (Array of string) List of bucket name of blob database - **err:** (String) Error Message in Detail. Will be Empty string if no error Example Request: list - Meta only .. code:: json { "command": "list", "payload": "meta" } Example Request: list - Blob only .. code:: json { "command": "list", "payload": "blob" } Example Request: list - Both .. code:: json { "command": "list", "payload": "both" } clear ''''' clear API clears all the data and measurement/table/bucket in the respective database based on request .. _request-4: Request .. code:: json { "command": "clear", "payload": { "dbType": "both", "topic": "edge_video_analytics_results" } } **Request Fields** - **command:** (Required/String) provide type of command for ZMQ/gRPC Req-Resp server. Supported commands: **read, write, update, list, delete**. - **payload:** (Required/JSON Object) - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **dbType:** (Required/String) Option to select which database to perform clear operation. Options are ``meta``, ``blob`` and ``both`` .. _response-4: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Based on the request, if meta data is requested this will be filled. Will be Empty string if not requested for metadata/no data for given query - **blobdata:** (Array of bytearray) Based on the request, if meta data is requested this will be filled. Will be Bulk data only if requested for both. Will be Empty array if not requested for blob. - **err:** (String) Error Message in Detail. Will be Empty string if no error .. **NOTE**: Deleting the blob data might send an error when EVAM ingestion is active. Example Request: clear - Meta only .. code:: json { "command": "clear", "payload": { "dbType": "meta", "topic": "edge_video_analytics_results" } } Example Request: clear - Blob only .. code:: json { "command": "clear", "payload": { "dbType": "blob", "topic": "edge_video_analytics_results" } } Example Request: clear - Both .. code:: json { "command": "clear", "payload": { "dbType": "both", "topic": "edge_video_analytics_results" } } delete '''''' Delete API Deletes all the data for selected measurement/table/bucket in the respective database based on requested time range. For meta/both data, timestamp should be in nano seconds and for blob data, timestamp should be in seconds .. _request-5: Request .. code:: json { "command": "delete", "payload": { "dbType": "both", "topic": "test_topic", "start": "1700560635226126767", "stop": "1700561235226127691", "blobIdentifier": "img_handle" } } **Request Fields** - **command:** (Required/String) provide type of command for ZMQ/gRPC Req-Resp server. Supported commands: **read, write, update, list, delete**. - **payload:** (Required/JSON Object) - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **dbType:** (Required/String) Option to select which database to perform delete operation. Options are ``meta``, ``blob`` and ``both`` - **start:** Timestamp from which the data should be deleted. For meta/both it should be nano seconds and for blob it should be seconds - **stop:** Timestamp to which the data should be deleted. For meta/both it should be nano seconds and for blob it should be seconds - **BlobIdentifier:** Should contain Blob identifier. Need to be filled only for both request (Optional) .. _response-5: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Based on the request, if meta data is requested this will be filled. Will be Empty string if not requested for metadata/no data for given query - **blobdata:** (Array of bytearray) Based on the request, if meta data is requested this will be filled. Will be Bulk data only if requested for both. Will be Empty array if not requested for blob. - **err:** (String) Error Message in Detail. Will be Empty string if no error .. **NOTE**: Deleting the blob data might send an error when EVAM ingestion is active. Example Request: delete - Meta only .. code:: json { "command": "delete", "payload": { "dbType": "meta", "topic": "test_topic", "start": "1700560635226126767", "stop": "1700561235226127691", "BlobIdentifier": "" } } Example Request: delete - Blob only .. code:: json { "command": "delete", "payload": { "dbType": "blob", "topic": "test_topic", "start": "1700471030", "stop": "1700483045", "BlobIdentifier": "" } } Example Request: delete - Both .. code:: json { "command": "delete", "payload": { "dbType": "both", "topic": "test_topic", "start": "1700560635226126767", "stop": "1700561235226127691", "BlobIdentifier": "img_handle" } } Status Codes ^^^^^^^^^^^^ =================================== =========== Description Status Code =================================== =========== Success 0 Fail 1 API Generic Failure 2 DB Handler API Failure 3 Factory Interface API Failure 4 JSON Packing/Unpacking Failure 5 Partial DB Execution Failed/Success 6 =================================== =========== Summary ^^^^^^^ In this tutorial, you learned how to query the databases over Intel® Edge Insights System Message Bus and gRPC interfaces Tutorial 2: Using Data Store Swagger documentation to exercise REST API interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The swagger documentation for REST APIs of Data Store would be available at ``http://localhost:8889/docs``. Please refer `REST API Interface <#rest-api-interface>`__ for more details. REST APIs Endpoints ^^^^^^^^^^^^^^^^^^^ +---------------------------+------------------------------------------+ | Path | Description | +===========================+==========================================+ | `/read <#read>`__ | Return Data from database based on | | | query/blob request. | +---------------------------+------------------------------------------+ | `/write <#write>`__ | Write Data to database based on the | | | request. Returns status code and err(if | | | any). | +---------------------------+------------------------------------------+ | `/update <#update>`__ | Update Data in database based on the | | | time field(Applicable only for | | | Metadata). Returns status code and | | | err(if any) | +---------------------------+------------------------------------------+ | `/list <#list>`__ | List API returns the list of | | | measurement/table/bucket names in the | | | respective database based on request | +---------------------------+------------------------------------------+ | `/clear <#clear>`__ | Clear API clears all the data and | | | measurement/table/bucket in the | | | respective database based on request | +---------------------------+------------------------------------------+ | `/delete <#delete>`__ | Delete API Deletes all the data and | | | measurement/table/bucket in the | | | respective database based on requested | | | time range. For meta/both data, | | | timestamp should be in nano seconds and | | | for blob data, timestamp should be in | | | seconds | +---------------------------+------------------------------------------+ .. _read-1: read '''' Return Data from database based on query/blob request or err if any. .. _request-6: Request .. code:: json { "topic": "edge_video_analytics_results", "query": "select * from edge_video_analytics_results", "blob": { "key": "img_handle" } } **Request Fields** - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **query:** (Optional/String) Should contain query for requesting data from Metadata Database (Can be empty if blob only request) - **blob:** (Optional/JSON Object) (Can be empty if meta only request) - **key:** (Required/String) Should contain Blob identifier(if single read request), Key from Metadata whose values will be used as blob identifier(if bulk read based on metadata response) .. **NOTE**: Either of one query/blob should be filled in case of Single read. .. _response-6: Response .. code:: json { "statuscode": 0, "response": { "metadata": "[{\"img_handle\":\"test_handle\",\"encoding_type\":\"jpeg\",\"encoding_level\":251,\"annotation\":\"test_data\",\"time\":\"1685090211099234630\"}]", "blobdata": ["ssadgfsbdsbasbdsadbgsadfds==/Qa"] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Based on the request, if meta data is requested this will be filled. Will be Empty string if not requested for metadata/no data for given query - **blobdata:** (Array of bytearray) Based on the request, if meta data is requested this will be filled. Will be Bulk data only if requested for both. Will be Empty array if not requested for blob. - **err:** (String) Error Message in Detail. Will be Empty string if no error .. _example-request-read---meta-only-bulk-response-based-on-query-1: Example Request: Read - Meta only (Bulk Response based on query) .. code:: json { "topic": "edge_video_analytics_results", "query": "select * from edge_video_analytics_results" } .. _example-request-read---blob-only-single-read-request-1: Example Request: Read - Blob only (Single Read Request) .. code:: json { "topic": "edge_video_analytics_results", "blob": { "key": "blob_identifier" } } .. _example-request-read---both-bulk-response-based-on-query-and-blob-for-each-row-1: Example Request: Read - Both (Bulk Response based on query, and blob for each row) .. code:: json { "topic": "edge_video_analytics_results", "query": "select * from edge_video_analytics_results", "blob": { "key": "img_handle" } } .. _write-1: write ''''' Write Data to database based on the request. Returns status code and err(if any) .. _request-7: Request .. code:: json { "topic": "sample_topic", "metadata": { "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25 }, "blob": { "key": "sample_image", "data": ["bytearray of blob"] } } **Request Fields** - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **metadata:** (Optional/JSON Object) Filled if meta data to be inserted. Should Contains the Key value pair of JSON meta data with Key as column name and values as column value. (Can be NULL if blob only request) - **blob:** (Optional/JSON Object) (Can be empty if meta only request) - **key:** (Required/String) Blob identifier to be stored in blob DB - **data:** (Required/Array of bytearray) Blob data of the corresponding blob identifier(key). Only 0th position will be considered. .. **NOTE**: Either of one metadata/blob should be filled in case of Single write. Data type of Columns should be maintained in case of meta data else, it will be created as new columns .. _response-7: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Will be empty string. - **blobdata:** (Array of bytearray) Will be empty array - **err:** (String) Error Message in Detail. Will be Empty string if no error .. _example-request-write---meta-only-single-row-write-request-1: Example Request: write - Meta only (Single Row write Request) .. code:: json { "topic": "sample_topic", "metadata": { "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25 } } .. _example-request-write---blob-only-single-blob-write-request-1: Example Request: write - Blob only (Single Blob write Request) .. code:: json { "topic": "sample_topic", "blob": { "key": "sample_image", "data": ["bytearray of blob"] } } .. _example-request-write---both-single-meta-blob-write-request-1: Example Request: write - Both (Single Meta & Blob write Request) .. code:: json { "topic": "sample_topic", "metadata": { "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25 }, "blob": { "key": "sample_image", "data": ["bytearray of blob"] } } .. _update-1: update '''''' Update Data in database based on the time field(Applicable only for Metadata). Returns status code and err(if any) .. _request-8: Request .. code:: json { "topic": "sample_topic", "metadata": [{ "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25, "time": "1685090211099234630" }] } **Request Fields** - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **metadata:** (Required/JSON Object) Filled if meta data to be inserted. Should Contains the Key value pair of JSON meta data with Key as column name and values as column value. .. **NOTE**: Data type of Columns should be maintained in case of meta data else, it will be created as new columns. **Time should in string format.** .. _response-8: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Will be empty string. - **blobdata:** (Array of bytearray) Will be empty array - **err:** (String) Error Message in Detail. Will be Empty string if no error .. _example-request-update---meta-only-single-meta-update-request-1: Example Request: update - Meta only (Single Meta Update Request) .. code:: json { "topic": "sample_topic", "metadata": { "img_handle": "c229634589", "encoding_type": "jpeg", "encoding_level": 25, "time": "1685090211099234630" } } .. _list-1: list '''' List API returns the list of measurement/table/bucket names in the respective database based on request .. _request-9: Request .. code:: json "both" **Request Fields** - **payload:** (Required/String) Option to select which database to list the topic. Options are ``meta``, ``blob`` and ``both`` .. _response-9: Response .. code:: json { "statuscode": 0, "response": { "metadata": "[\"sample_topic1\",\"sample_topic2\"]", "blobdata": ["sample_topic1","sample_topic2"] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of string as String) List of measurement/table name of meta database - **blobdata:** (Array of string) List of bucket name of blob database - **err:** (String) Error Message in Detail. Will be Empty string if no error .. _example-request-list---meta-only-1: Example Request: list - Meta only .. code:: json "meta" .. _example-request-list---blob-only-1: Example Request: list - Blob only .. code:: json "blob" .. _example-request-list---both-1: Example Request: list - Both .. code:: json "both" .. _clear-1: clear ''''' Clear API clears all the data and measurement/table/bucket in the respective database based on request .. _request-10: Request .. code:: json { "dbType": "both", "topic": "edge_video_analytics_results" } **Request Fields** - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **dbType:** (Required/String) Option to select which database to perform delete operation. Options are ``meta``, ``blob`` and ``both`` .. _response-10: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Based on the request, if meta data is requested this will be filled. Will be Empty string if not requested for metadata/no data for given query - **blobdata:** (Array of bytearray) Based on the request, if meta data is requested this will be filled. Will be Bulk data only if requested for both. Will be Empty array if not requested for blob. - **err:** (String) Error Message in Detail. Will be Empty string if no error .. **NOTE**: Deleting the blob data might send an error when EVAM ingestion is active. .. _example-request-clear---meta-only-1: Example Request: clear - Meta only .. code:: json { "dbType": "meta", "topic": "edge_video_analytics_results" } .. _example-request-clear---blob-only-1: Example Request: clear - Blob only .. code:: json { "dbType": "blob", "topic": "edge_video_analytics_results" } .. _example-request-clear---both-1: Example Request: clear - Both .. code:: json { "dbType": "both", "topic": "edge_video_analytics_results" } .. _delete-1: delete '''''' Delete API Deletes all the data and measurement/table/bucket in the respective database based on requested time range. For meta/both data, timestamp should be in nano seconds and for blob data, timestamp should be in seconds .. _request-11: Request .. code:: json { "dbType": "both", "topic": "test_topic", "start": "1700560635226126767", "stop": "1700561235226127691", "blobIdentifier": "img_handle" } **Request Fields** - **command:** (Required/String) provide type of command for ZMQ/gRPC Req-Resp server. Supported commands: **read, write, update, list, delete**. - **payload:** (Required/JSON Object) - **topic:** (Required/String) Should contain name of measurement/table/bucket on which operation to be performed - **dbType:** (Required/String) Option to select which database to perform delete operation. Options are ``meta``, ``blob`` and ``both`` - **start:** Timestamp from which the data should be deleted. For meta/both it should be nano seconds and for blob it should be seconds - **stop:** Timestamp to which the data should be deleted. For meta/both it should be nano seconds and for blob it should be seconds - **BlobIdentifier:** Should contain Blob identifier. Need to be filled only for both request (Optional) .. _response-11: Response .. code:: json { "statuscode": 0, "response": { "metadata": "", "blobdata": [] }, "err": "" } **Responses Fields** - **statuscode:** (Integer) Status Code of Request. Refer `Status Codes & Descriptions <#status-codes>`__ for details - **response:** (JSON Object) - **metadata:** (Array of JSON Object as String) Based on the request, if meta data is requested this will be filled. Will be Empty string if not requested for metadata/no data for given query - **blobdata:** (Array of bytearray) Based on the request, if meta data is requested this will be filled. Will be Bulk data only if requested for both. Will be Empty array if not requested for blob. - **err:** (String) Error Message in Detail. Will be Empty string if no error .. **NOTE**: Deleting the blob data might send an error when EVAM ingestion is active. .. _example-request-delete---meta-only-1: Example Request: delete - Meta only .. code:: json { "dbType": "meta", "topic": "test_topic", "start": "1700560635226126767", "stop": "1700561235226127691", "BlobIdentifier": "" } .. _example-request-delete---blob-only-1: Example Request: delete - Blob only .. code:: json { "dbType": "blob", "topic": "test_topic", "start": "1700471030", "stop": "1700483045", "BlobIdentifier": "" } .. _example-request-delete---both-1: Example Request: delete - Both .. code:: json { "dbType": "both", "topic": "test_topic", "start": "1700560635226126767", "stop": "1700561235226127691", "BlobIdentifier": "img_handle" } .. _status-codes-1: Status Codes ^^^^^^^^^^^^ =================================== =========== Description Status Code =================================== =========== Success 0 Fail 1 API Generic Failure 2 DB Handler API Failure 3 Factory Interface API Failure 4 JSON Packing/Unpacking Failure 5 Partial DB Execution Failed/Success 6 =================================== =========== .. _summary-1: Summary ^^^^^^^ In this tutorial, you learned how to query the databases over REST interface