syntax = "proto3";

package executor.v1;

// import "google/protobuf/timestamp.proto";
// import "protoc-gen-openapiv2/options/annotations.proto";
import "executor/v1/resources.proto";
// import "buf/validate/validate.proto";
// import "google/api/annotations.proto";
import "google/api/field_behavior.proto";

// import "google/protobuf/empty.proto";

option go_package = "v1";

service ExecutorService {
  rpc Submit(SubmitRequest) returns (SubmitResponse);
  rpc Abort(AbortRequest) returns (AbortResponse);
  rpc QueryRunnings(QueryRunningsRequest) returns (QueryRunningsResponse);
}

message SubmitRequest {
  string scope = 1 [(google.api.field_behavior) = REQUIRED];
  string plan_name = 2 [(google.api.field_behavior) = REQUIRED];
  string exec_id = 3 [(google.api.field_behavior) = REQUIRED];
  map<string, ActionArg> args = 4;
}

message SubmitResponse {
  string exec_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message AbortRequest {
  string scope = 1 [(google.api.field_behavior) = REQUIRED];
  string exec_id = 2 [(google.api.field_behavior) = REQUIRED];
}

message AbortResponse {
  string exec_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message QueryRunningsRequest {
  string scope = 1 [(google.api.field_behavior) = REQUIRED];
  string plan_name = 2 [(google.api.field_behavior) = REQUIRED];
  // Server-side filter: only return tasks whose args match all entries in match_args.
  // For each key, the task's arg value (or any of its comma-separated parts) must be in the filter values.
  // Empty match_args means no filtering (return all running tasks).
  map<string, MatchArgValues> match_args = 3;
}

message QueryRunningsResponse {
  map<string, ExecTaskStatusEx> exec_task_id_status = 1;
}
