diff --git a/server/apierrors/__init__.py b/server/apierrors/__init__.py index 8064181..46fad7b 100644 --- a/server/apierrors/__init__.py +++ b/server/apierrors/__init__.py @@ -105,7 +105,6 @@ _error_codes = { (403, 'forbidden'): { 10: ('routing_error', 'forbidden (routing error)'), - 11: ('missing_routing_header', 'forbidden (missing routing header)'), 12: ('blocked_internal_endpoint', 'forbidden (blocked internal endpoint)'), 20: ('role_not_allowed', 'forbidden (not allowed for role)'), 21: ('no_write_permission', 'forbidden (modification not allowed)'), diff --git a/server/apimodels/base.py b/server/apimodels/base.py index 842d338..51ba290 100644 --- a/server/apimodels/base.py +++ b/server/apimodels/base.py @@ -58,3 +58,7 @@ class UpdateResponse(models.Base): class PagedRequest(models.Base): page = fields.IntField() page_size = fields.IntField() + + +class IdResponse(models.Base): + id = fields.StringField(required=True) diff --git a/server/apimodels/tasks.py b/server/apimodels/tasks.py index 5145522..a025aeb 100644 --- a/server/apimodels/tasks.py +++ b/server/apimodels/tasks.py @@ -1,6 +1,6 @@ import six from jsonmodels import models -from jsonmodels.fields import StringField, BoolField, IntField +from jsonmodels.fields import StringField, BoolField, IntField, EmbeddedField from jsonmodels.validators import Enum from apimodels import DictField, ListField @@ -9,6 +9,24 @@ from database.model.task.task import TaskType from database.utils import get_options +class ArtifactTypeData(models.Base): + preview = StringField() + content_type = StringField() + data_hash = StringField() + + +class Artifact(models.Base): + key = StringField(required=True) + type = StringField(required=True) + mode = StringField(validators=Enum("input", "output"), default="output") + uri = StringField() + hash = StringField() + content_size = IntField() + timestamp = IntField() + type_data = EmbeddedField(ArtifactTypeData) + display_data = ListField([list]) + + class StartedResponse(UpdateResponse): started = IntField() @@ -72,3 +90,22 @@ class CreateRequest(TaskData): class PingRequest(TaskRequest): pass + + +class CloneRequest(TaskRequest): + new_task_name = StringField() + new_task_comment = StringField() + new_task_tags = ListField([str]) + new_task_system_tags = ListField([str]) + new_task_parent = StringField() + new_task_project = StringField() + execution_overrides = DictField() + + +class AddOrUpdateArtifactsRequest(TaskRequest): + artifacts = ListField([Artifact], required=True) + + +class AddOrUpdateArtifactsResponse(models.Base): + added = ListField([str]) + updated = ListField([str])