// Copyright 2023 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.aiplatform.v1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/aiplatform/v1/machine_resources.proto";
import "google/cloud/aiplatform/v1/model.proto";

option csharp_namespace = "Google.Cloud.AIPlatform.V1";
option go_package = "cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb";
option java_multiple_files = true;
option java_outer_classname = "PublisherModelProto";
option java_package = "com.google.cloud.aiplatform.v1";
option php_namespace = "Google\\Cloud\\AIPlatform\\V1";
option ruby_package = "Google::Cloud::AIPlatform::V1";

// A Model Garden Publisher Model.
message PublisherModel {
  option (google.api.resource) = {
    type: "aiplatform.googleapis.com/PublisherModel"
    pattern: "publishers/{publisher}/models/{model}"
  };

  // Reference to a resource.
  message ResourceReference {
    oneof reference {
      // The URI of the resource.
      string uri = 1;

      // The resource name of the Google Cloud resource.
      string resource_name = 2;
    }
  }

  // A named piece of documentation.
  message Documentation {
    // Required. E.g., OVERVIEW, USE CASES, DOCUMENTATION, SDK & SAMPLES, JAVA,
    // NODE.JS, etc..
    string title = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. Content of this piece of document (in Markdown format).
    string content = 2 [(google.api.field_behavior) = REQUIRED];
  }

  // Actions could take on this Publisher Model.
  message CallToAction {
    // The regional resource name or the URI. Key is region, e.g.,
    // us-central1, europe-west2, global, etc..
    message RegionalResourceReferences {
      // Required.
      map<string, ResourceReference> references = 1
          [(google.api.field_behavior) = REQUIRED];

      // Required. The title of the regional resource reference.
      string title = 2 [(google.api.field_behavior) = REQUIRED];
    }

    // Rest API docs.
    message ViewRestApi {
      // Required.
      repeated Documentation documentations = 1
          [(google.api.field_behavior) = REQUIRED];

      // Required. The title of the view rest API.
      string title = 2 [(google.api.field_behavior) = REQUIRED];
    }

    // Model metadata that is needed for UploadModel or
    // DeployModel/CreateEndpoint requests.
    message Deploy {
      // The prediction (for example, the machine) resources that the
      // DeployedModel uses.
      oneof prediction_resources {
        // A description of resources that are dedicated to the DeployedModel,
        // and that need a higher degree of manual configuration.
        DedicatedResources dedicated_resources = 5;

        // A description of resources that to large degree are decided by Vertex
        // AI, and require only a modest additional configuration.
        AutomaticResources automatic_resources = 6;

        // The resource name of the shared DeploymentResourcePool to deploy on.
        // Format:
        // `projects/{project}/locations/{location}/deploymentResourcePools/{deployment_resource_pool}`
        string shared_resources = 7;
      }

      // Optional. Default model display name.
      string model_display_name = 1 [(google.api.field_behavior) = OPTIONAL];

      // Optional. Large model reference. When this is set, model_artifact_spec
      // is not needed.
      LargeModelReference large_model_reference = 2
          [(google.api.field_behavior) = OPTIONAL];

      // Optional. The specification of the container that is to be used when
      // deploying this Model in Vertex AI. Not present for Large Models.
      ModelContainerSpec container_spec = 3
          [(google.api.field_behavior) = OPTIONAL];

      // Optional. The path to the directory containing the Model artifact and
      // any of its supporting files.
      string artifact_uri = 4 [(google.api.field_behavior) = OPTIONAL];

      // Required. The title of the regional resource reference.
      string title = 8 [(google.api.field_behavior) = REQUIRED];
    }

    // Optional. To view Rest API docs.
    ViewRestApi view_rest_api = 1 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Open notebook of the PublisherModel.
    RegionalResourceReferences open_notebook = 2
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Create application using the PublisherModel.
    RegionalResourceReferences create_application = 3
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Open fine-tuning pipeline of the PublisherModel.
    RegionalResourceReferences open_fine_tuning_pipeline = 4
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Open prompt-tuning pipeline of the PublisherModel.
    RegionalResourceReferences open_prompt_tuning_pipeline = 5
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Open Genie / Playground.
    RegionalResourceReferences open_genie = 6
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Deploy the PublisherModel to Vertex Endpoint.
    Deploy deploy = 7 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Open in Generation AI Studio.
    RegionalResourceReferences open_generation_ai_studio = 8
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Request for access.
    RegionalResourceReferences request_access = 9
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Open evaluation pipeline of the PublisherModel.
    RegionalResourceReferences open_evaluation_pipeline = 11
        [(google.api.field_behavior) = OPTIONAL];
  }

  // An enum representing the open source category of a PublisherModel.
  enum OpenSourceCategory {
    // The open source category is unspecified, which should not be used.
    OPEN_SOURCE_CATEGORY_UNSPECIFIED = 0;

    // Used to indicate the PublisherModel is not open sourced.
    PROPRIETARY = 1;

    // Used to indicate the PublisherModel is a Google-owned open source model
    // w/ Google checkpoint.
    GOOGLE_OWNED_OSS_WITH_GOOGLE_CHECKPOINT = 2;

    // Used to indicate the PublisherModel is a 3p-owned open source model w/
    // Google checkpoint.
    THIRD_PARTY_OWNED_OSS_WITH_GOOGLE_CHECKPOINT = 3;

    // Used to indicate the PublisherModel is a Google-owned pure open source
    // model.
    GOOGLE_OWNED_OSS = 4;

    // Used to indicate the PublisherModel is a 3p-owned pure open source model.
    THIRD_PARTY_OWNED_OSS = 5;
  }

  // An enum representing the launch stage of a PublisherModel.
  enum LaunchStage {
    // The model launch stage is unspecified.
    LAUNCH_STAGE_UNSPECIFIED = 0;

    // Used to indicate the PublisherModel is at Experimental launch stage.
    EXPERIMENTAL = 1;

    // Used to indicate the PublisherModel is at Private Preview launch stage.
    PRIVATE_PREVIEW = 2;

    // Used to indicate the PublisherModel is at Public Preview launch stage.
    PUBLIC_PREVIEW = 3;

    // Used to indicate the PublisherModel is at GA launch stage.
    GA = 4;
  }

  // Output only. The resource name of the PublisherModel.
  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Immutable. The version ID of the PublisherModel.
  // A new version is committed when a new model version is uploaded under an
  // existing model id. It is an auto-incrementing decimal number in string
  // representation.
  string version_id = 2 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Required. Indicates the open source category of the publisher model.
  OpenSourceCategory open_source_category = 7
      [(google.api.field_behavior) = REQUIRED];

  // Optional. Supported call-to-action options.
  CallToAction supported_actions = 19 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Additional information about the model's Frameworks.
  repeated string frameworks = 23 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Indicates the launch stage of the model.
  LaunchStage launch_stage = 29 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Output only. Immutable. Used to indicate this model has a
  // publisher model and provide the template of the publisher model resource
  // name.
  string publisher_model_template = 30 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. The schemata that describes formats of the PublisherModel's
  // predictions and explanations as given and returned via
  // [PredictionService.Predict][google.cloud.aiplatform.v1.PredictionService.Predict].
  PredictSchemata predict_schemata = 31
      [(google.api.field_behavior) = OPTIONAL];
}
