// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto3";

package chromiumos.test.api;

option go_package = "go.chromium.org/chromiumos/config/go/test/api";

// TestLibsService defines interactions with a Test Libs Server.
service TestLibsService {
  // StartLib starts a new docker container running for the given library.
  rpc StartLib(GetLibRequest) returns (GetLibResponse);

  // FindLib connects to an existing docker container (or starts one if no match
  // is found).
  rpc FindLib(GetLibRequest) returns (GetLibResponse);

  // KillLib closes a running docker container.
  rpc KillLib(KillLibRequest) returns (KillLibResponse);
}

// Get Lib messages.
message GetLibSuccess {
  string id = 1;
  string port = 2;
}

message GetLibFailure {
  enum Reason {
    REASON_UNKNOWN = 0;
    REASON_UNREGISTERED_LIB = 1;
    REASON_CONTAINER_START_ERROR = 2;
  }
  Reason reason = 1;
}

message GetLibRequest {
  string name = 1;
  string version = 2;
  repeated string options = 3;
}

message GetLibResponse {
  oneof outcome {
    GetLibSuccess success = 1;
    GetLibFailure failure = 2;
  }
}

// Kill Lib messages.
message KillLibRequest {
  string id = 1;
  string options = 2;
}

message KillLibResponse {}
