I drafted a gRPC API covering the current state as well as some future ideas (async execution, created files, execution id for bookkeeping) (see also branch f-sss4grpc of caosdb-proto)
syntax="proto3";packagecaosdb.scripting.v1alpha1;optionjava_multiple_files=true;optionjava_package="org.caosdb.api.scripting.v1alpha1";messageNamedArgument{// The name of the argumentstringname=1;// The value of the argumentstringvalue=2;}messageExecuteScriptRequest{// The script to executestringscript_filename=1;// The timeout for the script execution in millisecondsint64timeout_ms=2;// The positional arguments for the scriptrepeatedstringpositional_arguments=3;// The named arguments for the scriptrepeatedNamedArgumentnamed_arguments=4;// The files to be used by the script (will be uploaded to the server)repeatedstringscript_files=5;// IDEA: Whether the script should be executed asynchronouslyboolrun_async=6;}enumScriptExecutionResult{// The result of the script execution is unspecifiedSCRIPT_EXECUTION_RESULT_UNSPECIFIED=0;// The script execution was successfulSCRIPT_EXECUTION_RESULT_SUCCESS=1;// The script execution failed (general/unspecified failure)SCRIPT_EXECUTION_RESULT_GENERAL_FAILURE=2;// The script does not existSCRIPT_EXECUTION_RESULT_SCRIPT_DOES_NOT_EXIST=3;// The script is not executableSCRIPT_EXECUTION_RESULT_SCRIPT_NOT_EXECUTABLE=4;// The script execution failed due to a script errorSCRIPT_EXECUTION_RESULT_SCRIPT_ERROR=5;// The script execution failed during setup, e.g. due to configuration errorsSCRIPT_EXECUTION_RESULT_SCRIPT_SETUP_ERROR=6;// The script execution timed outSCRIPT_EXECUTION_RESULT_SCRIPT_TIMEOUT=7;// The script execution was cancelled for another reasonSCRIPT_EXECUTION_RESULT_CANCELLED=8;// The script execution was denied due to insufficient permissionsSCRIPT_EXECUTION_RESULT_PERMISSION_DENIED=9;// The script is running and the result is not yet available (only for async scripts)SCRIPT_EXECUTION_RESULT_RUNNING=10;}// IDEA: Give the script execution an id to be able to track itmessageScriptExecutionId{// Id of the script executionstringscript_execution_id=1;}messageExecuteScriptResponse{// Id of the script executionScriptExecutionIdscript_execution_id=1;// The script to executestringscript_filename=2;// The result of the script executionScriptExecutionResultresult=3;// Script return codeint32return_code=4;// The standard output of the scriptstringstdout=5;// The standard error of the scriptstringstderr=6;// IDEA: The user who executed the scriptstringexecuting_user=7;// IDEA: The date and time when the script was startedstringexecution_start_datetime=8;// IDEA: The date and time when the script was finishedstringexecution_end_datetime=9;// IDEA: The duration of the script executionstringexecution_duration=10;// IDEA: Return a list of files created by the script. These files will be available for download.// The files will be deleted after a certain time? How should the server know about// about these?repeatedstringcreated_files=11;}serviceServerSideScriptingService{// Executes a script on the server siderpcExecuteScript(ExecuteScriptRequest)returns(ExecuteScriptResponse){}// IDEA: Get the status of a script executionrpcGetScriptExecutionStatus(ScriptExecutionId)returns(ExecuteScriptResponse){}// IDEA: Delete temp files (only for admins?)// rpc DeleteTempFiles(DeleteTempFilesRequest) returns (DeleteTempFilesResponse) {}// IDEA: Wait for a script execution to finish// rpc WaitForScriptExecution(ScriptExecutionId, TimeoutDuration) returns (ExecuteScriptResponse) {}}
Covering the current functionality should be relatively straightforward with the exception of the files that are uploaded along with the request. Uploading files via gRPC still has limitations (see also #354) and may be changed substantially.