/*
Proto contract for the VectorCompose manager.

Version     Date            Author      Comment
V1.0.0      16-04-2026      SGi        Initial version
*/

syntax = "proto3";

import "Interfaces/google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "Interfaces/Application/Protos/V1/bergstein.digi.moduleinfo.proto";
import "Interfaces/PrintManager/Protos/V1/bergstein.digi.printmanager.paging.proto";

package vectorcomposemanager;

option csharp_namespace = "Bergstein.Digi.Shared.Interfaces.PrintManager.VectorCompose.Manager.Protos.V2";

// Service for Vector Compose manager instance.
service VectorComposeManager {
  /*
  Endpoint for starting a new VectorCompose Worker instance.
  The manager instance id should be provided through the header `manager-id`

  Returns on a success:
  - the id of the started worker instance

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  */
  rpc StartWorker (StartWorkerRequest) returns (StartWorkerReply) {
    option (google.api.http) = {
      post: "/vectorcomposemanager_module/v1/start_worker"
      body: "*"
    };
  }

  /*
  Endpoint for stopping an existing VectorCompose Worker instance.
  The manager instance id should be provided through the header `manager-id`
  The worker instance id should be provided through the header `worker-id`

  Returns on a success:
  - bool indicating if the worker stopped successfully

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  */
  rpc StopWorker (StopWorkerRequest) returns (StopWorkerReply) {
    option (google.api.http) = {
      post: "/vectorcomposemanager_module/v1/stop_worker"
      body: "*"
    };
  }

  /*
  Endpoint for getting all the worker instances in the system.

  This is only accessible for Administrator accounts.

  Returns on a success:
  - list of running worker instances

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - PERMISSION_DENIED (7) status when you do not have the right role
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  - UNAUTHENTICATED (16) status when you do not provide the required access token
  */
  rpc ListWorker (ListWorkerRequest) returns (ListWorkerReply) {
    option (google.api.http) = {
      get: "/vectorcomposemanager_module/v1/worker"
    };
  }

  /*
  Endpoint for listing files from a specific VectorCompose Worker instance.
  The manager instance id should be provided through the header `manager-id`
  The worker instance id should be provided through the header `worker-id`

  Returns on a success:
  - list of strings containing the full path of files (e.g. "./folderA/subFolder/file.vc.svg"

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  */
  rpc ListFile (ListFileRequest) returns (ListFileReply) {
    option (google.api.http) = {
      post: "/vectorcomposemanager_module/v1/list_file"
      body: "*"
    };
  }
}

// The StartWorkerRequest message.
message StartWorkerRequest {
  string svg_url = 1;
}

// The StartWorkerReply message.
message StartWorkerReply {
  bool success = 1;
  string reference_id = 2;
}

// The StopWorkerRequest message.
message StopWorkerRequest {
 // currently empty
}

// The StopWorkerReply message.
message StopWorkerReply {
  bool success = 1;
}

// A request for listing Worker instances.
message ListWorkerRequest {
  shared.PagingRequest paging = 1;
  bool descending = 2;
  string filter = 4;
}

// The list Worker Instances Reply.
message ListWorkerReply {
  // The collection of worker instances.
  repeated WorkerInfo workers = 1;
  shared.PagingReply paging = 2;
}

message WorkerInfo {
  string reference_id = 1;
  google.protobuf.Timestamp created_date_time_utc = 2;
}

// A request for listing files for a Worker instance.
message ListFileRequest {
  FileCategory file_category = 1;
}

// The list files Reply.
message ListFileReply {
  // The collection of worker instances.
  repeated string files = 1;
}

enum FileCategory {
  FILE_CATEGORY_UNKNOWN = 0;
  FILE_CATEGORY_INPUT = 1;
  FILE_CATEGORY_OUTPUT = 2;
}

// Service for reading info about the module configurations
service VectorComposeModuleInfoService {

  /*
  Endpoint for getting info about the this module.

  Returns on a success:
  - Info about this module

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  */
  rpc GetModuleInfo (google.protobuf.Empty) returns (module_info.ModuleInfoReply) {
    option (google.api.http) = {
      get: "/vectorcompose_module/v1/module_info"
    };
  }

  /*
  Endpoint for getting the Feature Flag values of this module.

  Returns on a success:
  - list with the Feature Flags and their values.

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  */
  rpc GetFeatureFlags (google.protobuf.Empty) returns (module_info.FeatureFlagsReply) {
    option (google.api.http) = {
      get: "/vectorcompose_module/v1/feature_flags"
    };
  }

  /*
  Endpoint for getting the Release Notes of this module.

  Returns on a success:
  - the release notes

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  */
  rpc GetReleaseNotes (google.protobuf.Empty) returns (module_info.ReleaseNotesReply) {
    option (google.api.http) = {
      get: "/vectorcompose_module/v1/release_notes"
    };
  }  

  /*
  Endpoint for getting the Health Checks for this module.

  Returns on a success:
  - a list with healthchecks and their respective status.

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INTERNAL (13) status when something went wrong on the server (please contact your administrator in this case)
  */
  rpc GetHealthChecks (google.protobuf.Empty) returns (module_info.HealthChecksReply) {
    option (google.api.http) = {
      get: "/vectorcompose_module/v1/health_checks"
    };
  }
}

