diff --git a/proto/caosdb/scripting/v1alpha1/scripting.proto b/proto/caosdb/scripting/v1alpha1/scripting.proto new file mode 100644 index 0000000000000000000000000000000000000000..c1247190908b971a0f4ab27c6f88ac275f8ded06 --- /dev/null +++ b/proto/caosdb/scripting/v1alpha1/scripting.proto @@ -0,0 +1,97 @@ +// +// This file is a part of the LinkAhead Project. +// +// Copyright (C) 2025 Joscha Schmiedt <joscha@schmiedt.dev> +// Copyright (C) 2025 IndiScale GmbH <info@indiscale.com> +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. + +syntax = "proto3"; + +package caosdb.scripting.v1alpha1; + +option java_multiple_files = true; +option java_package = "org.caosdb.api.scripting.v1alpha1"; + +message NamedArgument { + string name = 1; + string value = 2; +} + +message ExecuteScriptRequest { + // The script to execute + string script_filename = 1; + // Whether the script should be executed asynchronously + bool is_async = 2; + // The positional arguments for the script + repeated string positional_arguments = 3; + // The named arguments for the script + repeated NamedArgument named_arguments = 4; + // TODO: Should we support this? + // The files to be used by the script (will be uploaded to the server) + repeated string script_files = 5; +} + +enum ScriptExecutionResult { + // The result of the script execution is unspecified + SCRIPT_EXECUTION_RESULT_UNSPECIFIED = 0; + // The script execution was successful + SCRIPT_EXECUTION_RESULT_SUCCESS = 1; + // The script execution failed (general/unspecified failure) + SCRIPT_EXECUTION_RESULT_GENERAL_FAILURE = 2; + // The script execution was cancelled + SCRIPT_EXECUTION_RESULT_CANCELLED = 3; + // The script execution was denied due to insufficient permissionss + SCRIPT_EXECUTION_RESULT_PERMISSION_DENIED = 4; + // The script execution was denied due to a timeout + SCRIPT_EXECUTION_RESULT_TIMEOUT = 5; + // The script is running and the result is not yet available (only for async scripts) + SCRIPT_EXECUTION_RESULT_RUNNING = 6; + // The script execution was denied due to a missing script file + SCRIPT_EXECUTION_RESULT_MISSING_SCRIPT_FILE = 7; +} + +message ScriptExecutionId { + // Id of the script execution + string script_execution_id = 1; +} + +message ExecuteScriptResponse { + // Id of the script execution + ScriptExecutionId script_execution_id = 1; + // The script to execute + string script_filename = 2; + // The result of the script execution + ScriptExecutionResult result = 3; + // Script return code + int32 return_code = 4; + // The standard output of the script + string stdout = 5; + // The standard error of the script + string stderr = 6; + // TODO: Ideas: + string executing_user = 7; + string execution_datetime = 8; + + // TODO: Will we ever support this? How should the server know about them? Should the created files be downloaded? + // The files generated by the script + repeated string created_files = 9; +} + +service ServerSideScriptingService { + // Executes a script on the server side + rpc ExecuteScript(ExecuteScriptRequest) returns (ExecuteScriptResponse) {} + // Ideas + rpc GetScriptExecutionStatus(ScriptExecutionId) returns (ExecuteScriptResponse) {} +}