2022-08-25 17:03:56 +00:00
|
|
|
"""Manipulate jobs"""
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
|
|
import strawberry
|
|
|
|
|
|
|
|
from selfprivacy_api.graphql.mutations.mutation_interface import GenericMutationReturn
|
2022-08-25 18:42:37 +00:00
|
|
|
from selfprivacy_api.graphql import IsAuthenticated
|
2022-08-25 17:03:56 +00:00
|
|
|
from selfprivacy_api.jobs import Jobs
|
|
|
|
|
|
|
|
|
|
|
|
@strawberry.type
|
|
|
|
class JobMutations:
|
|
|
|
"""Mutations related to jobs"""
|
|
|
|
|
2022-08-25 18:42:37 +00:00
|
|
|
@strawberry.mutation(permission_classes=[IsAuthenticated])
|
2022-08-25 17:03:56 +00:00
|
|
|
def remove_job(self, job_id: str) -> GenericMutationReturn:
|
|
|
|
"""Remove a job from the queue"""
|
2022-10-27 14:01:11 +00:00
|
|
|
result = Jobs.remove_by_uid(job_id)
|
2022-08-25 17:03:56 +00:00
|
|
|
if result:
|
|
|
|
return GenericMutationReturn(
|
|
|
|
success=True,
|
|
|
|
code=200,
|
|
|
|
message="Job removed",
|
|
|
|
)
|
|
|
|
return GenericMutationReturn(
|
|
|
|
success=False,
|
|
|
|
code=404,
|
|
|
|
message="Job not found",
|
|
|
|
)
|