// 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.discoveryengine.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/discoveryengine/v1/identity_mapping_store.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";

option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1";
option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb";
option java_multiple_files = true;
option java_outer_classname = "IdentityMappingStoreServiceProto";
option java_package = "com.google.cloud.discoveryengine.v1";
option objc_class_prefix = "DISCOVERYENGINE";
option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1";
option ruby_package = "Google::Cloud::DiscoveryEngine::V1";

// Service for managing Identity Mapping Stores.
service IdentityMappingStoreService {
  option (google.api.default_host) = "discoveryengine.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Creates a new Identity Mapping Store.
  rpc CreateIdentityMappingStore(CreateIdentityMappingStoreRequest)
      returns (IdentityMappingStore) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/identityMappingStores"
      body: "identity_mapping_store"
    };
    option (google.api.method_signature) =
        "parent,identity_mapping_store,identity_mapping_store_id";
  }

  // Gets the Identity Mapping Store.
  rpc GetIdentityMappingStore(GetIdentityMappingStoreRequest)
      returns (IdentityMappingStore) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/identityMappingStores/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Deletes the Identity Mapping Store.
  rpc DeleteIdentityMappingStore(DeleteIdentityMappingStoreRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/identityMappingStores/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "google.cloud.discoveryengine.v1.DeleteIdentityMappingStoreMetadata"
    };
  }

  // Imports a list of Identity Mapping Entries to an Identity Mapping Store.
  rpc ImportIdentityMappings(ImportIdentityMappingsRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{identity_mapping_store=projects/*/locations/*/identityMappingStores/*}:importIdentityMappings"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "google.cloud.discoveryengine.v1.ImportIdentityMappingsResponse"
      metadata_type: "google.cloud.discoveryengine.v1.IdentityMappingEntryOperationMetadata"
    };
  }

  // Purges specified or all Identity Mapping Entries from an Identity Mapping
  // Store.
  rpc PurgeIdentityMappings(PurgeIdentityMappingsRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{identity_mapping_store=projects/*/locations/*/identityMappingStores/*}:purgeIdentityMappings"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "google.cloud.discoveryengine.v1.IdentityMappingEntryOperationMetadata"
    };
  }

  // Lists Identity Mappings in an Identity Mapping Store.
  rpc ListIdentityMappings(ListIdentityMappingsRequest)
      returns (ListIdentityMappingsResponse) {
    option (google.api.http) = {
      get: "/v1/{identity_mapping_store=projects/*/locations/*/identityMappingStores/*}:listIdentityMappings"
    };
  }

  // Lists all Identity Mapping Stores.
  rpc ListIdentityMappingStores(ListIdentityMappingStoresRequest)
      returns (ListIdentityMappingStoresResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/identityMappingStores"
    };
    option (google.api.method_signature) = "parent";
  }
}

// Request message for
// [IdentityMappingStoreService.CreateIdentityMappingStore][google.cloud.discoveryengine.v1.IdentityMappingStoreService.CreateIdentityMappingStore]
message CreateIdentityMappingStoreRequest {
  // CMEK options for the Identity Mapping Store. Setting this field will
  // override the default CmekConfig if one is set for the project.
  oneof cmek_options {
    // Resource name of the CmekConfig to use for protecting this Identity
    // Mapping Store.
    string cmek_config_name = 5 [(google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/CmekConfig"
    }];

    // Identity Mapping Store without CMEK protections. If a default CmekConfig
    // is set for the project, setting this field will override the default
    // CmekConfig as well.
    bool disable_cmek = 6;
  }

  // Required. The parent collection resource name, such as
  // `projects/{project}/locations/{location}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Location"
    }
  ];

  // Required. The ID of the Identity Mapping Store to create.
  //
  // The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores
  // (_), and hyphens (-). The maximum length is 63 characters.
  string identity_mapping_store_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The Identity Mapping Store to create.
  IdentityMappingStore identity_mapping_store = 3
      [(google.api.field_behavior) = REQUIRED];
}

// Request message for
// [IdentityMappingStoreService.GetIdentityMappingStore][google.cloud.discoveryengine.v1.IdentityMappingStoreService.GetIdentityMappingStore]
message GetIdentityMappingStoreRequest {
  // Required. The name of the Identity Mapping Store to get.
  // Format:
  // `projects/{project}/locations/{location}/identityMappingStores/{identityMappingStore}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/IdentityMappingStore"
    }
  ];
}

// Request message for
// [IdentityMappingStoreService.DeleteIdentityMappingStore][google.cloud.discoveryengine.v1.IdentityMappingStoreService.DeleteIdentityMappingStore]
message DeleteIdentityMappingStoreRequest {
  // Required. The name of the Identity Mapping Store to delete.
  // Format:
  // `projects/{project}/locations/{location}/identityMappingStores/{identityMappingStore}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/IdentityMappingStore"
    }
  ];
}

// Request message for
// [IdentityMappingStoreService.ImportIdentityMappings][google.cloud.discoveryengine.v1.IdentityMappingStoreService.ImportIdentityMappings]
message ImportIdentityMappingsRequest {
  // The inline source to import identity mapping entries from.
  message InlineSource {
    // A maximum of 10000 entries can be imported at one time
    repeated IdentityMappingEntry identity_mapping_entries = 1;
  }

  // The source of the input.
  oneof source {
    // The inline source to import identity mapping entries from.
    InlineSource inline_source = 2;
  }

  // Required. The name of the Identity Mapping Store to import Identity Mapping
  // Entries to. Format:
  // `projects/{project}/locations/{location}/identityMappingStores/{identityMappingStore}`
  string identity_mapping_store = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/IdentityMappingStore"
    }
  ];
}

// Response message for
// [IdentityMappingStoreService.ImportIdentityMappings][google.cloud.discoveryengine.v1.IdentityMappingStoreService.ImportIdentityMappings]
message ImportIdentityMappingsResponse {
  // A sample of errors encountered while processing the request.
  repeated google.rpc.Status error_samples = 1;
}

// Request message for
// [IdentityMappingStoreService.PurgeIdentityMappings][google.cloud.discoveryengine.v1.IdentityMappingStoreService.PurgeIdentityMappings]
message PurgeIdentityMappingsRequest {
  // The inline source to purge identity mapping entries from.
  message InlineSource {
    // A maximum of 10000 entries can be purged at one time
    repeated IdentityMappingEntry identity_mapping_entries = 1;
  }

  // The source of the input.
  oneof source {
    // The inline source to purge identity mapping entries from.
    InlineSource inline_source = 2;
  }

  // Required. The name of the Identity Mapping Store to purge Identity Mapping
  // Entries from. Format:
  // `projects/{project}/locations/{location}/identityMappingStores/{identityMappingStore}`
  string identity_mapping_store = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/IdentityMappingStore"
    }
  ];

  // Filter matching identity mappings to purge.
  // The eligible field for filtering is:
  // * `update_time`: in ISO 8601 "zulu" format.
  // * `external_id`
  //
  // Examples:
  //
  // * Deleting all identity mappings updated in a time range:
  //   `update_time > "2012-04-23T18:25:43.511Z" AND update_time <
  //   "2012-04-23T18:30:43.511Z"`
  // * Deleting all identity mappings for a given external_id:
  // `external_id = "id1"`
  // * Deleting all identity mappings inside an identity mapping store:
  //   `*`
  //
  // The filtering fields are assumed to have an implicit AND.
  // Should not be used with source. An error will be thrown, if both are
  // provided.
  string filter = 3;

  // Actually performs the purge. If `force` is set to false, return the
  // expected purge count without deleting any identity mappings. This field is
  // only supported for purge with filter. For input source this field is
  // ignored and data will be purged regardless of the value of this field.
  optional bool force = 4;
}

// Request message for
// [IdentityMappingStoreService.ListIdentityMappings][google.cloud.discoveryengine.v1.IdentityMappingStoreService.ListIdentityMappings]
message ListIdentityMappingsRequest {
  // Required. The name of the Identity Mapping Store to list Identity Mapping
  // Entries in. Format:
  // `projects/{project}/locations/{location}/identityMappingStores/{identityMappingStore}`
  string identity_mapping_store = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/IdentityMappingStore"
    }
  ];

  // Maximum number of IdentityMappings to return. If unspecified, defaults
  // to 2000. The maximum allowed value is 10000. Values above 10000 will be
  // coerced to 10000.
  int32 page_size = 2;

  // A page token, received from a previous `ListIdentityMappings` call.
  // Provide this to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to
  // `ListIdentityMappings` must match the call that provided the page
  // token.
  string page_token = 3;
}

// Response message for
// [IdentityMappingStoreService.ListIdentityMappings][google.cloud.discoveryengine.v1.IdentityMappingStoreService.ListIdentityMappings]
message ListIdentityMappingsResponse {
  // The Identity Mapping Entries.
  repeated IdentityMappingEntry identity_mapping_entries = 1;

  // A token that can be sent as `page_token` to retrieve the next page. If this
  // field is omitted, there are no subsequent pages.
  string next_page_token = 2;
}

// Request message for
// [IdentityMappingStoreService.ListIdentityMappingStores][google.cloud.discoveryengine.v1.IdentityMappingStoreService.ListIdentityMappingStores]
message ListIdentityMappingStoresRequest {
  // Required. The parent of the Identity Mapping Stores to list.
  // Format:
  // `projects/{project}/locations/{location}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Location"
    }
  ];

  // Maximum number of IdentityMappingStores to return. If unspecified, defaults
  // to 100. The maximum allowed value is 1000. Values above 1000 will be
  // coerced to 1000.
  int32 page_size = 2;

  // A page token, received from a previous `ListIdentityMappingStores` call.
  // Provide this to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to
  // `ListIdentityMappingStores` must match the call that provided the page
  // token.
  string page_token = 3;
}

// Response message for
// [IdentityMappingStoreService.ListIdentityMappingStores][google.cloud.discoveryengine.v1.IdentityMappingStoreService.ListIdentityMappingStores]
message ListIdentityMappingStoresResponse {
  // The Identity Mapping Stores.
  repeated IdentityMappingStore identity_mapping_stores = 1;

  // A token that can be sent as `page_token` to retrieve the next page. If this
  // field is omitted, there are no subsequent pages.
  string next_page_token = 2;
}

// IdentityMappingEntry LongRunningOperation metadata for
// [IdentityMappingStoreService.ImportIdentityMappings][google.cloud.discoveryengine.v1.IdentityMappingStoreService.ImportIdentityMappings]
// and
// [IdentityMappingStoreService.PurgeIdentityMappings][google.cloud.discoveryengine.v1.IdentityMappingStoreService.PurgeIdentityMappings]
message IdentityMappingEntryOperationMetadata {
  // The number of IdentityMappingEntries that were successfully processed.
  int64 success_count = 1;

  // The number of IdentityMappingEntries that failed to be processed.
  int64 failure_count = 2;

  // The total number of IdentityMappingEntries that were processed.
  int64 total_count = 3;
}

// Metadata related to the progress of the
// [IdentityMappingStoreService.DeleteIdentityMappingStore][google.cloud.discoveryengine.v1.IdentityMappingStoreService.DeleteIdentityMappingStore]
// operation. This will be returned by the google.longrunning.Operation.metadata
// field.
message DeleteIdentityMappingStoreMetadata {
  // Operation create time.
  google.protobuf.Timestamp create_time = 1;

  // Operation last update time. If the operation is done, this is also the
  // finish time.
  google.protobuf.Timestamp update_time = 2;
}
