// Copyright 2025 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.financialservices.v1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/financialservices/v1/line_of_business.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.FinancialServices.V1";
option go_package = "cloud.google.com/go/financialservices/apiv1/financialservicespb;financialservicespb";
option java_multiple_files = true;
option java_outer_classname = "EngineVersionProto";
option java_package = "com.google.cloud.financialservices.v1";
option php_namespace = "Google\\Cloud\\FinancialServices\\V1";
option ruby_package = "Google::Cloud::FinancialServices::V1";

// EngineVersion controls which version of the engine is used to tune, train,
// and run the model.
message EngineVersion {
  option (google.api.resource) = {
    type: "financialservices.googleapis.com/EngineVersion"
    pattern: "projects/{project_num}/locations/{location}/instances/{instance}/engineVersions/{engine_version}"
  };

  // State determines the lifecycle of a version and the models/engine configs
  // trained with it.
  enum State {
    // Default state, should never be used.
    STATE_UNSPECIFIED = 0;

    // Version is available for training and inference.
    ACTIVE = 1;

    // Models using this version can still be run, but new ones cannot be
    // trained.
    LIMITED = 2;

    // Version is deprecated, listed for informational purposes only.
    DECOMMISSIONED = 3;
  }

  // Output only. Identifier. The resource name of the EngineVersion
  // format:
  // `/projects/{project_num}/locations/{location}/instances/{instance}/engineVersions/{engine_version}`
  string name = 1 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.field_behavior) = IDENTIFIER
  ];

  // Output only. The state of the version.
  State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Planned time to stop allowing training/tuning using this
  // version. Existing trained models can still be used for prediction/backtest.
  google.protobuf.Timestamp expected_limitation_start_time = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Planned time to stop supporting the version, in addition
  // to no training or tuning, models trained on this version
  // can no longer be used for prediction/backtest.
  google.protobuf.Timestamp expected_decommission_time = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The line of business (Retail/Commercial) this engine version
  // is used for.
  LineOfBusiness line_of_business = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request for retrieving a paginated list of EngineVersion resources that meet
// the specified criteria.
message ListEngineVersionsRequest {
  // Required. The parent of the EngineVersion is the Instance.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "financialservices.googleapis.com/Instance"
    }
  ];

  // Optional. The number of resources to be included in the response. The
  // response contains a next_page_token, which can be used to retrieve the next
  // page of resources.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. In case of paginated results, this is the token that was returned
  // in the previous ListEngineVersionsResponse. It should be copied here to
  // retrieve the next page of resources. Empty will give the first page of
  // ListEngineVersionsRequest, and the last page will return an empty
  // page_token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Specify a filter to narrow search results.
  // If empty or unset will default to "state!=DEPRECATED",
  // to view deprecated versions use "state:*" or any other filter.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Specify a field to use for ordering.
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// The response to a list call containing the list of engine versions.
message ListEngineVersionsResponse {
  // List of EngineVersion resources
  repeated EngineVersion engine_versions = 1;

  // This token should be passed to the next EngineVersionsRequest to retrieve
  // the next page of EngineVersions (empty indicates we are done).
  string next_page_token = 2;

  // Locations that could not be reached.
  repeated string unreachable = 3;
}

// Request for retrieving a specific EngineVersion resource.
message GetEngineVersionRequest {
  // Required. The resource name of the EngineVersion
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "financialservices.googleapis.com/EngineVersion"
    }
  ];
}
