Skip to content
Snippets Groups Projects

Add server-side scripting to gRPC API

Open Joscha Schmiedt requested to merge f-sss4grpc into dev
Files
2
@@ -21,9 +21,12 @@ syntax = "proto3";
package caosdb.scripting.v1alpha1;
import "google/protobuf/timestamp.proto";
option java_multiple_files = true;
option java_package = "org.caosdb.api.scripting.v1alpha1";
option java_package = "org.caosdb.api.scripting.v1alpha1";
// A named argument for a script
message NamedArgument {
// The name of the argument
string name = 1;
@@ -31,7 +34,8 @@ message NamedArgument {
string value = 2;
}
message ExecuteScriptRequest {
// Request to execute a script on the server side
message ExecuteServerSideScriptRequest {
// The script to execute
string script_filename = 1;
// The timeout for the script execution in milliseconds
@@ -40,77 +44,76 @@ message ExecuteScriptRequest {
repeated string positional_arguments = 3;
// The named arguments for the script
repeated NamedArgument named_arguments = 4;
// The files to be used by the script (will be uploaded to the server)
// The files to be used by the script (will be uploaded to the server, not
// implemented yet)
repeated string script_files = 5;
// IDEA: Whether the script should be executed asynchronously
bool run_async = 6;
// The authentication token for the script execution. Will be generated by
// the server if empty.
string auth_token = 6;
// Whether the script should be executed asynchronously (not implemented yet)
bool run_async = 7;
}
enum ScriptExecutionResult {
// The result of a script execution
enum ServerSideScriptExecutionResult {
// The result of the script execution is unspecified
SCRIPT_EXECUTION_RESULT_UNSPECIFIED = 0;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_UNSPECIFIED = 0;
// The script execution was successful
SCRIPT_EXECUTION_RESULT_SUCCESS = 1;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_SUCCESS = 1;
// The script execution failed (general/unspecified failure)
SCRIPT_EXECUTION_RESULT_GENERAL_FAILURE = 2;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_GENERAL_FAILURE = 2;
// The script does not exist
SCRIPT_EXECUTION_RESULT_SCRIPT_DOES_NOT_EXIST = 3;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_SCRIPT_DOES_NOT_EXIST = 3;
// The script is not executable
SCRIPT_EXECUTION_RESULT_SCRIPT_NOT_EXECUTABLE = 4;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_SCRIPT_NOT_EXECUTABLE = 4;
// The script execution failed due to a script error
SCRIPT_EXECUTION_RESULT_SCRIPT_ERROR = 5;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_SCRIPT_ERROR = 5;
// The script execution failed during setup, e.g. due to configuration errors
SCRIPT_EXECUTION_RESULT_SCRIPT_SETUP_ERROR = 6;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_SCRIPT_SETUP_ERROR = 6;
// The script execution timed out
SCRIPT_EXECUTION_RESULT_SCRIPT_TIMEOUT = 7;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_SCRIPT_TIMEOUT = 7;
// The script execution was cancelled for another reason
SCRIPT_EXECUTION_RESULT_CANCELLED = 8;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_CANCELLED = 8;
// The script execution was denied due to insufficient permissions
SCRIPT_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;
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_PERMISSION_DENIED = 9;
// The script is running and the result is not yet available (only for
// async scripts)
SERVER_SIDE_SCRIPT_EXECUTION_RESULT_RUNNING = 10;
}
// IDEA: Give the script execution an id to be able to track it
message ScriptExecutionId {
// Id of a script execution. This is reserved for later releases to track
// and manage script executions.
message ServerSideScriptExecutionId {
// Id of the script execution
string script_execution_id = 1;
}
message ExecuteScriptResponse {
// Response to a script execution request
message ExecuteServerSideScriptResponse {
// Id of the script execution
ScriptExecutionId script_execution_id = 1;
// The script to execute
string script_filename = 2;
ServerSideScriptExecutionId script_execution_id = 1;
// The full command that was executed including all args
string call = 2;
// The result of the script execution
ScriptExecutionResult result = 3;
ServerSideScriptExecutionResult 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;
// IDEA: The user who executed the script
string executing_user = 7;
// IDEA: The date and time when the script was started
string execution_start_datetime = 8;
// IDEA: The date and time when the script was finished
string execution_end_datetime = 9;
// IDEA: The duration of the script execution
string execution_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?
repeated string created_files = 11;
// The start time of the script execution
google.protobuf.Timestamp start_time = 7;
// The end time of the script execution (empty if the script is still running)
google.protobuf.Timestamp end_time = 8;
// The duration of the script execution in milliseconds (zero if the script
// is still running)
int64 duration_ms = 9;
}
// Service for server-side scripting
service ServerSideScriptingService {
// Executes a script on the server side
rpc ExecuteScript(ExecuteScriptRequest) returns (ExecuteScriptResponse) {}
// IDEA: Get the status of a script execution
rpc GetScriptExecutionStatus(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) {}
rpc ExecuteServerSideScript(ExecuteServerSideScriptRequest)
returns (ExecuteServerSideScriptResponse) {}
}
Loading