// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.visualinspection.v1beta1;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.VisualInspection.V1Beta1";
option php_namespace = "Google\\Cloud\\VisualInspection\\V1beta1";
option ruby_package = "Google::Cloud::VisualInspection::V1beta1";
option go_package = "google.golang.org/genproto/googleapis/cloud/visualinspection/v1beta1;visualinspection";
option java_multiple_files = true;
option java_package = "com.google.cloud.visualinspection.v1beta1";

// A SolutionArtifact is a fixed set of Models which can be exported or
// deployed.
message SolutionArtifact {
  option (google.api.resource) = {
    type: "visualinspection.googleapis.com/SolutionArtifact"
    pattern: "projects/{project}/locations/{location}/solutions/{solution}/solutionArtifacts/{solution_artifact}"
  };

  // Export format types.
  enum ExportType {
    // Unspecified by the user.
    EXPORT_TYPE_UNSPECIFIED = 0;

    // A Docker-compatible container which runs on CPU only.
    CPU_CONTAINER = 1;

    // A Docker-compatible container which runs on GPU.
    GPU_CONTAINER = 2;

    // Packaged archive without the Docker container. It might include multiple
    // models, images, and other configuration files in one package.
    PACKAGED_ARCHIVE = 3;
  }

  oneof export_location {
    // Export location for the container. This must be specified when export
    // type is a CONTAINER type.
    GcrDestination container_export_location = 9;

    // Export location for the packaged archive in the format like
    // gs://<BUCKET_NAME>/<OBJECT_NAME>.tar.gz. This must be specified when
    // export type is PACKAGED_ARCHIVE.
    string packaged_archive_gcs_uri = 10;
  }

  // Output only. Resource name for SolutionArtifact generated by the system.
  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Timestamp when this Module was created.
  google.protobuf.Timestamp create_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. A user friendly display name for the SolutionArtifact.
  // The name can be up to 128 characters long and can consist of any UTF-8
  // characters.
  string display_name = 4 [(google.api.field_behavior) = REQUIRED];

  // A description for this SolutionArtifact.
  string description = 5;

  // The labels with user-defined metadata to organize your SolutionArtifacts.
  //
  // Label keys and values can be no longer than 64 characters
  // (Unicode codepoints), can only contain lowercase letters, numeric
  // characters, underscores and dashes. International characters are allowed.
  // Label keys must start with a letter.
  //
  // See https://goo.gl/xmQnxf for more information on and examples of labels.
  map<string, string> labels = 6;

  // A list of Models to include in the exported solution. If this field is not
  // provided in the CreateSolutionArtifactRequest, the latest Model for every
  // Module will be exported. If provided, then only these Models are exported.
  // The list of models must comprise a complete solution according to the
  // expectations set by the Solution's SolutionType.
  repeated string models = 7;

  // Required. Export type.
  ExportType export_type = 8 [(google.api.field_behavior) = REQUIRED];
}

// The GCR location where the container will be pushed.
message GcrDestination {
  // Required. Google Container Registry URI of the new image, up to
  // 2000 characters long. See
  //
  // https:
  // //cloud.google.com/container-registry/do
  // // cs/pushing-and-pulling#pushing_an_image_to_a_registry
  // Accepted forms:
  // * [HOSTNAME]/[PROJECT-ID]/[IMAGE]
  // * [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG]
  //
  // The requesting user must have permission to push images the project.
  string output_uri = 1 [(google.api.field_behavior) = REQUIRED];
}
