// This proto file was generated from sandbox-workspace-service-api.yml.
// Care should be taken while both files exist to maintain backwards compatibility with the Conjure generated code.

syntax = "proto3";

package nominal.sandbox.v1;

import "google/api/annotations.proto";
import "nominal/protos/gen/v1/alias.proto";

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

message AddDemoWorkbooksRequest {
  repeated string notebook_rids = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.scout.rids.api.NotebookRid"}];

  // When true, existing workbooks with an exact label-set match are archived
  // instead of raising an error, along with all related resources discovered
  // via full graph traversal: the workbook's data scope seeds initial assets
  // or runs, then the system alternates between discovering runs linked to
  // assets and assets linked to runs until no new resources are found.
  // All discovered assets, runs, datasets (from both asset and run data
  // scopes), and events (from the workbook's snapshot refs and from all
  // discovered assets) are archived. This is intended for demo workbook
  // replacement flows where all resources are recreated from scratch.
  // Partial (subset/superset) label conflicts always raise an error.
  // Defaults to false.
  optional bool archive_on_label_conflict = 2;
}

message GetDemoWorkbooksResponse {
  repeated string notebook_rids = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.scout.rids.api.NotebookRid"}];
}

message SetDemoWorkbooksRequest {
  repeated string notebook_rids = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.scout.rids.api.NotebookRid"}];
}

message GetDemoWorkbooksRequest {
  string workspace_rid = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.WorkspaceRid"}];
}

message SetDemoWorkbooksRequestWrapper {
  string workspace_rid = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.WorkspaceRid"}];

  SetDemoWorkbooksRequest request = 2;
}

message SetDemoWorkbooksResponse {}

message AddDemoWorkbooksRequestWrapper {
  string workspace_rid = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.WorkspaceRid"}];

  AddDemoWorkbooksRequest request = 2;
}

message AddDemoWorkbooksResponse {}

// Service for managing demo workbooks in sandbox workspaces.
// All endpoints validate that the provided workspace has the human-readable ID "sandbox".
service SandboxWorkspaceService {
  // Returns the list of demo workbook RIDs for the given sandbox workspace.
  // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME
  rpc GetDemoWorkbooks(GetDemoWorkbooksRequest) returns (GetDemoWorkbooksResponse) {
    option (google.api.http) = {get: "/scout/v1/sandbox-workspace/{workspace_rid}/demo-workbooks"};
  }
  // buf:lint:ignore RPC_REQUEST_STANDARD_NAME
  // Sets the list of demo workbook RIDs for the given sandbox workspace, replacing any existing entries.
  rpc SetDemoWorkbooks(SetDemoWorkbooksRequestWrapper) returns (SetDemoWorkbooksResponse) {
    option (google.api.http) = {
      body: "request"
      put: "/scout/v1/sandbox-workspace/{workspace_rid}/demo-workbooks"
    };
  }
  // buf:lint:ignore RPC_REQUEST_STANDARD_NAME
  // Appends workbooks to the existing demo workbook list. If archiveOnLabelConflict is true,
  // existing workbooks with an exact label-set match are archived along with all related
  // resources instead of raising an error. The cascade performs a full graph traversal:
  // starting from the workbook's data scope (asset RIDs or run RIDs), it alternates between
  // discovering runs linked to assets and assets linked to runs until convergence. All
  // discovered assets, runs, datasets (from both asset and run data scopes), and events
  // (from snapshot refs and from all discovered assets) are then archived. This ensures no
  // orphaned resources remain when demo workbooks are replaced. Partial (subset/superset)
  // label conflicts always raise an error.
  rpc AddDemoWorkbooks(AddDemoWorkbooksRequestWrapper) returns (AddDemoWorkbooksResponse) {
    option (google.api.http) = {
      post: "/scout/v1/sandbox-workspace/{workspace_rid}/demo-workbooks"
      body: "request"
    };
  }
}
