API
Encapsulates the response data for the jobs router.
CreateJobResponse
Bases: BaseModel
Encapsulates the response for a create jobs API call
Source code in src/mmisp/worker/api/response_schemas.py
42 43 44 45 46 47 48 49 50 |
|
job_id = None
class-attribute
instance-attribute
The id of the created job
success
instance-attribute
The API call was successful or not
DeleteJobResponse
Bases: BaseModel
Encapsulates the response for a remove jobs API call
Source code in src/mmisp/worker/api/response_schemas.py
53 54 55 56 57 58 59 |
|
success
instance-attribute
The API call was successful or not
ExceptionResponse
Bases: BaseModel
Encapsulates the response for a jobs where an exception was raised
Source code in src/mmisp/worker/api/response_schemas.py
33 34 35 36 37 38 39 |
|
message
instance-attribute
A costume message which describes the error that occurred
JobStatusEnum
Bases: StrEnum
Encapsulates the status of a Job
Source code in src/mmisp/worker/api/response_schemas.py
10 11 12 13 14 15 16 17 18 19 |
|
JobStatusResponse
Bases: BaseModel
Encapsulates the response for a jobs status API call
Source code in src/mmisp/worker/api/response_schemas.py
22 23 24 25 26 27 28 29 30 |
|
message
instance-attribute
A costume message which describes the success of getting the job status
status
instance-attribute
The status of the job
StartStopWorkerResponse
Bases: BaseModel
Represents the API response of starting and stopping a worker
Source code in src/mmisp/worker/api/response_schemas.py
77 78 79 80 81 82 83 84 85 86 87 |
|
message
instance-attribute
A costume message which describes the success of starting or stopping the worker
success
instance-attribute
The API call was successful or not
url
instance-attribute
The API url
WorkerStatusEnum
Bases: StrEnum
Represents different statuses of a worker
Source code in src/mmisp/worker/api/response_schemas.py
67 68 69 70 71 72 73 74 |
|
WorkerStatusResponse
Bases: BaseModel
Represents the API response of getting the status of a worker
Source code in src/mmisp/worker/api/response_schemas.py
90 91 92 93 94 95 96 97 98 |
|
jobs_queued
instance-attribute
The number of queued jobs of the worker
status
instance-attribute
The status of the worker
Encapsulates input data classes for the jobs router.
JobEnum
Bases: StrEnum
Represents the implemented jobs
Source code in src/mmisp/worker/api/requests_schemas.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
UserData
Bases: BaseModel
Data class for user_id
Source code in src/mmisp/worker/api/requests_schemas.py
10 11 12 13 14 15 16 |
|
user_id
instance-attribute
The id of the user
worker_router = APIRouter(prefix='/worker', tags=['worker'])
module-attribute
Every method in this file is a route for the worker_router every endpoint is prefixed with /worker and requires the user to be verified
add_queue(id, body, response)
async
Adds an existing queue to a worker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The id of the worker. |
required |
body
|
RemoveAddQueueToWorker
|
The request body containing the queue name to add. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
HTTPException
|
If the worker or queue cannot be found or if an error occurs during queue addition. |
Source code in src/mmisp/worker/api/worker_router.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
get_job_queue(id)
async
Get a list of all job queues for the worker specified by the id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The id of the worker. |
required |
Returns:
Type | Description |
---|---|
list[GetWorkerJobqueue]
|
list[GetWorkerJobqueue]: A list of job queue objects for the worker. |
Raises:
Type | Description |
---|---|
HTTPException
|
If an error occurs while retrieving the job queues or the worker id is invalid. |
Source code in src/mmisp/worker/api/worker_router.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
list_all_workers()
async
Get a list of all workers.
Returns:
Type | Description |
---|---|
list[GetWorkerWorkers]
|
list[GetWorkerWorkers]: A list of GetWorkerWorkers objects with status, queues, |
list[GetWorkerWorkers]
|
and job counts of a single worker. |
Raises:
Type | Description |
---|---|
HTTPException
|
If an error occurs while retrieving the worker list. |
Source code in src/mmisp/worker/api/worker_router.py
151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
pause_worker(name)
async
Pauses a single worker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the worker. |
required |
Raises:
Type | Description |
---|---|
HTTPException
|
If the worker name does not exist. |
Source code in src/mmisp/worker/api/worker_router.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
remove_queue(id, body, response)
async
Removes an existing queue from a worker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The id of the worker. |
required |
body
|
RemoveAddQueueToWorker
|
The request body containing the queue name to remove. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
HTTPException
|
If the worker or queue cannot be found or if an error occurs during queue removal. |
Source code in src/mmisp/worker/api/worker_router.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
unpause_worker(name)
async
Unpauses a single worker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the worker. |
required |
Raises:
Type | Description |
---|---|
HTTPException
|
If the worker name does not exist. |
Source code in src/mmisp/worker/api/worker_router.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
verified(credentials=Depends(HTTPBearer(auto_error=False)))
A function to verify the api key that is sent by the client if the api key is not correct, it will raise an HTTPException
:param credentials: credentials sent by the client :type credentials: HTTPAuthorizationCredentials
Source code in src/mmisp/worker/api/api_verification.py
7 8 9 10 11 12 13 14 15 16 17 18 |
|