diff --git a/crc/api.yml b/crc/api.yml index 5311e14a..1cee4439 100644 --- a/crc/api.yml +++ b/crc/api.yml @@ -240,18 +240,18 @@ paths: schema: $ref: "#/components/schemas/Error" /workflow-specification/{spec_id}: + parameters: + - name: spec_id + in: path + required: false + description: The unique id of an existing workflow specification to modify. + schema: + type: string put: operationId: crc.api.workflow.update_workflow_specification summary: Modifies an existing workflow specification with the given parameters. tags: - Workflows and Tasks - parameters: - - name: spec_id - in: path - required: false - description: The unique id of an existing workflow specification to modify. - schema: - type: string requestBody: content: application/json: @@ -270,6 +270,14 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" + delete: + operationId: crc.api.workflow.delete_workflow_specification + summary: Removes an existing workflow specification + tags: + - Workflows and Tasks + responses: + '204': + description: The workflow specification has been removed. /file: parameters: - name: spec_id diff --git a/crc/api/workflow.py b/crc/api/workflow.py index b2e0bd4a..0e5ad309 100644 --- a/crc/api/workflow.py +++ b/crc/api/workflow.py @@ -21,13 +21,13 @@ def add_workflow_specification(body): def update_workflow_specification(spec_id, body): if spec_id is None: - error = ApiError('unknown_study', 'Please provide a valid Workflow Specification ID.') + error = ApiError('unknown_spec', 'Please provide a valid Workflow Specification ID.') return ApiErrorSchema.dump(error), 404 spec: WorkflowSpecModel = session.query(WorkflowSpecModel).filter_by(id=spec_id).first() if spec is None: - error = ApiError('unknown_study', 'The Workflow Specification "' + spec_id + '" is not recognized.') + error = ApiError('unknown_spec', 'The Workflow Specification "' + spec_id + '" is not recognized.') return ApiErrorSchema.dump(error), 404 spec = WorkflowSpecModelSchema().load(body, session=session) @@ -36,6 +36,23 @@ def update_workflow_specification(spec_id, body): return WorkflowSpecModelSchema().dump(spec) +def delete_workflow_specification(spec_id): + if spec_id is None: + error = ApiError('unknown_spec', 'Please provide a valid Workflow Specification ID.') + return ApiErrorSchema.dump(error), 404 + + spec: WorkflowSpecModel = session.query(WorkflowSpecModel).filter_by(id=spec_id).first() + + if spec is None: + error = ApiError('unknown_spec', 'The Workflow Specification "' + spec_id + '" is not recognized.') + return ApiErrorSchema.dump(error), 404 + + session.query(WorkflowSpecModel).filter_by(id=spec_id).delete() + + # TODO: Delete everything else with the same workflow_spec_id? + session.commit() + + def get_workflow(workflow_id): schema = WorkflowModelSchema() workflow = session.query(WorkflowModel).filter_by(id=workflow_id).first()