From 24d5f0ba14c31feca37e3632e762683610dd5421 Mon Sep 17 00:00:00 2001 From: itsnotapt <3096198+itsnotapt@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:16:28 +1100 Subject: [PATCH 1/2] Refactoring of the TIM api --- docs/api.md | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 docs/api.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..abfd0df --- /dev/null +++ b/docs/api.md @@ -0,0 +1,219 @@ +# REST API + +## Query + +### Execute a query + +```text +POST /query-execute +``` + +**Parameters:** + +* `connection_id` string +* `data` dictionary + +**Example request (Kusto):** + +```json +{ + "connection_id": "c69e4539-5e13-4b73-84f3-9662fb4ee142", + "data": { + "cluster": "https://help.kusto.windows.net", + "database": "Samples", + "query": "StormEvents | take 1", + "parameters": { + "key": "value" + } + } +} +``` + +**Example request (Splunk):** + +```json +{ + "connection_id": "c0aec099-ec07-45a4-86bd-b4e9fb26d708", + "data": { + "": "", + } +} +``` + +**Response `202`:** + +```json +{ + "query_id": "bee731fd-20be-4d06-bfa5-d8d41ab8647a" +} +``` + +### Retrieve query result + +```text +GET /query-execute/:query_id +``` + +**Parameters:** + +* `limit` int +* `page` int + +**Response:** + +```json +{ + "data": [ + { + "key": "value" + }, + { + "key": "value" + } + ] +} +``` + +### List all labels for query result + +```text +POST /queries/:query_id/labels +``` + +**Parameters:** + +* `since` timestamp +* `limit` int +* `page` int + +**Response:** + +```json +[ + { + "test": "TEST" + } +] +``` + +### Auto-tag query result + +Apply tags to a query result using the given auto-tag group. + +```text +POST /queries/:query_id/autotag/:group_id +``` + +**Parameters:** + +No parameters. + +**Response:** + +Alternate1: + +```json +[ + [], + ["tag1", "tag2"], + [] +] +``` + +Alternate2: + +```json +{ + "1": ["tag1", "tag2"] +} +``` + +Alternate3: + +```json +[ + { + "row": 1, + "tags": ["tag1", "tag2"] + } +] +``` + +## Labels + +### List all recent labels + +```text +GET /labels +``` + +**Parameters:** + +* `since` timestamp +* `limit` int +* `page` int + +**Response:** + +```json +[ + { + "test": "TEST" + } +] +``` + +### Retrieve label + +```text +GET /labels/:event_id +``` + +**Parameters:** + +No parameters. + +**Response:** + +```json +{ + "test": "TEST" +} +``` + +### Create label + +```text +POST /labels +``` + +**Parameters:** + +* `event_id` string +* `label` string + +**Response:** + +```json +{ + "test": "TEST" +} +``` + +### Delete label + +```text +DELETE /labels/:event_id +``` + +**Parameters:** + +No parameters. + +**Response:** + +```json +{ + "test": "TEST" +} +``` From 2035b542a81905210b2263da2ad5d44d238a1b7a Mon Sep 17 00:00:00 2001 From: itsnotapt <3096198+itsnotapt@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:47:33 +1100 Subject: [PATCH 2/2] Update api.md --- docs/api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index abfd0df..90e7056 100644 --- a/docs/api.md +++ b/docs/api.md @@ -5,7 +5,7 @@ ### Execute a query ```text -POST /query-execute +POST /queries/execute ``` **Parameters:** @@ -51,7 +51,7 @@ POST /query-execute ### Retrieve query result ```text -GET /query-execute/:query_id +GET /queries/:query_id/result ``` **Parameters:** @@ -77,7 +77,7 @@ GET /query-execute/:query_id ### List all labels for query result ```text -POST /queries/:query_id/labels +GET /queries/:query_id/labels ``` **Parameters:** @@ -98,7 +98,7 @@ POST /queries/:query_id/labels ### Auto-tag query result -Apply tags to a query result using the given auto-tag group. +Retrieve tags for a query result using the given auto-tag group. ```text POST /queries/:query_id/autotag/:group_id