Создание отчёта
Запрос
Тип | Метод |
---|---|
POST |
/reports/create |
Описание: При выполнении запроса будет создан отчет. Объекты связанных сущностей игнорируются в теле запроса. Метод изменяет поле task_id
указанного отчета.
Пример запроса
POST
http://127.0.0.1/cruddy/v2/reports/create
Тело запроса: модель ReportCreate.
Пример тела запроса
{
"name": "string",
"config": {
"pages": [
[
{}
]
]
},
"settings": {
"general": {
"period": [
"2019-08-24T14:15:22Z"
],
"name_mask": "string"
},
"header": {
"show": true,
"text": "string",
"show_on_all_pages": true,
"color": "string",
"text_align": "right",
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAA...",
"fit": "fit",
"image_align": "string"
},
"footer": {
"show": true,
"show_on_first_page": true,
"text": "string",
"color": "string",
"show_date": true,
"show_page_number": true,
"text_align": "right",
"date_align": "string",
"page_number_align": "string",
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAA...",
"fit": "fit",
"image_align": "string"
},
"style": {
"font": "OpenSans-ExtraBoldItalic"
}
},
"is_system": false,
"dashboard_id": "6904cee6-5a01-4acf-92d9-7e185cd226de",
"category_id": "8de4c9fd-61a4-4c0b-bf88-0ed3a0fe3fa2"
}
Успешный ответ
Статус код: 201
– успешное добавление.
Формат: JSON
Тело ответа: модель отчета.
Пример ответа
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"created_at": "2023-12-20T00:00:01.652259Z",
"updated_at": "2023-12-20T00:00:01.652259Z",
"name": "string",
"config": {
"pages": [
[
{}
]
]
},
"settings": {
"general": {
"period": [
"2019-08-24T14:15:22Z"
],
"name_mask": "string"
},
"header": {
"show": true,
"text": "string",
"show_on_all_pages": true,
"color": "string",
"text_align": "right",
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAA...",
"fit": "fit",
"image_align": "string"
},
"footer": {
"show": true,
"show_on_first_page": true,
"text": "string",
"color": "string",
"show_date": true,
"show_page_number": true,
"text_align": "right",
"date_align": "string",
"page_number_align": "string",
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAA...",
"fit": "fit",
"image_align": "string"
},
"style": {
"font": "OpenSans-ExtraBoldItalic"
}
},
"is_system": false,
"category": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"created_at": "2023-12-20T00:00:01.652259Z",
"updated_at": "2023-12-20T00:00:01.652259Z",
"name": "string",
"parent_id": "string"
},
"dashboard": {
"id": "uuid",
"created_at": "2023-12-20T00:00:01.652259Z",
"updated_at": "2023-12-20T00:00:01.652259Z",
"name": "string",
"config": {
"grid": [
{}
],
"period": [
"now-1",
"now"
]
},
"owner": {
"id": "uuid",
"email": "string",
"first_name": "string",
"last_name": "string",
"username": "string"
},
"users": [
{
"id": "uuid",
"email": "string",
"first_name": "string",
"last_name": "string",
"username": "string"
}
],
"user_ids": [
"uuid"
],
"groups": [
{
"id": "uuid",
"name": "string",
"parent_group": "string",
"realm_id": "string",
"email": "string",
"phone_number": "string",
"leader_id": "string",
"accept_risk": true,
"visible_scan_schedules": true,
"stop_scans": true,
"edited_by": "string",
"user_ids": [
"uuid"
]
}
],
"group_ids": [
"uuid"
],
"widgets": [
{
"id": "uuid",
"created_at": "2023-12-20T00:00:01.652259Z",
"updated_at": "2023-12-20T00:00:01.652259Z",
"name": "string",
"config": {
"type": "string",
"settings": {
"kind": "histogram",
"base": {
"name": "Гистрограмма",
"showHeading": true,
"description": "string"
},
"legend": {
"placement": "string",
"show": true
},
"settings": {
"type": "bar",
"lineStyle": "linear",
"showDots": true,
"stack": true,
"theme": "string"
},
"mappings": {
"xAxis": {
"field": "string",
"customRange": true,
"customRangeValues": [
"string"
],
"useUnknownValues": true
},
"yAxis": {
"field": "string",
"groupingField": "string"
},
"normalizationStrategy": "fix"
}
},
"series": [
{
"name": "string",
"mode": "string",
"source": "string",
"period": [
"now-1",
"now"
],
"sql": "string",
"query": {
"dataset": "string",
"distinct": true,
"fields": [
{
"field": "string",
"alias": "string",
"format": "string",
"aggregation": {
"func": "string",
"distinct": true,
"args": [
"string"
]
}
}
],
"filters": [
{
"field": "string",
"negation": false,
"operator": "is",
"value": "string"
}
],
"group_by": [
"string"
],
"limit": 20,
"offset": 0,
"order_by": [
{
"direction": "asc",
"field": "string"
}
],
"interval": "1y"
}
}
]
},
"settings": {
"settings": {
"kind": "histogram",
"base": {
"name": "Гистрограмма",
"showHeading": true,
"description": "string"
},
"legend": {
"placement": "string",
"show": true
},
"settings": {
"type": "bar",
"showDots": true,
"text": "string",
"image": "string",
"fit": "string"
},
"mappings": {
"xAxis": {
"field": "string",
"customRange": true,
"customRangeValues": [
"string"
]
},
"yAxis": {
"field": "string"
},
"fields": [
{
"label": "string",
"key": "string"
}
],
"field": "string",
"dataSeries": "string"
}
},
"period": [
"now-1",
"now"
],
"series": [
{
"name": "string",
"mode": "string",
"source": "string",
"period": [
"now-1",
"now"
],
"sql": "string",
"query": {
"dataset": "string",
"distinct": true,
"fields": [
{
"field": "string",
"alias": "string",
"format": "string",
"aggregation": {
"func": "string",
"distinct": true,
"args": [
"string"
]
}
}
],
"filters": [
{
"field": "string",
"negation": false,
"operator": "is",
"value": "string"
}
],
"group_by": [
"string"
],
"limit": 20,
"offset": 0,
"order_by": [
{
"direction": "asc",
"field": "string"
}
],
"interval": "1y"
}
}
]
},
"dashboard_id": "uuid"
}
]
},
"owner": {
"id": "uuid",
"email": "string",
"first_name": "string",
"last_name": "string",
"username": "string"
},
"users": [
{
"id": "uuid",
"email": "string",
"first_name": "string",
"last_name": "string",
"username": "string"
}
],
"groups": [
{
"id": "uuid",
"name": "string",
"parent_group": "string",
"realm_id": "string",
"email": "string",
"phone_number": "string",
"leader_id": "string",
"accept_risk": true,
"visible_scan_schedules": true,
"stop_scans": true,
"edited_by": "string",
"user_ids": [
"uuid"
]
}
],
"task": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"created_at": "2023-12-20T00:00:01.652259Z",
"updated_at": "2023-12-20T00:00:01.652259Z",
"interval": "* 0 1 1 1",
"instance": "868cf2e9-bd6d-4bac-96ba-2b08120d8cf9"
}
}
Другие возможные ответы
Код | Ответ | Описание |
---|---|---|
400 |
1. Bad Request 2. missing uid header 3. Pgr-User-Id should be uuid format 4. config validation: … 5. name should not be empty |
1. Неверный тип параметра запроса, либо отсутствует обязательный параметр 2. Не передан заголовок Pgr-User-ID 3. Недопустимый формат Pgr-User-ID 4. Ошибка в структуре поля config 5. Поле name не может быть пустым |
409 |
Bad Request |
Попытка создать отчёт с существующим именем |
500 |
Internal Server Error |
Другие ошибки при удалении объектов |
Примечание: Текст ошибки не фиксированный, может изменяться в зависимости от фактического ответа получателя запроса.
Пример ответа
Код 400
{
"error": "Bad Request",
"error_code": 400
}
Код 409
{
"error": "Bad Request",
"error_code": 409,
"extra": {
"fields": [
"name"
]
}
}
Код 500
{
"error": "Internal Server Error",
"error_code": 500
}