// 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/cmek_config_service.proto";
import "google/cloud/discoveryengine/v1beta/common.proto";
import "google/cloud/discoveryengine/v1beta/document_processing_config.proto";
import "google/cloud/discoveryengine/v1beta/schema.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 = "DataStoreProto";
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";

// DataStore captures global settings and configs at the DataStore level.
message DataStore {
  option (google.api.resource) = {
    type: "discoveryengine.googleapis.com/DataStore"
    pattern: "projects/{project}/locations/{location}/dataStores/{data_store}"
    pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}"
  };

  // Estimation of data size per data store.
  message BillingEstimation {
    // Data size for structured data in terms of bytes.
    int64 structured_data_size = 1;

    // Data size for unstructured data in terms of bytes.
    int64 unstructured_data_size = 2;

    // Data size for websites in terms of bytes.
    int64 website_data_size = 3;

    // Last updated timestamp for structured data.
    google.protobuf.Timestamp structured_data_update_time = 4;

    // Last updated timestamp for unstructured data.
    google.protobuf.Timestamp unstructured_data_update_time = 5;

    // Last updated timestamp for websites.
    google.protobuf.Timestamp website_data_update_time = 6;
  }

  // Stores information regarding the serving configurations at DataStore level.
  message ServingConfigDataStore {
    // Optional. If set true, the DataStore will not be available for serving
    // search requests.
    bool disabled_for_serving = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Stores information for federated search.
  message FederatedSearchConfig {
    // Stores information for connecting to AlloyDB.
    message AlloyDbConfig {
      // Configuration for connecting to AlloyDB.
      message AlloyDbConnectionConfig {
        // Auth mode.
        enum AuthMode {
          AUTH_MODE_UNSPECIFIED = 0;

          // Uses P4SA when VAIS talks to AlloyDB.
          AUTH_MODE_SERVICE_ACCOUNT = 1;

          // Uses EUC when VAIS talks to AlloyDB.
          AUTH_MODE_END_USER_ACCOUNT = 2;
        }

        // Required. The AlloyDB instance to connect to.
        string instance = 1 [(google.api.field_behavior) = REQUIRED];

        // Required. The AlloyDB database to connect to.
        string database = 2 [(google.api.field_behavior) = REQUIRED];

        // Required. Database user.
        //
        // If auth_mode = END_USER_ACCOUNT, it can be unset. In that case,
        // the user will be inferred on the AlloyDB side, based on the
        // authenticated user.
        string user = 3 [(google.api.field_behavior) = REQUIRED];

        // Required. Database password.
        //
        // If auth_mode = END_USER_ACCOUNT, it can be unset. In that case,
        // the password will be inferred on the AlloyDB side, based on the
        // authenticated user.
        string password = 4 [(google.api.field_behavior) = REQUIRED];

        // Optional. Auth mode.
        AuthMode auth_mode = 5 [(google.api.field_behavior) = OPTIONAL];

        // Optional. If true, enable PSVS for AlloyDB.
        bool enable_psvs = 6 [(google.api.field_behavior) = OPTIONAL];
      }

      // Configuration for AlloyDB AI Natural Language.
      message AlloyDbAiNaturalLanguageConfig {
        // Optional. AlloyDb AI NL config id, i.e. the value that was used for
        // calling `SELECT alloydb_ai_nl.g_create_configuration(...)`. Can be
        // empty.
        string nl_config_id = 1 [(google.api.field_behavior) = OPTIONAL];
      }

      // Required. Configuration for connecting to AlloyDB.
      AlloyDbConnectionConfig alloydb_connection_config = 1
          [(google.api.field_behavior) = REQUIRED];

      // Optional. Configuration for Magic.
      AlloyDbAiNaturalLanguageConfig alloydb_ai_nl_config = 2
          [(google.api.field_behavior) = OPTIONAL];

      // Optional. Fields to be returned in the search results. If empty, all
      // fields will be returned.
      repeated string returned_fields = 3
          [(google.api.field_behavior) = OPTIONAL];
    }

    // Stores information for third party applicationOAuth.
    message ThirdPartyOauthConfig {
      // Optional. The type of the application. E.g., "jira", "box", etc.
      string app_name = 1 [(google.api.field_behavior) = OPTIONAL];

      // Optional. The instance name identifying the 3P app, e.g.,
      // "vaissptbots-my". This is different from the instance_uri which is the
      // full URL of the 3P app e.g., "https://vaissptbots-my.sharepoint.com".
      string instance_name = 2 [(google.api.field_behavior) = OPTIONAL];
    }

    // Config for connecting to NotebookLM Enterprise.
    message NotebooklmConfig {
      // Required. Search config name.
      //
      // Format: projects/*/locations/global/notebookLmSearchConfigs/*
      string search_config = 1 [(google.api.field_behavior) = REQUIRED];
    }

    // Configuration for the data source this data store is connected to.
    oneof data_source_config {
      // AlloyDB config. If set, this DataStore is connected to AlloyDB.
      AlloyDbConfig alloy_db_config = 1;

      // Third Party OAuth config. If set, this DataStore is connected to a
      // third party application.
      ThirdPartyOauthConfig third_party_oauth_config = 2;

      // NotebookLM config. If set, this DataStore is connected to
      // NotebookLM Enterprise.
      NotebooklmConfig notebooklm_config = 3;
    }
  }

  // Content config of the data store.
  enum ContentConfig {
    // Default value.
    CONTENT_CONFIG_UNSPECIFIED = 0;

    // Only contains documents without any
    // [Document.content][google.cloud.discoveryengine.v1beta.Document.content].
    NO_CONTENT = 1;

    // Only contains documents with
    // [Document.content][google.cloud.discoveryengine.v1beta.Document.content].
    CONTENT_REQUIRED = 2;

    // The data store is used for public website search.
    PUBLIC_WEBSITE = 3;

    // The data store is used for workspace search. Details of workspace
    // data store are specified in the
    // [WorkspaceConfig][google.cloud.discoveryengine.v1beta.WorkspaceConfig].
    GOOGLE_WORKSPACE = 4;
  }

  // Configuration for configurable billing approach.
  enum ConfigurableBillingApproach {
    // Default value. For Spark and non-Spark non-configurable billing approach.
    CONFIGURABLE_BILLING_APPROACH_UNSPECIFIED = 0;

    // Use the subscription base + overage billing for indexing core for non
    // embedding storage.
    CONFIGURABLE_SUBSCRIPTION_INDEXING_CORE = 1;

    // Use the consumption pay-as-you-go billing for embedding storage add-on.
    CONFIGURABLE_CONSUMPTION_EMBEDDING = 2;
  }

  // Immutable. Identifier. The full resource name of the data store.
  // Format:
  // `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}`.
  //
  // This field must be a UTF-8 encoded string with a length limit of 1024
  // characters.
  string name = 1 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.field_behavior) = IDENTIFIER
  ];

  // Required. The data store display name.
  //
  // This field must be a UTF-8 encoded string with a length limit of 128
  // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Immutable. The industry vertical that the data store registers.
  IndustryVertical industry_vertical = 3
      [(google.api.field_behavior) = IMMUTABLE];

  // The solutions that the data store enrolls. Available solutions for each
  // [industry_vertical][google.cloud.discoveryengine.v1beta.DataStore.industry_vertical]:
  //
  // * `MEDIA`: `SOLUTION_TYPE_RECOMMENDATION` and `SOLUTION_TYPE_SEARCH`.
  // * `SITE_SEARCH`: `SOLUTION_TYPE_SEARCH` is automatically enrolled. Other
  //   solutions cannot be enrolled.
  repeated SolutionType solution_types = 5;

  // Output only. The id of the default
  // [Schema][google.cloud.discoveryengine.v1beta.Schema] associated to this
  // data store.
  string default_schema_id = 7 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Immutable. The content config of the data store. If this field is unset,
  // the server behavior defaults to
  // [ContentConfig.NO_CONTENT][google.cloud.discoveryengine.v1beta.DataStore.ContentConfig.NO_CONTENT].
  ContentConfig content_config = 6 [(google.api.field_behavior) = IMMUTABLE];

  // Output only. Timestamp the
  // [DataStore][google.cloud.discoveryengine.v1beta.DataStore] was created at.
  google.protobuf.Timestamp create_time = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Configuration for advanced site search.
  AdvancedSiteSearchConfig advanced_site_search_config = 12
      [(google.api.field_behavior) = OPTIONAL];

  // Language info for DataStore.
  LanguageInfo language_info = 14;

  // Optional. Configuration for Natural Language Query Understanding.
  NaturalLanguageQueryUnderstandingConfig
      natural_language_query_understanding_config = 34
      [(google.api.field_behavior) = OPTIONAL];

  // Input only. The KMS key to be used to protect this DataStore at creation
  // time.
  //
  // Must be set for requests that need to comply with CMEK Org Policy
  // protections.
  //
  // If this field is set and processed successfully, the DataStore will be
  // protected by the KMS key, as indicated in the cmek_config field.
  string kms_key_name = 32 [(google.api.field_behavior) = INPUT_ONLY];

  // Output only. CMEK-related information for the DataStore.
  CmekConfig cmek_config = 18 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Data size estimation for billing.
  BillingEstimation billing_estimation = 23
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Immutable. Whether data in the
  // [DataStore][google.cloud.discoveryengine.v1beta.DataStore] has ACL
  // information. If set to `true`, the source data must have ACL. ACL will be
  // ingested when data is ingested by
  // [DocumentService.ImportDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ImportDocuments]
  // methods.
  //
  // When ACL is enabled for the
  // [DataStore][google.cloud.discoveryengine.v1beta.DataStore],
  // [Document][google.cloud.discoveryengine.v1beta.Document] can't be accessed
  // by calling
  // [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument]
  // or
  // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments].
  //
  // Currently ACL is only supported in `GENERIC` industry vertical with
  // non-`PUBLIC_WEBSITE` content config.
  bool acl_enabled = 24 [(google.api.field_behavior) = IMMUTABLE];

  // Config to store data store type configuration for workspace data. This
  // must be set when
  // [DataStore.content_config][google.cloud.discoveryengine.v1beta.DataStore.content_config]
  // is set as
  // [DataStore.ContentConfig.GOOGLE_WORKSPACE][google.cloud.discoveryengine.v1beta.DataStore.ContentConfig.GOOGLE_WORKSPACE].
  WorkspaceConfig workspace_config = 25;

  // Configuration for Document understanding and enrichment.
  DocumentProcessingConfig document_processing_config = 27;

  // The start schema to use for this
  // [DataStore][google.cloud.discoveryengine.v1beta.DataStore] when
  // provisioning it. If unset, a default vertical specialized schema will be
  // used.
  //
  // This field is only used by
  // [CreateDataStore][google.cloud.discoveryengine.v1beta.DataStoreService.CreateDataStore]
  // API, and will be ignored if used in other APIs. This field will be omitted
  // from all API responses including
  // [CreateDataStore][google.cloud.discoveryengine.v1beta.DataStoreService.CreateDataStore]
  // API. To retrieve a schema of a
  // [DataStore][google.cloud.discoveryengine.v1beta.DataStore], use
  // [SchemaService.GetSchema][google.cloud.discoveryengine.v1beta.SchemaService.GetSchema]
  // API instead.
  //
  // The provided schema will be validated against certain rules on schema.
  // Learn more from [this
  // doc](https://cloud.google.com/generative-ai-app-builder/docs/provide-schema).
  Schema starting_schema = 28;

  // Optional. Configuration for `HEALTHCARE_FHIR` vertical.
  HealthcareFhirConfig healthcare_fhir_config = 29
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Stores serving config at DataStore level.
  ServingConfigDataStore serving_config_data_store = 30
      [(google.api.field_behavior) = OPTIONAL];

  // Immutable. The fully qualified resource name of the associated
  // [IdentityMappingStore][google.cloud.discoveryengine.v1beta.IdentityMappingStore].
  // This field can only be set for acl_enabled DataStores with `THIRD_PARTY` or
  // `GSUITE` IdP. Format:
  // `projects/{project}/locations/{location}/identityMappingStores/{identity_mapping_store}`.
  string identity_mapping_store = 31 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/IdentityMappingStore"
    }
  ];

  // Optional. If set, this DataStore is an Infobot FAQ DataStore.
  bool is_infobot_faq_data_store = 37 [(google.api.field_behavior) = OPTIONAL];

  // Optional. If set, this DataStore is a federated search DataStore.
  FederatedSearchConfig federated_search_config = 38
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Configuration for configurable billing approach. See
  ConfigurableBillingApproach configurable_billing_approach = 45
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The timestamp when configurable_billing_approach was last
  // updated.
  google.protobuf.Timestamp configurable_billing_approach_update_time = 46
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Configuration data for advance site search.
message AdvancedSiteSearchConfig {
  // If set true, initial indexing is disabled for the DataStore.
  optional bool disable_initial_index = 3;

  // If set true, automatic refresh is disabled for the DataStore.
  optional bool disable_automatic_refresh = 4;
}

// Language info for DataStore.
message LanguageInfo {
  // The language code for the DataStore.
  string language_code = 1;

  // Output only. This is the normalized form of language_code.
  // E.g.: language_code of `en-GB`, `en_GB`, `en-UK` or `en-gb`
  // will have normalized_language_code of `en-GB`.
  string normalized_language_code = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Language part of normalized_language_code.
  // E.g.: `en-US` -> `en`, `zh-Hans-HK` -> `zh`, `en` -> `en`.
  string language = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Region part of normalized_language_code, if present.
  // E.g.: `en-US` -> `US`, `zh-Hans-HK` -> `HK`, `en` -> ``.
  string region = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Configuration for Natural Language Query Understanding.
message NaturalLanguageQueryUnderstandingConfig {
  // Mode of Natural Language Query Understanding. When the
  // NaturalLanguageQueryUnderstandingConfig.Mode is ENABLED, the natural
  // language understanding capabilities will be enabled for a search request if
  // the NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition in the
  // SearchRequest is ENABLED.
  enum Mode {
    // Default value.
    MODE_UNSPECIFIED = 0;

    // Natural Language Query Understanding is disabled.
    DISABLED = 1;

    // Natural Language Query Understanding is enabled.
    ENABLED = 2;
  }

  // Mode of Natural Language Query Understanding. If this field is unset, the
  // behavior defaults to
  // [NaturalLanguageQueryUnderstandingConfig.Mode.DISABLED][google.cloud.discoveryengine.v1beta.NaturalLanguageQueryUnderstandingConfig.Mode.DISABLED].
  Mode mode = 1;
}

// Config to store data store type configuration for workspace data
message WorkspaceConfig {
  // Specifies the type of Workspace App supported by this DataStore
  enum Type {
    // Defaults to an unspecified Workspace type.
    TYPE_UNSPECIFIED = 0;

    // Workspace Data Store contains Drive data
    GOOGLE_DRIVE = 1;

    // Workspace Data Store contains Mail data
    GOOGLE_MAIL = 2;

    // Workspace Data Store contains Sites data
    GOOGLE_SITES = 3;

    // Workspace Data Store contains Calendar data
    GOOGLE_CALENDAR = 4;

    // Workspace Data Store contains Chat data
    GOOGLE_CHAT = 5;

    // Workspace Data Store contains Groups data
    GOOGLE_GROUPS = 6;

    // Workspace Data Store contains Keep data
    GOOGLE_KEEP = 7;

    // Workspace Data Store contains People data
    GOOGLE_PEOPLE = 8;
  }

  // The Google Workspace data source.
  Type type = 1;

  // Output only. Obfuscated Dasher customer ID. Derived by the server from
  // the project's GCP organization at data store creation time; any value
  // supplied in the request payload is ignored.
  string dasher_customer_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The super admin service account for the workspace that will be
  // used for access token generation. For now we only use it for Native Google
  // Drive connector data ingestion.
  string super_admin_service_account = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The super admin email address for the workspace that will be used
  // for access token generation. For now we only use it for Native Google Drive
  // connector data ingestion.
  string super_admin_email_address = 5 [(google.api.field_behavior) = OPTIONAL];
}
