// 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";

import "chromiumos/longrunning/operations.proto";
import "google/protobuf/any.proto";
import "chromiumos/storage_path.proto";
import "chromiumos/test/api/cros_test_cli.proto";

// Generic publishing interface for CFT. Intended to be interchangeable across
// services
service GenericPublishService {
  // Publish publishes test results to a specific endpoint.
  // It is intended to be a generic publish grpc that may be
  // used by all endpoints.
  rpc Publish(PublishRequest) returns (longrunning.Operation) {
    option (longrunning.operation_info) = {
      response_type: "PublishResponse",
      metadata_type: "PublishMetadata"
    };
  }
}

// NEXT_TAG: 6
message PublishRequest {
  // Local path to tests artifact directory
  StoragePath artifact_dir_path = 1;

  // Test responses from cros-test
  CrosTestResponse test_response = 2;

  // Retry count. Default is 0 where no retry will be done.
  int32 retry_count = 3;

  // Endpoint specific metadata
  google.protobuf.Any metadata = 4;

  // Flag to indicate whether tests are run via 3d.
  bool is_3d_run = 5;
}

message PublishResponse {
  // Status of the publish operation
  enum Status {
    // Unspecified.  Invalid state.
    STATUS_UNSPECIFIED = 0;
    // Success
    STATUS_SUCCESS = 1;
    // Invalid Request
    STATUS_INVALID_REQUEST = 2;
    // Failure
    STATUS_FAILURE = 3;
  }
  // Status of the publish operation
  Status status = 1;

  // Any kind of message that the service wants to respond with.
  // In case of failure, this will hold the error message.
  string message = 2;

  // Endpoint specific metadata
  google.protobuf.Any metadata = 3;
}
