Skip to content

Commit

Permalink
api: add workflow seeding endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
  • Loading branch information
Diego Rodriguez committed Oct 12, 2017
1 parent 665e5b3 commit db37c69
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 0 deletions.
75 changes: 75 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,81 @@
"summary": "Returns all workflows."
}
},
"/api/workflows/{workflow_id}/workspace": {
"post": {
"consumes": [
"multipart/form-data"
],
"description": "This resource is expecting a workflow UUID and a file to place in the workflow workspace.",
"operationId": "seed_workflow",
"parameters": [
{
"description": "Required. Organization which the worklow belongs to.",
"in": "query",
"name": "organization",
"required": true,
"type": "string"
},
{
"description": "Required. UUID of workflow owner.",
"in": "query",
"name": "user",
"required": true,
"type": "string"
},
{
"description": "Required. Workflow UUID.",
"in": "path",
"name": "workflow_id",
"required": true,
"type": "string"
},
{
"description": "Required. File to add to the workflow workspace.",
"in": "formData",
"name": "file_content",
"required": true,
"type": "file"
},
{
"description": "Required. File name.",
"in": "query",
"name": "file_name",
"required": true,
"type": "string"
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "Request succeeded. The file has been added to the workspace.",
"examples": {
"application/json": {
"message": "Workflow has been added to the workspace",
"workflow_id": "cdcf48b1-c2f3-4693-8230-b066e088c6ac"
}
},
"schema": {
"properties": {
"message": {
"type": "string"
},
"workflow_id": {
"type": "string"
}
},
"type": "object"
}
},
"400": {
"description": "Request failed. The incoming data specification seems malformed"
}
},
"summary": "Adds a file to the workflow workspace."
}
},
"/api/yadage/remote": {
"post": {
"consumes": [
Expand Down
74 changes: 74 additions & 0 deletions reana_workflow_controller/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import traceback

from flask import Blueprint, abort, jsonify, request
from werkzeug.utils import secure_filename

from .factory import db
from .fsdb import get_all_workflows
Expand Down Expand Up @@ -147,6 +148,79 @@ def get_workflows(): # noqa
return jsonify({"message": str(e)}), 500


@restapi_blueprint.route('/workflows/<workflow_id>/workspace',
methods=['POST'])
def seed_workflow_workspace(workflow_id):
r"""Seed workflow workspace.
---
post:
summary: Adds a file to the workflow workspace.
description: >-
This resource is expecting a workflow UUID and a file to place in the
workflow workspace.
operationId: seed_workflow
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- name: organization
in: query
description: Required. Organization which the worklow belongs to.
required: true
type: string
- name: user
in: query
description: Required. UUID of workflow owner.
required: true
type: string
- name: workflow_id
in: path
description: Required. Workflow UUID.
required: true
type: string
- name: file_content
in: formData
description: Required. File to add to the workflow workspace.
required: true
type: file
- name: file_name
in: query
description: Required. File name.
required: true
type: string
responses:
200:
description: >-
Request succeeded. The file has been added to the workspace.
schema:
type: object
properties:
message:
type: string
workflow_id:
type: string
examples:
application/json:
{
"message": "Workflow has been added to the workspace",
"workflow_id": "cdcf48b1-c2f3-4693-8230-b066e088c6ac"
}
400:
description: >-
Request failed. The incoming data specification seems malformed
"""
try:
file_ = request.files['file_content'].stream.read()
file_name = secure_filename(request.args['file_name'])
return jsonify({'message': 'File successfully transferred'}), 200
except KeyError as e:
return jsonify({"message": str(e)}), 400
except Exception as e:
return jsonify({"message": str(e)}), 500


@restapi_blueprint.route('/yadage/remote', methods=['POST'])
def run_yadage_workflow_from_remote_endpoint(): # noqa
r"""Create a new yadage workflow from a remote repository.
Expand Down

0 comments on commit db37c69

Please sign in to comment.