From 5c7780eed9251ccbc767a937c5d5850dfd822849 Mon Sep 17 00:00:00 2001 From: Nicola Tarocco Date: Wed, 10 Jul 2024 17:10:26 +0200 Subject: [PATCH] service: raise when calling not implemented methods --- invenio_jobs/services/services.py | 70 +++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/invenio_jobs/services/services.py b/invenio_jobs/services/services.py index 3a4192f..7efc6b8 100644 --- a/invenio_jobs/services/services.py +++ b/invenio_jobs/services/services.py @@ -29,7 +29,71 @@ from .errors import JobNotFoundError, RunNotFoundError, RunStatusChangeError -class TasksService(RecordService): +class OnlySearchRecordService(RecordService): + """Base service class that allows only searching. + + Needed because this module does not have records, but re-implements the search + method from the record's service and uses the permissions mechanism. + """ + + def check_revision_id(self): + """Not implemented.""" + raise NotImplementedError() + + def create_search(self): + """Not implemented.""" + raise NotImplementedError() + + def search_request(self): + """Not implemented.""" + raise NotImplementedError() + + def scan(self): + """Not implemented.""" + raise NotImplementedError() + + def reindex(self): + """Not implemented.""" + raise NotImplementedError() + + def create(self): + """Not implemented.""" + raise NotImplementedError() + + def read(self): + """Not implemented.""" + raise NotImplementedError() + + def exists(self): + """Not implemented.""" + raise NotImplementedError() + + def read_many(self): + """Not implemented.""" + raise NotImplementedError() + + def read_all(self): + """Not implemented.""" + raise NotImplementedError() + + def update(self): + """Not implemented.""" + raise NotImplementedError() + + def delete(self): + """Not implemented.""" + raise NotImplementedError() + + def rebuild_index(self): + """Not implemented.""" + raise NotImplementedError() + + def on_relation_update(self): + """Not implemented.""" + raise NotImplementedError() + + +class TasksService(OnlySearchRecordService): """Tasks service.""" def search(self, identity, params): @@ -78,7 +142,7 @@ def get_run(run_id, job_id=None): return run -class JobsService(RecordService): +class JobsService(OnlySearchRecordService): """Jobs service.""" @unit_of_work() @@ -173,7 +237,7 @@ def delete(self, identity, id_, uow=None): return True -class RunsService(RecordService): +class RunsService(OnlySearchRecordService): """Runs service.""" def search(self, identity, job_id, params):