// Copyright 2026 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.discoveryengine.v1beta;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/discoveryengine/v1beta/logging.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta";
option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb";
option java_multiple_files = true;
option java_outer_classname = "ProjectProto";
option java_package = "com.google.cloud.discoveryengine.v1beta";
option objc_class_prefix = "DISCOVERYENGINE";
option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta";
option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta";

// Metadata and configurations for a Google Cloud project in the service.
message Project {
  option (google.api.resource) = {
    type: "discoveryengine.googleapis.com/Project"
    pattern: "projects/{project}"
  };

  // Metadata about the terms of service.
  message ServiceTerms {
    // The agreement states this terms of service.
    enum State {
      // The default value of the enum. This value is not actually used.
      STATE_UNSPECIFIED = 0;

      // The project has given consent to the terms of service.
      TERMS_ACCEPTED = 1;

      // The project is pending to review and accept the terms of service.
      TERMS_PENDING = 2;

      // The project has declined or revoked the agreement to terms of service.
      TERMS_DECLINED = 3;
    }

    // The unique identifier of this terms of service.
    // Available terms:
    //
    // * `GA_DATA_USE_TERMS`: [Terms for data
    // use](https://cloud.google.com/retail/data-use-terms). When using this as
    // `id`, the acceptable
    // [version][google.cloud.discoveryengine.v1beta.Project.ServiceTerms.version]
    // to provide is `2022-11-23`.
    string id = 1;

    // The version string of the terms of service.
    // For acceptable values, see the comments for
    // [id][google.cloud.discoveryengine.v1beta.Project.ServiceTerms.id] above.
    string version = 2;

    // Whether the project has accepted/rejected the service terms or it is
    // still pending.
    State state = 4;

    // The last time when the project agreed to the terms of service.
    google.protobuf.Timestamp accept_time = 5;

    // The last time when the project declined or revoked the agreement to terms
    // of service.
    google.protobuf.Timestamp decline_time = 6;
  }

  // Customer provided configurations.
  message CustomerProvidedConfig {
    // Configuration for NotebookLM.
    message NotebooklmConfig {
      // Configuration for customer defined Model Armor templates to be used for
      // sanitizing user prompts and LLM responses.
      message ModelArmorConfig {
        // Optional. The resource name of the Model Armor Template for
        // sanitizing user prompts. Format:
        // projects/{project}/locations/{location}/templates/{template_id}
        // If not specified, no sanitization will be applied to the user prompt.
        string user_prompt_template = 1 [
          (google.api.field_behavior) = OPTIONAL,
          (google.api.resource_reference) = {
            type: "modelarmor.googleapis.com/Template"
          }
        ];

        // Optional. The resource name of the Model Armor Template for
        // sanitizing LLM responses. Format:
        // projects/{project}/locations/{location}/templates/{template_id}
        // If not specified, no sanitization will be applied to the LLM
        // response.
        string response_template = 2 [
          (google.api.field_behavior) = OPTIONAL,
          (google.api.resource_reference) = {
            type: "modelarmor.googleapis.com/Template"
          }
        ];
      }

      // Data protection policy config for NotebookLM.
      message DataProtectionPolicy {
        // Specifies a Sensitive Data Protection
        // (https://cloud.google.com/sensitive-data-protection/docs/sensitive-data-protection-overview)
        // policy.
        message SensitiveDataProtectionPolicy {
          // Optional. The Sensitive Data Protection policy resource name.
          string policy = 1 [
            (google.api.field_behavior) = OPTIONAL,
            (google.api.resource_reference) = {
              type: "dlp.googleapis.com/ContentPolicy"
            }
          ];
        }

        // Optional. The sensitive data protection policy.
        SensitiveDataProtectionPolicy sensitive_data_protection_policy = 1
            [(google.api.field_behavior) = OPTIONAL];
      }

      // Model Armor configuration to be used for sanitizing user prompts and
      // LLM responses.
      ModelArmorConfig model_armor_config = 1;

      // Optional. Whether to disable the notebook sharing feature for the
      // project. Default to false if not specified.
      bool opt_out_notebook_sharing = 2
          [(google.api.field_behavior) = OPTIONAL];

      // Optional. Specifies the data protection policy for NotebookLM.
      DataProtectionPolicy data_protection_policy = 5
          [(google.api.field_behavior) = OPTIONAL];

      // Optional. Observability config for NotebookLM.
      ObservabilityConfig observability_config = 6
          [(google.api.field_behavior) = OPTIONAL];
    }

    // Optional. Configuration for NotebookLM settings.
    NotebooklmConfig notebooklm_config = 3
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Represents the currently effective configurable billing parameters.
  // These values are derived from the customer's subscription history stored
  // internally and reflect the thresholds actively being used for billing
  // purposes at the time of the GetProject call. This includes the start_time
  // of the subscription and may differ from the values in
  // `customer_provided_config` due to billing rules
  // (e.g., scale-downs taking effect only at the start of a new month).
  // We also include the update type to indicate the type of update performed on
  // the configurable billing configuration in the UpdateProject operation.
  message ConfigurableBillingStatus {
    // Per-model Agent Search TPM subscription status. One entry per active
    // `core_subscription.agent_search_token_subscriptions[*]` entry in the
    // customer-provided config; populated by UpdateProject and GetProject.
    //
    // The lifecycle scalars on this message (`start_time`, `terminate_time`,
    // `update_type`, `tpm_threshold_next_update_time`) are per (project,
    // model_version) — siblings of the whole-relationship `start_time` /
    // `terminate_time` / `update_type` on the enclosing
    // ConfigurableBillingStatus, but scoped to this specific Agent Search
    // TPM subscription instead of to the overall customer-configurable-
    // pricing relationship. This per-instance granularity is intentional:
    // the underlying SubV3 storage is per-(project, model_version), so
    // each model has its own activation, termination, and deferred-update
    // clock; surfacing that on the response gives customers the granularity
    // they need to manage per-model commitments independently. QPM /
    // IndexingCore differ — their storage is one row per (project,
    // location), so their lifecycle is represented only by the whole-
    // relationship scalars on ConfigurableBillingStatus.
    message AgentSearchTokenSubscriptionStatus {
      // Output only. The Gemini model version this status corresponds to.
      // Matches CoreSubscription.AgentSearchTokenSubscription.model_version (a
      // stable Gemini model version from the Gemini Enterprise Agent Platform
      // model-versions registry; see
      // https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions#gemini-models).
      string model_version = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. The currently effective TPM threshold. Reflects scale-up
      // immediately and scale-down at the next billing cycle, matching
      // `effective_search_qpm_threshold` semantics.
      int64 effective_tpm_threshold = 2
          [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. The earliest next update time for the TPM subscription
      // threshold for this (project, model_version). Populated only after a
      // successful update.
      google.protobuf.Timestamp tpm_threshold_next_update_time = 3
          [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. When this (project, model_version) Agent Search TPM
      // subscription was first activated. Set once on first activation of this
      // model version and never moved by subsequent threshold updates; on
      // termination + re-activation a new value is recorded. Does NOT move
      // the whole-relationship `start_time` on the enclosing
      // ConfigurableBillingStatus, which continues to represent the first
      // activation of the overall customer-configurable-pricing
      // relationship.
      google.protobuf.Timestamp start_time = 4
          [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. If set, the scheduled effective time at which this
      // (project, model_version) Agent Search TPM subscription will terminate.
      // Populated when the customer removes this entry from
      // `core_subscription.agent_search_token_subscriptions[*]`. Does NOT move
      // the whole-relationship `terminate_time` on the enclosing
      // ConfigurableBillingStatus, which is populated only when the entire
      // customer-configurable-pricing relationship is being torn down.
      google.protobuf.Timestamp terminate_time = 5
          [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. The type of the most recent update to this (project,
      // model_version) subscription, as performed by the most recent
      // UpdateProject call. `UPDATE_TYPE_UNSPECIFIED` indicates this
      // model_version was not touched by the most recent UpdateProject (its
      // `effective_tpm_threshold` reflects an earlier update). The
      // whole-relationship `update_type` on the enclosing
      // ConfigurableBillingStatus continues to summarize the direction of
      // the most recent update across all surfaces in the project (QPM,
      // IndexingCore, and Agent Search TPM together).
      UpdateType update_type = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
    }

    // The type of update performed on the configurable billing configuration.
    enum UpdateType {
      // Unspecified update type.
      UPDATE_TYPE_UNSPECIFIED = 0;

      // Configurable billing was created/enabled.
      CREATE = 1;

      // Configurable billing was deleted/disabled.
      DELETE = 2;

      // Subscription was scaled up (thresholds increased).
      SCALE_UP = 3;

      // Subscription was scaled down (thresholds decreased).
      SCALE_DOWN = 4;
    }

    // Optional. The currently effective Search QPM threshold in queries per
    // minute. This is the threshold against which QPM usage is compared for
    // overage calculations.
    int64 effective_search_qpm_threshold = 1
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. The currently effective Indexing Core threshold.
    // This is the threshold against which Indexing Core usage is compared
    // for overage calculations.
    int64 effective_indexing_core_threshold = 2
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. The start time of the currently active billing subscription.
    google.protobuf.Timestamp start_time = 3
        [(google.api.field_behavior) = OPTIONAL];

    // Output only. The latest terminate effective time of search qpm and
    // indexing core subscriptions.
    google.protobuf.Timestamp terminate_time = 4
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The earliest next update time for the search QPM
    // subscription threshold. This is based on the next_update_time returned by
    // the underlying Cloud Billing Subscription V3 API. This field is populated
    // only if an update QPM subscription threshold request is succeeded.
    google.protobuf.Timestamp search_qpm_threshold_next_update_time = 5
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The earliest next update time for the indexing core
    // subscription threshold. This is based on the next_update_time returned by
    // the underlying Cloud Billing Subscription V3 API. This field is populated
    // only if an update indexing core subscription threshold
    // request is succeeded.
    google.protobuf.Timestamp indexing_core_threshold_next_update_time = 6
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The type of update performed in this operation.
    // This field is populated in the response of UpdateProject.
    UpdateType update_type = 7 [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. Per-model Agent Search TPM subscription status.
    repeated AgentSearchTokenSubscriptionStatus
        agent_search_token_subscription_statuses = 8
        [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Output only. Full resource name of the project, for example
  // `projects/{project}`.
  // Note that when making requests, project number and project id are both
  // acceptable, but the server will always respond in project number.
  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when this project is created.
  google.protobuf.Timestamp create_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when this project is successfully provisioned.
  // Empty value means this project is still provisioning and is not ready for
  // use.
  google.protobuf.Timestamp provision_completion_time = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. A map of terms of services. The key is the `id` of
  // [ServiceTerms][google.cloud.discoveryengine.v1beta.Project.ServiceTerms].
  map<string, ServiceTerms> service_terms_map = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Customer provided configurations.
  CustomerProvidedConfig customer_provided_config = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The current status of the project's configurable billing.
  ConfigurableBillingStatus configurable_billing_status = 10
      [(google.api.field_behavior) = OUTPUT_ONLY];
}
