// Copyright 2024 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.contactcenterinsights.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/contactcenterinsights/v1/resources.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";

option csharp_namespace = "Google.Cloud.ContactCenterInsights.V1";
option go_package = "cloud.google.com/go/contactcenterinsights/apiv1/contactcenterinsightspb;contactcenterinsightspb";
option java_multiple_files = true;
option java_outer_classname = "ContactCenterInsightsProto";
option java_package = "com.google.cloud.contactcenterinsights.v1";
option php_namespace = "Google\\Cloud\\ContactCenterInsights\\V1";
option ruby_package = "Google::Cloud::ContactCenterInsights::V1";

// An API that lets users analyze and explore their business conversation data.
service ContactCenterInsights {
  option (google.api.default_host) = "contactcenterinsights.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Creates a conversation.
  rpc CreateConversation(CreateConversationRequest) returns (Conversation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/conversations"
      body: "conversation"
    };
    option (google.api.method_signature) =
        "parent,conversation,conversation_id";
  }

  // Create a longrunning conversation upload operation. This method differs
  // from CreateConversation by allowing audio transcription and optional DLP
  // redaction.
  rpc UploadConversation(UploadConversationRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/conversations:upload"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "Conversation"
      metadata_type: "UploadConversationMetadata"
    };
  }

  // Updates a conversation.
  rpc UpdateConversation(UpdateConversationRequest) returns (Conversation) {
    option (google.api.http) = {
      patch: "/v1/{conversation.name=projects/*/locations/*/conversations/*}"
      body: "conversation"
    };
    option (google.api.method_signature) = "conversation,update_mask";
  }

  // Gets a conversation.
  rpc GetConversation(GetConversationRequest) returns (Conversation) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/conversations/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists conversations.
  rpc ListConversations(ListConversationsRequest)
      returns (ListConversationsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/conversations"
    };
    option (google.api.method_signature) = "parent";
  }

  // Deletes a conversation.
  rpc DeleteConversation(DeleteConversationRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/conversations/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates an analysis. The long running operation is done when the analysis
  // has completed.
  rpc CreateAnalysis(CreateAnalysisRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*/conversations/*}/analyses"
      body: "analysis"
    };
    option (google.api.method_signature) = "parent,analysis";
    option (google.longrunning.operation_info) = {
      response_type: "Analysis"
      metadata_type: "CreateAnalysisOperationMetadata"
    };
  }

  // Gets an analysis.
  rpc GetAnalysis(GetAnalysisRequest) returns (Analysis) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/conversations/*/analyses/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists analyses.
  rpc ListAnalyses(ListAnalysesRequest) returns (ListAnalysesResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/conversations/*}/analyses"
    };
    option (google.api.method_signature) = "parent";
  }

  // Deletes an analysis.
  rpc DeleteAnalysis(DeleteAnalysisRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/conversations/*/analyses/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Analyzes multiple conversations in a single request.
  rpc BulkAnalyzeConversations(BulkAnalyzeConversationsRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/conversations:bulkAnalyze"
      body: "*"
    };
    option (google.api.method_signature) = "parent,filter,analysis_percentage";
    option (google.longrunning.operation_info) = {
      response_type: "BulkAnalyzeConversationsResponse"
      metadata_type: "BulkAnalyzeConversationsMetadata"
    };
  }

  // Deletes multiple conversations in a single request.
  rpc BulkDeleteConversations(BulkDeleteConversationsRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/conversations:bulkDelete"
      body: "*"
    };
    option (google.api.method_signature) = "parent,filter";
    option (google.longrunning.operation_info) = {
      response_type: "BulkDeleteConversationsResponse"
      metadata_type: "BulkDeleteConversationsMetadata"
    };
  }

  // Imports conversations and processes them according to the user's
  // configuration.
  rpc IngestConversations(IngestConversationsRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/conversations:ingest"
      body: "*"
    };
    option (google.api.method_signature) = "parent";
    option (google.longrunning.operation_info) = {
      response_type: "IngestConversationsResponse"
      metadata_type: "IngestConversationsMetadata"
    };
  }

  // Export insights data to a destination defined in the request body.
  rpc ExportInsightsData(ExportInsightsDataRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/insightsdata:export"
      body: "*"
    };
    option (google.api.method_signature) = "parent";
    option (google.longrunning.operation_info) = {
      response_type: "ExportInsightsDataResponse"
      metadata_type: "ExportInsightsDataMetadata"
    };
  }

  // Creates an issue model.
  rpc CreateIssueModel(CreateIssueModelRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/issueModels"
      body: "issue_model"
    };
    option (google.api.method_signature) = "parent,issue_model";
    option (google.longrunning.operation_info) = {
      response_type: "IssueModel"
      metadata_type: "CreateIssueModelMetadata"
    };
  }

  // Updates an issue model.
  rpc UpdateIssueModel(UpdateIssueModelRequest) returns (IssueModel) {
    option (google.api.http) = {
      patch: "/v1/{issue_model.name=projects/*/locations/*/issueModels/*}"
      body: "issue_model"
    };
    option (google.api.method_signature) = "issue_model,update_mask";
  }

  // Gets an issue model.
  rpc GetIssueModel(GetIssueModelRequest) returns (IssueModel) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/issueModels/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists issue models.
  rpc ListIssueModels(ListIssueModelsRequest)
      returns (ListIssueModelsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/issueModels"
    };
    option (google.api.method_signature) = "parent";
  }

  // Deletes an issue model.
  rpc DeleteIssueModel(DeleteIssueModelRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/issueModels/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "DeleteIssueModelMetadata"
    };
  }

  // Deploys an issue model. Returns an error if a model is already deployed.
  // An issue model can only be used in analysis after it has been deployed.
  rpc DeployIssueModel(DeployIssueModelRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/issueModels/*}:deploy"
      body: "*"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "DeployIssueModelResponse"
      metadata_type: "DeployIssueModelMetadata"
    };
  }

  // Undeploys an issue model.
  // An issue model can not be used in analysis after it has been undeployed.
  rpc UndeployIssueModel(UndeployIssueModelRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/issueModels/*}:undeploy"
      body: "*"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "UndeployIssueModelResponse"
      metadata_type: "UndeployIssueModelMetadata"
    };
  }

  // Gets an issue.
  rpc GetIssue(GetIssueRequest) returns (Issue) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/issueModels/*/issues/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists issues.
  rpc ListIssues(ListIssuesRequest) returns (ListIssuesResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/issueModels/*}/issues"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates an issue.
  rpc UpdateIssue(UpdateIssueRequest) returns (Issue) {
    option (google.api.http) = {
      patch: "/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}"
      body: "issue"
    };
    option (google.api.method_signature) = "issue,update_mask";
  }

  // Deletes an issue.
  rpc DeleteIssue(DeleteIssueRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/issueModels/*/issues/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Gets an issue model's statistics.
  rpc CalculateIssueModelStats(CalculateIssueModelStatsRequest)
      returns (CalculateIssueModelStatsResponse) {
    option (google.api.http) = {
      get: "/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats"
    };
    option (google.api.method_signature) = "issue_model";
  }

  // Creates a phrase matcher.
  rpc CreatePhraseMatcher(CreatePhraseMatcherRequest) returns (PhraseMatcher) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/phraseMatchers"
      body: "phrase_matcher"
    };
    option (google.api.method_signature) = "parent,phrase_matcher";
  }

  // Gets a phrase matcher.
  rpc GetPhraseMatcher(GetPhraseMatcherRequest) returns (PhraseMatcher) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/phraseMatchers/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists phrase matchers.
  rpc ListPhraseMatchers(ListPhraseMatchersRequest)
      returns (ListPhraseMatchersResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/phraseMatchers"
    };
    option (google.api.method_signature) = "parent";
  }

  // Deletes a phrase matcher.
  rpc DeletePhraseMatcher(DeletePhraseMatcherRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/phraseMatchers/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Updates a phrase matcher.
  rpc UpdatePhraseMatcher(UpdatePhraseMatcherRequest) returns (PhraseMatcher) {
    option (google.api.http) = {
      patch: "/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}"
      body: "phrase_matcher"
    };
    option (google.api.method_signature) = "phrase_matcher,update_mask";
  }

  // Gets conversation statistics.
  rpc CalculateStats(CalculateStatsRequest) returns (CalculateStatsResponse) {
    option (google.api.http) = {
      get: "/v1/{location=projects/*/locations/*}/conversations:calculateStats"
    };
    option (google.api.method_signature) = "location";
  }

  // Gets project-level settings.
  rpc GetSettings(GetSettingsRequest) returns (Settings) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/settings}"
    };
    option (google.api.method_signature) = "name";
  }

  // Updates project-level settings.
  rpc UpdateSettings(UpdateSettingsRequest) returns (Settings) {
    option (google.api.http) = {
      patch: "/v1/{settings.name=projects/*/locations/*/settings}"
      body: "settings"
    };
    option (google.api.method_signature) = "settings,update_mask";
  }

  // Creates a view.
  rpc CreateView(CreateViewRequest) returns (View) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/views"
      body: "view"
    };
    option (google.api.method_signature) = "parent,view";
  }

  // Gets a view.
  rpc GetView(GetViewRequest) returns (View) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/views/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists views.
  rpc ListViews(ListViewsRequest) returns (ListViewsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/views"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates a view.
  rpc UpdateView(UpdateViewRequest) returns (View) {
    option (google.api.http) = {
      patch: "/v1/{view.name=projects/*/locations/*/views/*}"
      body: "view"
    };
    option (google.api.method_signature) = "view,update_mask";
  }

  // Deletes a view.
  rpc DeleteView(DeleteViewRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/views/*}"
    };
    option (google.api.method_signature) = "name";
  }
}

// Represents the options for viewing a conversation.
enum ConversationView {
  // The conversation view is not specified.
  //
  // * Defaults to `FULL` in `GetConversationRequest`.
  // * Defaults to `BASIC` in `ListConversationsRequest`.
  CONVERSATION_VIEW_UNSPECIFIED = 0;

  // Populates all fields in the conversation.
  FULL = 2;

  // Populates all fields in the conversation except the transcript.
  BASIC = 1;
}

// The request for calculating conversation statistics.
message CalculateStatsRequest {
  // Required. The location of the conversations.
  string location = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // A filter to reduce results to a specific subset. This field is useful for
  // getting statistics about conversations with specific properties.
  string filter = 2;
}

// The response for calculating conversation statistics.
message CalculateStatsResponse {
  // A time series representing conversations over time.
  message TimeSeries {
    // A single interval in a time series.
    message Interval {
      // The start time of this interval.
      google.protobuf.Timestamp start_time = 1;

      // The number of conversations created in this interval.
      int32 conversation_count = 2;
    }

    // The duration of each interval.
    google.protobuf.Duration interval_duration = 1;

    // An ordered list of intervals from earliest to latest, where each interval
    // represents the number of conversations that transpired during the time
    // window.
    repeated Interval points = 2;
  }

  // The average duration of all conversations. The average is calculated using
  // only conversations that have a time duration.
  google.protobuf.Duration average_duration = 1;

  // The average number of turns per conversation.
  int32 average_turn_count = 2;

  // The total number of conversations.
  int32 conversation_count = 3;

  // A map associating each smart highlighter display name with its respective
  // number of matches in the set of conversations.
  map<string, int32> smart_highlighter_matches = 4;

  // A map associating each custom highlighter resource name with its respective
  // number of matches in the set of conversations.
  map<string, int32> custom_highlighter_matches = 5;

  // A map associating each issue resource name with its respective number of
  // matches in the set of conversations. Key has the format:
  // `projects/<Project-ID>/locations/<Location-ID>/issueModels/<Issue-Model-ID>/issues/<Issue-ID>`
  // Deprecated, use `issue_matches_stats` field instead.
  map<string, int32> issue_matches = 6 [deprecated = true];

  // A map associating each issue resource name with its respective number of
  // matches in the set of conversations. Key has the format:
  // `projects/<Project-ID>/locations/<Location-ID>/issueModels/<Issue-Model-ID>/issues/<Issue-ID>`
  map<string, IssueModelLabelStats.IssueStats> issue_matches_stats = 8;

  // A time series representing the count of conversations created over time
  // that match that requested filter criteria.
  TimeSeries conversation_count_time_series = 7;
}

// Metadata for a create analysis operation.
message CreateAnalysisOperationMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The Conversation that this Analysis Operation belongs to.
  string conversation = 3 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Conversation"
    }
  ];

  // Output only. The annotator selector used for the analysis (if any).
  AnnotatorSelector annotator_selector = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request to create a conversation.
message CreateConversationRequest {
  // Required. The parent resource of the conversation.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Required. The conversation resource to create.
  Conversation conversation = 2 [(google.api.field_behavior) = REQUIRED];

  // A unique ID for the new conversation. This ID will become the final
  // component of the conversation's resource name. If no ID is specified, a
  // server-generated ID will be used.
  //
  // This value should be 4-64 characters and must match the regular
  // expression `^[a-z0-9-]{4,64}$`. Valid characters are `[a-z][0-9]-`
  string conversation_id = 3;
}

// Request to upload a conversation.
message UploadConversationRequest {
  // Required. The parent resource of the conversation.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Required. The conversation resource to create.
  Conversation conversation = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. A unique ID for the new conversation. This ID will become the
  // final component of the conversation's resource name. If no ID is specified,
  // a server-generated ID will be used.
  //
  // This value should be 4-64 characters and must match the regular
  // expression `^[a-z0-9-]{4,64}$`. Valid characters are `[a-z][0-9]-`
  string conversation_id = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. DLP settings for transcript redaction. Will default to the config
  // specified in Settings.
  RedactionConfig redaction_config = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Speech-to-Text configuration. Will default to the config
  // specified in Settings.
  SpeechConfig speech_config = 11 [(google.api.field_behavior) = OPTIONAL];
}

// The metadata for an UploadConversation operation.
message UploadConversationMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The original request.
  UploadConversationRequest request = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The operation name for a successfully created analysis
  // operation, if any.
  string analysis_operation = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The redaction config applied to the uploaded conversation.
  RedactionConfig applied_redaction_config = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request to list conversations.
message ListConversationsRequest {
  // Required. The parent resource of the conversation.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // The maximum number of conversations to return in the response. A valid page
  // size ranges from 0 to 1,000 inclusive. If the page size is zero or
  // unspecified, a default page size of 100 will be chosen. Note that a call
  // might return fewer results than the requested page size.
  int32 page_size = 2;

  // The value returned by the last `ListConversationsResponse`. This value
  // indicates that this is a continuation of a prior `ListConversations` call
  // and that the system should return the next page of data.
  string page_token = 3;

  // A filter to reduce results to a specific subset. Useful for querying
  // conversations with specific properties.
  string filter = 4;

  // The level of details of the conversation. Default is `BASIC`.
  ConversationView view = 5;
}

// The response of listing conversations.
message ListConversationsResponse {
  // The conversations that match the request.
  repeated Conversation conversations = 1;

  // A token which can be sent as `page_token` to retrieve the next page. If
  // this field is set, it means there is another page available. If it is not
  // set, it means no other pages are available.
  string next_page_token = 2;
}

// The request to get a conversation.
message GetConversationRequest {
  // Required. The name of the conversation to get.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Conversation"
    }
  ];

  // The level of details of the conversation. Default is `FULL`.
  ConversationView view = 2;
}

// The request to update a conversation.
message UpdateConversationRequest {
  // Required. The new values for the conversation.
  Conversation conversation = 1 [(google.api.field_behavior) = REQUIRED];

  // The list of fields to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

// The request to delete a conversation.
message DeleteConversationRequest {
  // Required. The name of the conversation to delete.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Conversation"
    }
  ];

  // If set to true, all of this conversation's analyses will also be deleted.
  // Otherwise, the request will only succeed if the conversation has no
  // analyses.
  bool force = 2;
}

// The request to ingest conversations.
message IngestConversationsRequest {
  // Configuration for Cloud Storage bucket sources.
  message GcsSource {
    enum BucketObjectType {
      // The object type is unspecified and will default to `TRANSCRIPT`.
      BUCKET_OBJECT_TYPE_UNSPECIFIED = 0;

      // The object is a transcript.
      TRANSCRIPT = 1;

      // The object is an audio file.
      AUDIO = 2;
    }

    // Required. The Cloud Storage bucket containing source objects.
    string bucket_uri = 1 [(google.api.field_behavior) = REQUIRED];

    // Optional. Specifies the type of the objects in `bucket_uri`.
    BucketObjectType bucket_object_type = 2
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Configuration for processing transcript objects.
  message TranscriptObjectConfig {
    // Required. The medium transcript objects represent.
    Conversation.Medium medium = 1 [(google.api.field_behavior) = REQUIRED];
  }

  // Configuration that applies to all conversations.
  message ConversationConfig {
    // An opaque, user-specified string representing the human agent who handled
    // the conversations.
    string agent_id = 1;

    // Optional. Indicates which of the channels, 1 or 2, contains the agent.
    // Note that this must be set for conversations to be properly displayed and
    // analyzed.
    int32 agent_channel = 2 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Indicates which of the channels, 1 or 2, contains the agent.
    // Note that this must be set for conversations to be properly displayed and
    // analyzed.
    int32 customer_channel = 3 [(google.api.field_behavior) = OPTIONAL];
  }

  // Configuration for an external data store containing objects that will
  // be converted to conversations.
  oneof source {
    // A cloud storage bucket source. Note that any previously ingested objects
    // from the source will be skipped to avoid duplication.
    GcsSource gcs_source = 2;
  }

  // Configuration for converting individual `source` objects to conversations.
  oneof object_config {
    // Configuration for when `source` contains conversation transcripts.
    TranscriptObjectConfig transcript_object_config = 3;
  }

  // Required. The parent resource for new conversations.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Configuration that applies to all conversations.
  ConversationConfig conversation_config = 4;

  // Optional. DLP settings for transcript redaction. Optional, will default to
  // the config specified in Settings.
  RedactionConfig redaction_config = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Default Speech-to-Text configuration. Optional, will default to
  // the config specified in Settings.
  SpeechConfig speech_config = 6 [(google.api.field_behavior) = OPTIONAL];
}

// The metadata for an IngestConversations operation.
message IngestConversationsMetadata {
  // Statistics for IngestConversations operation.
  message IngestConversationsStats {
    // Output only. The number of objects processed during the ingest operation.
    int32 processed_object_count = 1
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The number of objects skipped because another conversation
    // with the same transcript uri had already been ingested.
    int32 duplicates_skipped_count = 2
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The number of new conversations added during this ingest
    // operation.
    int32 successful_ingest_count = 3
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The number of objects which were unable to be ingested due
    // to errors. The errors are populated in the partial_errors field.
    int32 failed_ingest_count = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The original request for ingest.
  IngestConversationsRequest request = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Partial errors during ingest operation that might cause the
  // operation output to be incomplete.
  repeated google.rpc.Status partial_errors = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Statistics for IngestConversations operation.
  IngestConversationsStats ingest_conversations_stats = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The response to an IngestConversations operation.
message IngestConversationsResponse {}

// The request to create an analysis.
message CreateAnalysisRequest {
  // Required. The parent resource of the analysis.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Conversation"
    }
  ];

  // Required. The analysis to create.
  Analysis analysis = 2 [(google.api.field_behavior) = REQUIRED];
}

// The request to list analyses.
message ListAnalysesRequest {
  // Required. The parent resource of the analyses.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Conversation"
    }
  ];

  // The maximum number of analyses to return in the response. If this
  // value is zero, the service will select a default size. A call might return
  // fewer objects than requested. A non-empty `next_page_token` in the response
  // indicates that more data is available.
  int32 page_size = 2;

  // The value returned by the last `ListAnalysesResponse`; indicates
  // that this is a continuation of a prior `ListAnalyses` call and
  // the system should return the next page of data.
  string page_token = 3;

  // A filter to reduce results to a specific subset. Useful for querying
  // conversations with specific properties.
  string filter = 4;
}

// The response to list analyses.
message ListAnalysesResponse {
  // The analyses that match the request.
  repeated Analysis analyses = 1;

  // A token, which 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;
}

// The request to get an analysis.
message GetAnalysisRequest {
  // Required. The name of the analysis to get.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Analysis"
    }
  ];
}

// The request to delete an analysis.
message DeleteAnalysisRequest {
  // Required. The name of the analysis to delete.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Analysis"
    }
  ];
}

// The request to analyze conversations in bulk.
message BulkAnalyzeConversationsRequest {
  // Required. The parent resource to create analyses in.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Required. Filter used to select the subset of conversations to analyze.
  string filter = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Percentage of selected conversation to analyze, between
  // [0, 100].
  float analysis_percentage = 3 [(google.api.field_behavior) = REQUIRED];

  // To select the annotators to run and the phrase matchers to use
  // (if any). If not specified, all annotators will be run.
  AnnotatorSelector annotator_selector = 8;
}

// The metadata for a bulk analyze conversations operation.
message BulkAnalyzeConversationsMetadata {
  // The time the operation was created.
  google.protobuf.Timestamp create_time = 1;

  // The time the operation finished running.
  google.protobuf.Timestamp end_time = 2;

  // The original request for bulk analyze.
  BulkAnalyzeConversationsRequest request = 3;

  // The number of requested analyses that have completed successfully so far.
  int32 completed_analyses_count = 4;

  // The number of requested analyses that have failed so far.
  int32 failed_analyses_count = 5;

  // Total number of analyses requested. Computed by the number of conversations
  // returned by `filter` multiplied by `analysis_percentage` in the request.
  int32 total_requested_analyses_count = 6;

  // Output only. Partial errors during bulk analyze operation that might cause
  // the operation output to be incomplete.
  repeated google.rpc.Status partial_errors = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The response for a bulk analyze conversations operation.
message BulkAnalyzeConversationsResponse {
  // Count of successful analyses.
  int32 successful_analysis_count = 1;

  // Count of failed analyses.
  int32 failed_analysis_count = 2;
}

// The request to delete conversations in bulk.
message BulkDeleteConversationsRequest {
  // Required. The parent resource to delete conversations from.
  // Format:
  // projects/{project}/locations/{location}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Filter used to select the subset of conversations to delete.
  string filter = 2;

  // Maximum number of conversations to delete.
  int32 max_delete_count = 3;

  // If set to true, all of this conversation's analyses will also be deleted.
  // Otherwise, the request will only succeed if the conversation has no
  // analyses.
  bool force = 4;
}

// The metadata for a bulk delete conversations operation.
message BulkDeleteConversationsMetadata {
  // The time the operation was created.
  google.protobuf.Timestamp create_time = 1;

  // The time the operation finished running.
  google.protobuf.Timestamp end_time = 2;

  // The original request for bulk delete.
  BulkDeleteConversationsRequest request = 3;

  // Partial errors during bulk delete conversations operation that might cause
  // the operation output to be incomplete.
  repeated google.rpc.Status partial_errors = 4;
}

// The response for a bulk delete conversations operation.
message BulkDeleteConversationsResponse {}

// The request to export insights.
message ExportInsightsDataRequest {
  // A BigQuery Table Reference.
  message BigQueryDestination {
    // A project ID or number. If specified, then export will attempt to
    // write data to this project instead of the resource project. Otherwise,
    // the resource project will be used.
    string project_id = 3;

    // Required. The name of the BigQuery dataset that the snapshot result
    // should be exported to. If this dataset does not exist, the export call
    // returns an INVALID_ARGUMENT error.
    string dataset = 1 [(google.api.field_behavior) = REQUIRED];

    // The BigQuery table name to which the insights data should be written.
    // If this table does not exist, the export call returns an INVALID_ARGUMENT
    // error.
    string table = 2;
  }

  // Specifies the action that occurs if the destination table already exists.
  enum WriteDisposition {
    // Write disposition is not specified. Defaults to WRITE_TRUNCATE.
    WRITE_DISPOSITION_UNSPECIFIED = 0;

    // If the table already exists, BigQuery will overwrite the table data and
    // use the schema from the load.
    WRITE_TRUNCATE = 1;

    // If the table already exists, BigQuery will append data to the table.
    WRITE_APPEND = 2;
  }

  // Exporter destination.
  oneof destination {
    // Specified if sink is a BigQuery table.
    BigQueryDestination big_query_destination = 2;
  }

  // Required. The parent resource to export data from.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // A filter to reduce results to a specific subset. Useful for exporting
  // conversations with specific properties.
  string filter = 3;

  // A fully qualified KMS key name for BigQuery tables protected by CMEK.
  // Format:
  // projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}/cryptoKeyVersions/{version}
  string kms_key = 4;

  // Options for what to do if the destination table already exists.
  WriteDisposition write_disposition = 5;
}

// Metadata for an export insights operation.
message ExportInsightsDataMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // The original request for export.
  ExportInsightsDataRequest request = 3;

  // Partial errors during export operation that might cause the operation
  // output to be incomplete.
  repeated google.rpc.Status partial_errors = 4;
}

// Response for an export insights operation.
message ExportInsightsDataResponse {}

// The request to create an issue model.
message CreateIssueModelRequest {
  // Required. The parent resource of the issue model.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Required. The issue model to create.
  IssueModel issue_model = 2 [(google.api.field_behavior) = REQUIRED];
}

// Metadata for creating an issue model.
message CreateIssueModelMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // The original request for creation.
  CreateIssueModelRequest request = 3;
}

// The request to update an issue model.
message UpdateIssueModelRequest {
  // Required. The new values for the issue model.
  IssueModel issue_model = 1 [(google.api.field_behavior) = REQUIRED];

  // The list of fields to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

// Request to list issue models.
message ListIssueModelsRequest {
  // Required. The parent resource of the issue model.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];
}

// The response of listing issue models.
message ListIssueModelsResponse {
  // The issue models that match the request.
  repeated IssueModel issue_models = 1;
}

// The request to get an issue model.
message GetIssueModelRequest {
  // Required. The name of the issue model to get.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/IssueModel"
    }
  ];
}

// The request to delete an issue model.
message DeleteIssueModelRequest {
  // Required. The name of the issue model to delete.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/IssueModel"
    }
  ];
}

// Metadata for deleting an issue model.
message DeleteIssueModelMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // The original request for deletion.
  DeleteIssueModelRequest request = 3;
}

// The request to deploy an issue model.
message DeployIssueModelRequest {
  // Required. The issue model to deploy.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/IssueModel"
    }
  ];
}

// The response to deploy an issue model.
message DeployIssueModelResponse {}

// Metadata for deploying an issue model.
message DeployIssueModelMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // The original request for deployment.
  DeployIssueModelRequest request = 3;
}

// The request to undeploy an issue model.
message UndeployIssueModelRequest {
  // Required. The issue model to undeploy.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/IssueModel"
    }
  ];
}

// The response to undeploy an issue model.
message UndeployIssueModelResponse {}

// Metadata for undeploying an issue model.
message UndeployIssueModelMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // The original request for undeployment.
  UndeployIssueModelRequest request = 3;
}

// The request to get an issue.
message GetIssueRequest {
  // Required. The name of the issue to get.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Issue"
    }
  ];
}

// Request to list issues.
message ListIssuesRequest {
  // Required. The parent resource of the issue.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/IssueModel"
    }
  ];
}

// The response of listing issues.
message ListIssuesResponse {
  // The issues that match the request.
  repeated Issue issues = 1;
}

// The request to update an issue.
message UpdateIssueRequest {
  // Required. The new values for the issue.
  Issue issue = 1 [(google.api.field_behavior) = REQUIRED];

  // The list of fields to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

// The request to delete an issue.
message DeleteIssueRequest {
  // Required. The name of the issue to delete.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Issue"
    }
  ];
}

// Request to get statistics of an issue model.
message CalculateIssueModelStatsRequest {
  // Required. The resource name of the issue model to query against.
  string issue_model = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/IssueModel"
    }
  ];
}

// Response of querying an issue model's statistics.
message CalculateIssueModelStatsResponse {
  // The latest label statistics for the queried issue model. Includes results
  // on both training data and data labeled after deployment.
  IssueModelLabelStats current_stats = 4;
}

// Request to create a phrase matcher.
message CreatePhraseMatcherRequest {
  // Required. The parent resource of the phrase matcher. Required. The location
  // to create a phrase matcher for. Format: `projects/<Project
  // ID>/locations/<Location ID>` or `projects/<Project
  // Number>/locations/<Location ID>`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Required. The phrase matcher resource to create.
  PhraseMatcher phrase_matcher = 2 [(google.api.field_behavior) = REQUIRED];
}

// Request to list phrase matchers.
message ListPhraseMatchersRequest {
  // Required. The parent resource of the phrase matcher.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // The maximum number of phrase matchers to return in the response. If this
  // value is zero, the service will select a default size. A call might return
  // fewer objects than requested. A non-empty `next_page_token` in the response
  // indicates that more data is available.
  int32 page_size = 2;

  // The value returned by the last `ListPhraseMatchersResponse`. This value
  // indicates that this is a continuation of a prior `ListPhraseMatchers` call
  // and that the system should return the next page of data.
  string page_token = 3;

  // A filter to reduce results to a specific subset. Useful for querying
  // phrase matchers with specific properties.
  string filter = 4;
}

// The response of listing phrase matchers.
message ListPhraseMatchersResponse {
  // The phrase matchers that match the request.
  repeated PhraseMatcher phrase_matchers = 1;

  // A token, which 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;
}

// The request to get a a phrase matcher.
message GetPhraseMatcherRequest {
  // Required. The name of the phrase matcher to get.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/PhraseMatcher"
    }
  ];
}

// The request to delete a phrase matcher.
message DeletePhraseMatcherRequest {
  // Required. The name of the phrase matcher to delete.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/PhraseMatcher"
    }
  ];
}

// The request to update a phrase matcher.
message UpdatePhraseMatcherRequest {
  // Required. The new values for the phrase matcher.
  PhraseMatcher phrase_matcher = 1 [(google.api.field_behavior) = REQUIRED];

  // The list of fields to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

// The request to get project-level settings.
message GetSettingsRequest {
  // Required. The name of the settings resource to get.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/Settings"
    }
  ];
}

// The request to update project-level settings.
message UpdateSettingsRequest {
  // Required. The new settings values.
  Settings settings = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The list of fields to be updated.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = REQUIRED];
}

// The request to create a view.
message CreateViewRequest {
  // Required. The parent resource of the view. Required. The location to create
  // a view for.
  // Format: `projects/<Project ID>/locations/<Location ID>` or
  // `projects/<Project Number>/locations/<Location ID>`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Required. The view resource to create.
  View view = 2 [(google.api.field_behavior) = REQUIRED];
}

// The request to get a view.
message GetViewRequest {
  // Required. The name of the view to get.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/View"
    }
  ];
}

// The request to list views.
message ListViewsRequest {
  // Required. The parent resource of the views.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // The maximum number of views to return in the response. If this
  // value is zero, the service will select a default size. A call may return
  // fewer objects than requested. A non-empty `next_page_token` in the response
  // indicates that more data is available.
  int32 page_size = 2;

  // The value returned by the last `ListViewsResponse`; indicates
  // that this is a continuation of a prior `ListViews` call and
  // the system should return the next page of data.
  string page_token = 3;
}

// The response of listing views.
message ListViewsResponse {
  // The views that match the request.
  repeated View views = 1;

  // A token, which 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;
}

// The request to update a view.
message UpdateViewRequest {
  // Required. The new view.
  View view = 1 [(google.api.field_behavior) = REQUIRED];

  // The list of fields to be updated.
  google.protobuf.FieldMask update_mask = 2;
}

// The request to delete a view.
message DeleteViewRequest {
  // Required. The name of the view to delete.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "contactcenterinsights.googleapis.com/View"
    }
  ];
}
