/*
Proto contract of Scheduling API module.
This is a collection that allows for:
- Scheduling jobs
- Executing jobs on printers

Version     Date            Author      Comment
V0.1.0      08-01-2025      KdJ         Initial version
V1.0.1      14-01-2025      KdJ         Updated proto references
V1.1.0      23-06-2025      SGi         Proto refactor for CRUD operations
*/

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

package job_schedule;

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

// Service for handling jobs on printers
service JobScheduleService {
  /*
  Endpoint for sending a job to a printer
  */
  rpc SendJobToPrinter (SendJobRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/jobschedule_module/v1/send_job_to_printer"
      body: "*"
    };
  }
}

// A request for Jobs.
message SendJobRequest {
  // JobId refers to the JobTemplate.Id of the JobCompose module
  string job_template_id = 1 [(proto_options.field_attributes) = IS_GUID];
  // ConnectionId refers to the connection info from the gateway module, which holds the connector, holding the information of the actual printer connection
  string printer_connection_id = 2 [(proto_options.field_attributes) = IS_GUID];
  /*
  The binary (little-endian) sides number this image should be printed on to a maximum of 32 layers. 
  For example: when its needed to print this image on the first and second layer, you activate those entries bitwise (little endian):
  With a binary notation this means: 0000 0000 0000 0011 => decimal 3. So we store the number 3 here.
  */
  uint32 enabled_layers = 3;
  /*
  The binary (little-endian) sides number this image should be printed on to a maximum of 64. 
  For example: when its needed to print this image with the first and third product, you activate those entries bitwise (little-endian):
  With a binary notation this means: 0000 0000 0000 0101 => decimal 5. So we store the decimal number 5.
  */
  uint64 enabled_products = 4;
  /*
  The binary (little-endian) sides number of this image that shall be shown, to a maximum of 64 sides. 
  For example: when its needed to show this image with the first and third product, you activate those entries bitwise (little-endian):
  With a binary notation this means: 0000 0000 0000 0101 => decimal 5. So we store the decimal number 5.
  */
  uint32 enabled_sides = 5;
  /*
  The JobPrintMode for this job
  */
  JobPrintMode JobPrintMode = 6;
}

// The job printing modus.
message JobPrintMode {
  // The print mode for this specific job
  PrintMode PrintMode = 1;
  // When set to batch, we need an amount of prints, called the print count
  uint32 PrintCount = 2;
}

// The enum options of the type of print mode for the printer
enum PrintMode {
  // The print mode is unknown
  PRINTMODE_UNKNOWN = 0;
  // Single print mode.
  PRINTMODE_SINGLE = 1;
  // Batch print mode
  PRINTMODE_BATCH = 2;
  // Continuous print mode
  PRINTMODE_CONTINUOUS = 3;
}

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

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