Skip to content

API

Encapsulates the response data for the jobs router.

CreateJobResponse

Bases: BaseModel

Encapsulates the response for a create jobs API call

job_id class-attribute instance-attribute

job_id: str | None = None

The id of the created job

success instance-attribute

success: bool

The API call was successful or not

DeleteJobResponse

Bases: BaseModel

Encapsulates the response for a remove jobs API call

success instance-attribute

success: bool

The API call was successful or not

ExceptionResponse

Bases: BaseModel

Encapsulates the response for a jobs where an exception was raised

message instance-attribute

message: str

A costume message which describes the error that occurred

JobStatusEnum

Bases: StrEnum

Encapsulates the status of a Job

JobStatusResponse

Bases: BaseModel

Encapsulates the response for a jobs status API call

message instance-attribute

message: str

A costume message which describes the success of getting the job status

status instance-attribute

status: JobStatusEnum

The status of the job

StartStopWorkerResponse

Bases: BaseModel

Represents the API response of starting and stopping a worker

message instance-attribute

message: str

A costume message which describes the success of starting or stopping the worker

success instance-attribute

success: bool

The API call was successful or not

url instance-attribute

url: str

The API url

WorkerStatusEnum

Bases: StrEnum

Represents different statuses of a worker

WorkerStatusResponse

Bases: BaseModel

Represents the API response of getting the status of a worker

jobs_queued instance-attribute

jobs_queued: int

The number of queued jobs of the worker

status instance-attribute

status: WorkerStatusEnum

The status of the worker

Encapsulates input data classes for the jobs router.

JobEnum

Bases: StrEnum

Represents the implemented jobs

UserData

Bases: BaseModel

Data class for user_id

user_id instance-attribute

user_id: int

The id of the user

worker_router module-attribute

worker_router: APIRouter = APIRouter(prefix='/worker', tags=['worker'])

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 async

add_queue(id: str, body: RemoveAddQueueToWorker, response: Response) -> None

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.

get_job_queue async

get_job_queue(id: str) -> list[GetWorkerJobqueue]

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.

list_all_workers async

list_all_workers() -> list[GetWorkerWorkers]

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.

pause_worker async

pause_worker(name: str) -> None

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.

remove_queue async

remove_queue(id: str, body: RemoveAddQueueToWorker, response: Response) -> None

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.

unpause_worker async

unpause_worker(name: str) -> None

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.

Encapsulates API calls for jobs

verified

verified(credentials: HTTPAuthorizationCredentials = Depends(HTTPBearer(auto_error=False))) -> None

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