Adds endpoint to delete workflow spec
This commit is contained in:
parent
45f2e52c86
commit
6aa3d711ce
22
crc/api.yml
22
crc/api.yml
|
@ -240,18 +240,18 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
/workflow-specification/{spec_id}:
|
/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:
|
put:
|
||||||
operationId: crc.api.workflow.update_workflow_specification
|
operationId: crc.api.workflow.update_workflow_specification
|
||||||
summary: Modifies an existing workflow specification with the given parameters.
|
summary: Modifies an existing workflow specification with the given parameters.
|
||||||
tags:
|
tags:
|
||||||
- Workflows and Tasks
|
- 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:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
|
@ -270,6 +270,14 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$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:
|
/file:
|
||||||
parameters:
|
parameters:
|
||||||
- name: spec_id
|
- name: spec_id
|
||||||
|
|
|
@ -21,13 +21,13 @@ def add_workflow_specification(body):
|
||||||
|
|
||||||
def update_workflow_specification(spec_id, body):
|
def update_workflow_specification(spec_id, body):
|
||||||
if spec_id is None:
|
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
|
return ApiErrorSchema.dump(error), 404
|
||||||
|
|
||||||
spec: WorkflowSpecModel = session.query(WorkflowSpecModel).filter_by(id=spec_id).first()
|
spec: WorkflowSpecModel = session.query(WorkflowSpecModel).filter_by(id=spec_id).first()
|
||||||
|
|
||||||
if spec is None:
|
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
|
return ApiErrorSchema.dump(error), 404
|
||||||
|
|
||||||
spec = WorkflowSpecModelSchema().load(body, session=session)
|
spec = WorkflowSpecModelSchema().load(body, session=session)
|
||||||
|
@ -36,6 +36,23 @@ def update_workflow_specification(spec_id, body):
|
||||||
return WorkflowSpecModelSchema().dump(spec)
|
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):
|
def get_workflow(workflow_id):
|
||||||
schema = WorkflowModelSchema()
|
schema = WorkflowModelSchema()
|
||||||
workflow = session.query(WorkflowModel).filter_by(id=workflow_id).first()
|
workflow = session.query(WorkflowModel).filter_by(id=workflow_id).first()
|
||||||
|
|
Loading…
Reference in New Issue