Skip to content

Commit

Permalink
#18 WIP: start query API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Aug 31, 2021
1 parent 5571f57 commit c5d0d3f
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/thehive/api/.pages
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
nav:
- index.md
- 'search'
- 'organisation'
- 'user'
- 'custom-field'
Expand Down
5 changes: 5 additions & 0 deletions docs/thehive/api/search/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
nav:
- query.md
- filters.md
- sorting.md
- pagination.md
Empty file.
Empty file.
120 changes: 120 additions & 0 deletions docs/thehive/api/search/query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Query API

## Overview

The Query API is the API used to search for objects with filtering and sorting capabilities. It's an API introduced by TheHive 4 and is optimized for the the new data model.

TheHive comes with a list of predefined search *Queries* like:

- `listOrganisation`
- `listUser`
- `listAlert`
- `listCase`

## Query

```plain
POST /api/v0/query
```

## Request Body

The Query API request body should be an array of *operations* of different types:

- Selection: *Required*
- list of objects
- object by identifier
- Filtering: *optional*
- Sorting: *optional*
- Pagination: *optional*
- Formatting: *optional*

!!! Examples

=== "Simple List"
```json
{
"query": [
{
"_name": "listOrganisation"
}
]
}
```
=== "List with filters"
List organisations called *admin*
```json
{
"query": [
{
"_name": "listOrganisation"
},
{
"_like": {
"_field": "name",
"_value": "admin"
},
"_name": "filter"
}
]
}
```
=== "List with filters and sort"
List organisations called *admin*, sorted by ascendant `updatedAt` value
```json
{
"query": [
{
"_name": "listOrganisation"
},
{
"_like": {
"_field": "name",
"_value": "admin"
},
"_name": "filter"
},
{
"_fields": [
{
"updatedAt": "asc"
}
],
"_name": "sort"
}
]
}
```
=== "List with pagination"
List organisations called *admin*, sorted by ascendant `updatedAt` value, paginated to display the first 15 items
```json
{
"query": [
{
"_name": "listOrganisation"
},
{
"_like": {
"_field": "name",
"_value": "admin"
},
"_name": "filter"
},
{
"_fields": [
{
"updatedAt": "asc"
}
],
"_name": "sort"
},
{
"_name": "page",
"from": 0,
"to": 15
}
]
}
```


Empty file.

0 comments on commit c5d0d3f

Please sign in to comment.