Adds endpoint to delete workflow spec

This commit is contained in:
Aaron Louie 2020-01-23 16:05:09 -05:00
parent 45f2e52c86
commit 6aa3d711ce
2 changed files with 34 additions and 9 deletions

View File

@ -240,11 +240,6 @@ paths:
schema:
$ref: "#/components/schemas/Error"
/workflow-specification/{spec_id}:
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
@ -252,6 +247,11 @@ paths:
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
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

View File

@ -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()