syntax = "proto3";

// If you make any changes make sure you run: make regenerate-proto

package gitlab.agent.runner_controller.rpc;

option go_package = "gitlab.com/gitlab-org/cluster-integration/gitlab-agent/v18/internal/module/runner_controller/rpc";

import "buf/validate/validate.proto";

message AdmitJobRequest {
  int64 project_id = 1;
  string project_name = 2;
  string project_full_path = 3;
  int64 namespace_id = 4;
  int64 root_namespace_id = 5;
  int64 organization_id = 6;
  int64 user_id = 7;

  Image image = 8;
  int64 runner_id = 9;
}

message Image {
  string name = 1;
}

message AdmitJobResponse {
  oneof admission_response {
    option (buf.validate.oneof).required = true;

    Admitted admitted = 1;
    Rejected rejected = 2;
  }
}

message Admitted {}

message Rejected {
  string reason = 1 [(buf.validate.field).string.min_bytes = 1];
}

service RunnerControllerService {
  rpc AdmitJob(stream AdmitJobResponse) returns (stream AdmitJobRequest) {}
}
