/*
Proto contract for rasterization.

Version     Date            Author      Comment
V1.0.0      01-07-2025      KDJ         Initial version
*/

syntax = "proto3";

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

package rasterization;

option csharp_namespace = "Bergstein.Digi.Shared.Interfaces.PrintManager.Rasterization.Protos.V1";

// Service for parsing isi files.
service IsiParserService {
    
  /*
  Endpoint for converting an isi file to a multispectral tiff image.

  This is only accessible for Administrator accounts.

  Returns on a success:
  - the converted multispectral tiff image

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - INVALID_ARGUMENT status when the one or more isi_parser fields no not fall within the set format/limits.
  - 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 GetMultiSpectralTiff (GetMultiSpectralTiffRequest) returns (GetMultiSpectralTiffReply) {
    option (google.api.http) = {
      post: "/rasterization_module/v1/isi_parser/multi_spectral_tiff"
      body: "*"
    };
  }

  /*
  Endpoint for converting an isi file to a dictionary of tiff files per color channel.

  This is only accessible for Administrator accounts or the requesting user.

  Returns on a success:
  - A dictionary of tiff files per color channel, where the key is the color channel name and the value is the tiff file.

  Returns on a failure:
  - CANCELLED (1) status when you abort the call
  - NOT_FOUND (5) status when the requested isi_parser (ID), to fetch, was not found
  - 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 GetTiffPerColorChannelKey (GetTiffPerColorChannelKeyRequest) returns (stream GetTiffPerColorChannelKeyReply) {
    option (google.api.http) = {
      post: "/rasterization_module/v1/isi_parser/tiff_per_color_channel_key"
      body: "*"
    };
  }

  /*
  Endpoint for converting an isi file to a collection of Tiff files.

  This is only accessible for Administrator accounts.

  Returns on a success:
  - list of tiff files, where each tiff file is a single color channel tiff file.

  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 GetTiffCollectionFromIsiFileHandle (GetTiffCollectionFromIsiFileHandleRequest) returns (stream GetTiffCollectionFromIsiFileHandleReply) {
    option (google.api.http) = {
      post: "/rasterization_module/v1/isi_parser/tiff_collection_from_isi_file_handle"
      body: "*"
    };
  }
}

message GetMultiSpectralTiffRequest {
  // The name of the file.
  string file_name = 1;
  // The type of the file (extension).
  files.FileType file_type = 2;
  // The topic type of the file.
  files.TopicType topic_type = 3;
  // file data as a byte array.
  bytes file_data = 4;
}

message GetMultiSpectralTiffReply {
  TiffFile tiff_file = 1;
}

message GetTiffPerColorChannelKeyRequest {
  // The name of the file.
  string file_name = 1;
  // The type of the file (extension).
  files.FileType file_type = 2;
  // The topic type of the file.
  files.TopicType topic_type = 3;
  // file data as a byte array.
  bytes file_data = 4;
}

message GetTiffPerColorChannelKeyReply {
    TiffFile tiff_file = 1;
}

message GetTiffCollectionFromIsiFileHandleRequest {
  // The name of the file.
  string file_name = 1;
  // The type of the file (extension).
  files.FileType file_type = 2;
  // The topic type of the file.
  files.TopicType topic_type = 3;
  // file data as a byte array.
  bytes file_data = 4;
  // the filesourcehandle id
  string file_source_handle_id = 5 [(proto_options.field_attributes) = IS_GUID];
  // the colorspace
  repeated string color_channels = 6;
}

message GetTiffCollectionFromIsiFileHandleReply {  
  // The collection of tiff files.
  TiffFile tiff_file = 1;
}

message TiffFile {
  // The name of the file.
  string file_name = 1;
  // The type of the file (extension).
  files.FileType file_type = 2;
  // file data as a byte array.
  bytes file_data = 3;
  // the color channel of the tiff file
  string color_channel = 4;
}

service OnyxService {    
  /*
  Endpoint for getting all the Quicksets of Onyx.

  This is only accessible for Administrator accounts.

  Returns on a success:
  - list of registered Quicksets in Onyx

  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 ListQuickset (google.protobuf.Empty) returns (ListQuicksetReply) {
    option (google.api.http) = {
      get: "/rasterization_module/v1/onyx/quickset"
    };
  }
}

message ListQuicksetReply {
    repeated string quickset = 1;
}

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

  /*
  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: "/rasterization_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: "/rasterization_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: "/rasterization_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: "/rasterization_module/v1/health_checks"
    };
  }
}
