Skip to content

Commit

Permalink
resources: update request/response handler MIMETypes
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed May 24, 2024
1 parent c53a8ee commit 13d1af1
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions invenio_jobs/resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@

from ..services.errors import JobNotFoundError

response_handlers = {
**ResourceConfig.response_handlers,
"application/vnd.inveniordm.v1+json": ResourceConfig.response_handlers[
"application/json"
],
}
request_body_parsers = {
**ResourceConfig.request_body_parsers,
"application/vnd.inveniordm.v1+json": ResourceConfig.request_body_parsers[
"application/json"
],
}


class TasksResourceConfig(ResourceConfig, ConfiguratorMixin):
"""Celery tasks resource config."""
Expand All @@ -25,7 +38,12 @@ class TasksResourceConfig(ResourceConfig, ConfiguratorMixin):
url_prefix = "/tasks"
routes = {"list": ""}

# Request handling
request_search_args = SearchRequestArgsSchema
request_body_parsers = request_body_parsers

# Response handling
response_handlers = response_handlers


class JobsSearchRequestArgsSchema(SearchRequestArgsSchema):
Expand All @@ -45,10 +63,14 @@ class JobsResourceConfig(ResourceConfig, ConfiguratorMixin):
"item": "/<job_id>",
}

# Request parsing
# Request handling
request_read_args = {}
request_view_args = {"job_id": ma.fields.UUID()}
request_search_args = JobsSearchRequestArgsSchema
request_body_parsers = request_body_parsers

# Response handling
response_handlers = response_handlers

error_handlers = {
**ErrorHandlersMixin.error_handlers,
Expand All @@ -72,11 +94,15 @@ class RunsResourceConfig(ResourceConfig, ConfiguratorMixin):
"actions_stop": "/jobs/<job_id>/runs/<run_id>/actions/stop",
}

# Request parsing
# Request handling
request_view_args = {
"job_id": ma.fields.UUID(),
"run_id": ma.fields.UUID(),
}
request_body_parsers = request_body_parsers

# Response handling
response_handlers = response_handlers

error_handlers = {
**ErrorHandlersMixin.error_handlers,
Expand Down

0 comments on commit 13d1af1

Please sign in to comment.