Add the tasks cancel route to cancel tasks

This commit is contained in:
Kerollmops 2022-10-18 14:48:40 +02:00 committed by Clément Renault
parent 01ed1fb128
commit 973e2f71eb
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
6 changed files with 73 additions and 8 deletions

View file

@ -150,6 +150,7 @@ pub enum Code {
DumpNotFound,
TaskNotFound,
TaskDeletionWithEmptyQuery,
TaskCancelationWithEmptyQuery,
PayloadTooLarge,
RetrieveDocument,
SearchDocuments,
@ -237,9 +238,11 @@ impl Code {
ErrCode::authentication("missing_authorization_header", StatusCode::UNAUTHORIZED)
}
TaskNotFound => ErrCode::invalid("task_not_found", StatusCode::NOT_FOUND),
// TODO: Lo: find the proper error name & message for this one
TaskDeletionWithEmptyQuery => {
ErrCode::invalid("task_deletion_with_empty_query", StatusCode::BAD_REQUEST)
ErrCode::invalid("missing_filters", StatusCode::BAD_REQUEST)
}
TaskCancelationWithEmptyQuery => {
ErrCode::invalid("missing_filters", StatusCode::BAD_REQUEST)
}
DumpNotFound => ErrCode::invalid("dump_not_found", StatusCode::NOT_FOUND),
NoSpaceLeftOnDevice => {

View file

@ -224,6 +224,8 @@ pub enum Action {
IndexesDelete,
#[serde(rename = "tasks.*")]
TasksAll,
#[serde(rename = "tasks.cancel")]
TasksCancel,
#[serde(rename = "tasks.delete")]
TasksDelete,
#[serde(rename = "tasks.get")]
@ -274,6 +276,8 @@ impl Action {
INDEXES_UPDATE => Some(Self::IndexesUpdate),
INDEXES_DELETE => Some(Self::IndexesDelete),
TASKS_ALL => Some(Self::TasksAll),
TASKS_CANCEL => Some(Self::TasksCancel),
TASKS_DELETE => Some(Self::TasksDelete),
TASKS_GET => Some(Self::TasksGet),
SETTINGS_ALL => Some(Self::SettingsAll),
SETTINGS_GET => Some(Self::SettingsGet),
@ -313,6 +317,7 @@ pub mod actions {
pub const INDEXES_UPDATE: u8 = IndexesUpdate.repr();
pub const INDEXES_DELETE: u8 = IndexesDelete.repr();
pub const TASKS_ALL: u8 = TasksAll.repr();
pub const TASKS_CANCEL: u8 = TasksCancel.repr();
pub const TASKS_DELETE: u8 = TasksDelete.repr();
pub const TASKS_GET: u8 = TasksGet.repr();
pub const SETTINGS_ALL: u8 = SettingsAll.repr();