syntax = "proto3";

package nominal.mesh.v1;

import "buf/validate/validate.proto";
import "google/protobuf/timestamp.proto";
import "nominal/protos/gen/v1/alias.proto";

option java_multiple_files = true;
option java_package = "io.nominal.mesh.v1";

enum RemoteConnectionStatus {
  REMOTE_CONNECTION_STATUS_UNSPECIFIED = 0;
  REMOTE_CONNECTION_STATUS_ONLINE = 1;
  REMOTE_CONNECTION_STATUS_OFFLINE = 2;
}

message RemoteConnection {
  // Unique identifier for this remote connection.
  string rid = 1 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.RemoteConnectionRid"}
  ];
  // Human readable name for this remote connection.
  string name = 2;
  // Base URL for the remote environment.
  string base_url = 3;
  // Secret to be used to authenticate with the remote environment.
  string secret_rid = 4 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.secrets.api.SecretRid"}
  ];
  // Health status of the remote connection.
  RemoteConnectionStatus status = 5;
  // Timestamp of the last status update.
  google.protobuf.Timestamp status_updated_at = 6;
}

message CreateRemoteConnectionRequest {
  string name = 1;
  string base_url = 2;
  string secret_rid = 3 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.secrets.api.SecretRid"}
  ];
  // The workspace to register the remote connection in.
  string workspace_rid = 4 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.WorkspaceRid"}
  ];
}

message CreateRemoteConnectionResponse {
  RemoteConnection remote_connection = 1;
}

message GetRemoteConnectionRequest {
  string remote_connection_rid = 1 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.RemoteConnectionRid"}
  ];
}

message GetRemoteConnectionResponse {
  RemoteConnection remote_connection = 1;
}

message UpdateRemoteConnectionRequest {
  string remote_connection_rid = 1 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.RemoteConnectionRid"}
  ];
  optional string name = 2;
  optional string base_url = 3;
  optional string secret_rid = 4 [(nominal.gen.v1.alias) = {java_name: "io.nominal.secrets.api.SecretRid"}];
}

message UpdateRemoteConnectionResponse {
  RemoteConnection remote_connection = 1;
}

message DeleteRemoteConnectionRequest {
  string remote_connection_rid = 1 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.RemoteConnectionRid"}
  ];
}

message DeleteRemoteConnectionResponse {}

message ListRemoteConnectionsRequest {
  // The workspace to list remote connections for.
  string workspace_rid = 1 [
    (buf.validate.field).required = true,
    (nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.WorkspaceRid"}
  ];
  // Maximum number of remote connections to return per page.
  int32 page_size = 2 [
    (buf.validate.field).int32.gte = 1,
    (buf.validate.field).int32.lte = 100
  ];
  // Token for pagination. If empty, returns the first page.
  optional string page_token = 3;
}

message ListRemoteConnectionsResponse {
  repeated RemoteConnection remote_connections = 1;
  // Token for retrieving the next page of results. Empty if no more pages.
  optional string next_page_token = 2;
}
