syntax = "proto3";

package nominal.connect.demo_apps.v1;

import "buf/validate/validate.proto";
import "google/api/annotations.proto";
import "nominal/protos/gen/v1/error.proto";

option java_multiple_files = true;
option java_package = "io.nominal.connect.demo_apps.v1";

// Checksums for every bundled demo app are calculated
// when Connect is released and stored within the Connect installation
// .tar.zst files are named with their SHA256 checksum such that
// Connect can download the correct version of demo apps easily
message GetDemoAppDownloadUrlRequest {
  string sha256_checksum = 1 [(buf.validate.field).string.pattern = "^[a-f0-9]{64}$"];
}

message GetDemoAppDownloadUrlResponse {
  string url = 1;
}

enum ConnectDemoAppsServiceError {
  CONNECT_DEMO_APPS_SERVICE_ERROR_UNSPECIFIED = 0;
  CONNECT_DEMO_APPS_SERVICE_ERROR_UNAVAILABLE_FOR_ENVIRONMENT = 1 [(nominal.gen.v1.error) = {
    code: "NOT_FOUND"
    message: "Demo apps not available for specified environment."
  }];
  CONNECT_DEMO_APPS_SERVICE_ERROR_INVALID_CHECKSUM = 2 [(nominal.gen.v1.error) = {
    code: "INVALID_ARGUMENT"
    message: "Provided checksum is not valid."
  }];
}

// Service for downloading demo Connect apps
service ConnectDemoAppsService {
  // Get a pre-signed URL for downloading a demo Connect app
  rpc GetDemoAppDownloadUrl(GetDemoAppDownloadUrlRequest) returns (GetDemoAppDownloadUrlResponse) {
    option (google.api.http) = {
      post: "/connect/v1/demo-apps/download"
      body: "*"
    };
  }
}
