def remove_workflow(workflow_id, **_): """ Remove the specified workflow. Variables: workflow_id => ID of the workflow to remove Arguments: None Data Block: None Result example: { "success": true # Was the remove successful? } """ wf = STORAGE.get_workflow(workflow_id) if wf: STORAGE.delete_workflow(workflow_id) return make_api_response({"success": True}) else: return make_api_response({"success": False}, err="Workflow ID %s does not exist" % workflow_id, status_code=404)
def edit_workflow(workflow_id, **_): """ Edit a workflow. Variables: workflow_id => ID of the workflow to edit Arguments: None Data Block: { "name": "Workflow name", # Name of the workflow "classification": "", # Max classification for workflow "label": ['label1'], # Labels for the workflow "priority": "LOW", # Priority of the workflow "status": "MALICIOUS", # Status of the workflow "query": "*:*" # Query to match the data } Result example: { "success": true # Saving the user info succeded } """ data = request.json name = data.get('name', None) query = data.get('query', None) if not name: return make_api_response({"success": False}, err="Name field is required", status_code=400) if not query: return make_api_response({"success": False}, err="Query field is required", status_code=400) wf = STORAGE.get_workflow(workflow_id) if wf: STORAGE.save_workflow(workflow_id, data) return make_api_response({"success": True}) else: return make_api_response({"success": False}, err="Workflow ID %s does not exist" % workflow_id, status_code=404)
def get_workflow(workflow_id, **kwargs): """ Load the user account information. Variables: workflow_id => ID of the workflow Arguments: None Data Block: None Result example: { "name": "Workflow name", # Name of the workflow "classification": "", # Max classification for workflow "label": ['label1'], # Labels for the workflow "priority": "LOW", # Priority of the workflow "status": "MALICIOUS", # Status of the workflow "query": "*:*" # Query to match the data } """ user = kwargs['user'] wf = STORAGE.get_workflow(workflow_id) if wf: if CLASSIFICATION.is_accessible(user['classification'], wf['classification']): return make_api_response(wf) else: return make_api_response({}, err="You're not allowed to view workflow ID: %s" % workflow_id, status_code=403) else: return make_api_response({}, err="Workflow ID %s does not exist" % workflow_id, status_code=404)