diff --git a/backend/app_sdk/README.md b/backend/app_sdk/README.md index 754392ff..170781f3 100644 --- a/backend/app_sdk/README.md +++ b/backend/app_sdk/README.md @@ -1,9 +1,5 @@ # app_sdk.py This is the SDK used for apps to behave like they should. -To change it in the backend, upload it to Buckets/shuffler.appspot.com/generated_apps/baseline. - -# static_baseline.py -It's used for python code generation and should be under MIT. Has to be located here because it's used by the backend. ## If you want to update apps.. PS: downloads from docker hub do overrides.. :) 1. Write your code & check if runtime works diff --git a/backend/app_sdk/requirements.txt b/backend/app_sdk/requirements.txt index 0da82340..acde3f06 100644 --- a/backend/app_sdk/requirements.txt +++ b/backend/app_sdk/requirements.txt @@ -1,2 +1,2 @@ -urllib3 -requests +urllib3=1.25.9 +requests=2.25.1 diff --git a/backend/app_sdk/static_baseline.py b/backend/app_sdk/static_baseline.py deleted file mode 100644 index 152131cd..00000000 --- a/backend/app_sdk/static_baseline.py +++ /dev/null @@ -1,76 +0,0 @@ -import os -import sys -import time -import logging -import requests - -# Goal here: -# * Make an app from WALKOFF able to run without app_base.py from WALKOFF -# # How: -# * Make it rely 100% on INPUT throug HTTP invocations instead of redis READS -# # But really, how? -# * Make a WORKER that reads the queue, and reuses a function - -# Here to get it global -apikey = "" -try: - apikey = os.environ["FUNCTION_APIKEY"] -except KeyError: - pass - -# Authorize the execution -def authorization(request): - # This is basically my issue, but it enforces the use of an internal API key for execution - try: - apikey = os.environ["FUNCTION_APIKEY"] - except KeyError: - return f"Internal server error", 500 - - - # Check API key from ENV authentication - authentication = request.headers.get("Authorization") - if authentication == None: return f"Unauthorized", 401 - - apikey_split = authentication.split(" ") - if apikey_split[0] != "Bearer" or len(apikey_split) != 2: - return f"Apikey error", 401 - - if apikey != apikey_split[1]: - return f"Unauthorized", 401 - - return run(request) - -class AppBase: - """ The base class for Python-based Walkoff applications, handles Redis and logging configurations. """ - __version__ = None - app_name = None - - def __init__(self, redis=None, logger=None, console_logger=None):#, docker_client=None): - self.logger = logger if logger is not None else logging.getLogger("AppBaseLogger") - self.redis=redis - self.console_logger=console_logger - self.current_execution_id = None - self.url = "https://shuffler.io" - self.apikey = apikey - - @classmethod - async def run(cls, action): - """ Connect to Redis and HTTP session, await actions """ - logging.basicConfig(format="{asctime} - {name} - {levelname}:{message}", style='{') - logger = logging.getLogger(f"{cls.__name__}") - logger.setLevel(logging.DEBUG) - - app = cls(redis=None, logger=logger, console_logger=logger) - - # Authorization for the app/function to control the workflow - # Function will crash if its wrong, which it probably should. - - await app.execute_action(action) - - async def execute_action(self, action): - # FIXME - add request for the function STARTING here. Use "results stream" or something - # PAUSED, AWAITING_DATA, PENDING, COMPLETED, ABORTED, EXECUTING, SUCCESS, FAILURE - - self.authorization = action["authorization"] - self.execution_id = action["execution_id"] - self.current_execution_id = action["execution_id"] diff --git a/frontend/src/components/ConfigureWorkflow.jsx b/frontend/src/components/ConfigureWorkflow.jsx new file mode 100644 index 00000000..0e83f81b --- /dev/null +++ b/frontend/src/components/ConfigureWorkflow.jsx @@ -0,0 +1,97 @@ +import React, {useState} from 'react'; + +import {Typography, } from '@material-ui/core'; + +const Workflow = (props) => { + const { workflow, appAuthentication, apps } = props + const [requiredActions, setRequiredActions] = React.useState([]) + const [firstLoad, setFirstLoad] = React.useState("") + + // Rofl + if (workflow === undefined || workflow === null) { + return null + } + + if (apps === undefined || apps === null) { + return null + } + + if (appAuthentication === undefined || appAuthentication === null) { + return null + } + + if (firstLoad.length === 0 || firstLoad !== workflow.id) { + setFirstLoad(workflow.id) + const newactions = [] + for (var key in workflow.actions) { + var newaction = { + "large_image": "", + "app_name": "", + "app_version": "", + "must_activate": false, + "must_authenticate": false, + "action_ids": [], + } + + const action = workflow.actions[key] + console.log(action) + const app = apps.find(app => app.name === action.app_name && app.app_version === action.app_version) + if (app === undefined || app === null) { + console.log("COULDNT FIND APP - SEARCH BACKEND") + + newaction.app_name = action.app_name + newaction.app_version = action.app_version + } else { + newaction.app_name = app.name + newaction.app_version = app.app_version + + console.log("APP: ", app) + if (action.authentication_id === "" && app.authentication.required === true) { + console.log("Requires auth!") + newaction.must_authenticate = true + newaction.action_ids.push(action.id) + } + + //newaction.app_name = action.app_name + //newaction.app_name = action.app_version + } + + if (action.errors !== undefined && action.errors !== null && action.errors.length > 0) { + console.log("Has errors!") + } + + console.log("NEWACTION: ", newaction) + if (newaction.must_authenticate || newaction.must_activate) { + newactions.push(newaction) + } + } + + console.log("ACTIONS: ", newactions) + setRequiredActions(newactions) + } + + const AppSection = (props) => { + const {action} = props + + return ( +
{description}