// Copyright 2020 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.dialogflow.cx.v3beta1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/dialogflow/cx/v3beta1/flow.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";

option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Dialogflow.Cx.V3Beta1";
option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3beta1;cx";
option java_multiple_files = true;
option java_outer_classname = "AgentProto";
option java_package = "com.google.cloud.dialogflow.cx.v3beta1";
option objc_class_prefix = "DF";

// Service for managing [Agents][google.cloud.dialogflow.cx.v3beta1.Agent].
service Agents {
  option (google.api.default_host) = "dialogflow.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform,"
      "https://www.googleapis.com/auth/dialogflow";

  // Returns the list of all agents in the specified location.
  rpc ListAgents(ListAgentsRequest) returns (ListAgentsResponse) {
    option (google.api.http) = {
      get: "/v3beta1/{parent=projects/*/locations/*}/agents"
    };
    option (google.api.method_signature) = "parent";
  }

  // Retrieves the specified agent.
  rpc GetAgent(GetAgentRequest) returns (Agent) {
    option (google.api.http) = {
      get: "/v3beta1/{name=projects/*/locations/*/agents/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates an agent in the specified location.
  rpc CreateAgent(CreateAgentRequest) returns (Agent) {
    option (google.api.http) = {
      post: "/v3beta1/{parent=projects/*/locations/*}/agents"
      body: "agent"
    };
    option (google.api.method_signature) = "parent,agent";
  }

  // Updates the specified agent.
  rpc UpdateAgent(UpdateAgentRequest) returns (Agent) {
    option (google.api.http) = {
      patch: "/v3beta1/{agent.name=projects/*/locations/*/agents/*}"
      body: "agent"
    };
    option (google.api.method_signature) = "agent,update_mask";
  }

  // Deletes the specified agent.
  rpc DeleteAgent(DeleteAgentRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v3beta1/{name=projects/*/locations/*/agents/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Exports the specified agent to a binary file.
  rpc ExportAgent(ExportAgentRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v3beta1/{name=projects/*/locations/*/agents/*}:export"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "ExportAgentResponse"
      metadata_type: "google.protobuf.Struct"
    };
  }

  // Restores the specified agent from a binary file.
  //
  // Replaces the current agent with a new one. Note that all existing resources
  // in agent (e.g. intents, entity types, flows) will be removed.
  rpc RestoreAgent(RestoreAgentRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v3beta1/{name=projects/*/locations/*/agents/*}:restore"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "google.protobuf.Struct"
    };
  }
}

// Settings related to speech recognition.
message SpeechToTextSettings {
  // Whether to use speech adaptation for speech recognition.
  bool enable_speech_adaptation = 1;
}

// Agents are best described as Natural Language Understanding (NLU) modules
// that transform user requests into actionable data. You can include agents
// in your app, product, or service to determine user intent and respond to the
// user in a natural way.
//
// After you create an agent, you can add [Intents][google.cloud.dialogflow.cx.v3beta1.Intent],
// [Entity Types][google.cloud.dialogflow.cx.v3beta1.EntityType], [Flows][google.cloud.dialogflow.cx.v3beta1.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3beta1.Fulfillment],
// [Webhooks][google.cloud.dialogflow.cx.v3beta1.Webhook], and so on to manage the conversation flows..
message Agent {
  option (google.api.resource) = {
    type: "dialogflow.googleapis.com/Agent"
    pattern: "projects/{project}/locations/{location}/agents/{agent}"
  };

  // The unique identifier of the agent.
  // Required for the [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3beta1.Agents.UpdateAgent] method. [Agents.CreateAgent][google.cloud.dialogflow.cx.v3beta1.Agents.CreateAgent]
  // populates the name automatically.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
  string name = 1;

  // Required. The human-readable name of the agent, unique within the location.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // Immutable. The default language of the agent as a language tag.
  // See [Language
  // Support](https://cloud.google.com/dialogflow/docs/reference/language)
  // for a list of the currently supported language codes.
  // This field cannot be set by the [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3beta1.Agents.UpdateAgent] method.
  string default_language_code = 3 [(google.api.field_behavior) = IMMUTABLE];

  // Required. The time zone of the agent from the [time zone
  // database](https://www.iana.org/time-zones), e.g., America/New_York,
  // Europe/Paris.
  string time_zone = 5 [(google.api.field_behavior) = REQUIRED];

  // The description of the agent. The maximum length is 500 characters. If
  // exceeded, the request is rejected.
  string description = 6;

  // The URI of the agent's avatar. Avatars are used throughout the Dialogflow
  // console and in the self-hosted [Web
  // Demo](https://cloud.google.com/dialogflow/docs/integrations/web-demo)
  // integration.
  string avatar_uri = 7;

  // Speech recognition related settings.
  SpeechToTextSettings speech_to_text_settings = 13;

  // Immutable. Name of the start flow in this agent. A start flow will be automatically
  // created when the agent is created, and can only be deleted by deleting the
  // agent.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
  // ID>/flows/<Flow ID>`.
  string start_flow = 16 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Flow"
    }
  ];

  // Indicates if stackdriver logging is enabled for the agent.
  bool enable_stackdriver_logging = 18;

  // Indicates if automatic spell correction is enabled in detect intent
  // requests.
  bool enable_spell_correction = 20;
}

// The request message for [Agents.ListAgents][google.cloud.dialogflow.cx.v3beta1.Agents.ListAgents].
message ListAgentsRequest {
  // Required. The location to list all agents for.
  // Format: `projects/<Project ID>/locations/<Location ID>`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "dialogflow.googleapis.com/Agent"
    }
  ];

  // The maximum number of items to return in a single page. By default 100 and
  // at most 1000.
  int32 page_size = 2;

  // The next_page_token value returned from a previous list request.
  string page_token = 3;
}

// The response message for [Agents.ListAgents][google.cloud.dialogflow.cx.v3beta1.Agents.ListAgents].
message ListAgentsResponse {
  // The list of agents. There will be a maximum number of items returned based
  // on the page_size field in the request.
  repeated Agent agents = 1;

  // Token to retrieve the next page of results, or empty if there are no more
  // results in the list.
  string next_page_token = 2;
}

// The request message for [Agents.GetAgent][google.cloud.dialogflow.cx.v3beta1.Agents.GetAgent].
message GetAgentRequest {
  // Required. The name of the agent.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Agent"
    }
  ];
}

// The request message for [Agents.CreateAgent][google.cloud.dialogflow.cx.v3beta1.Agents.CreateAgent].
message CreateAgentRequest {
  // Required. The location to create a agent for.
  // Format: `projects/<Project ID>/locations/<Location ID>`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "dialogflow.googleapis.com/Agent"
    }
  ];

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

// The request message for [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3beta1.Agents.UpdateAgent].
message UpdateAgentRequest {
  // Required. The agent to update.
  Agent agent = 1 [(google.api.field_behavior) = REQUIRED];

  // The mask to control which fields get updated. If the mask is not present,
  // all fields will be updated.
  google.protobuf.FieldMask update_mask = 2;
}

// The request message for [Agents.DeleteAgent][google.cloud.dialogflow.cx.v3beta1.Agents.DeleteAgent].
message DeleteAgentRequest {
  // Required. The name of the agent to delete.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Agent"
    }
  ];
}

// The request message for [Agents.ExportAgent][google.cloud.dialogflow.cx.v3beta1.Agents.ExportAgent].
message ExportAgentRequest {
  // Required. The name of the agent to export.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Agent"
    }
  ];

  // Optional. The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI to
  // export the agent to. The format of this URI must be
  // `gs://<bucket-name>/<object-name>`.
  // If left unspecified, the serialized agent is returned inline.
  string agent_uri = 2 [(google.api.field_behavior) = OPTIONAL];
}

// The response message for [Agents.ExportAgent][google.cloud.dialogflow.cx.v3beta1.Agents.ExportAgent].
message ExportAgentResponse {
  // The exported agent.
  oneof agent {
    // The URI to a file containing the exported agent. This field is populated
    // only if `agent_uri` is specified in [ExportAgentRequest][google.cloud.dialogflow.cx.v3beta1.ExportAgentRequest].
    string agent_uri = 1;

    // Uncompressed raw byte content for agent.
    bytes agent_content = 2;
  }
}

// The request message for [Agents.RestoreAgent][google.cloud.dialogflow.cx.v3beta1.Agents.RestoreAgent].
message RestoreAgentRequest {
  // Required. The name of the agent to restore into.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Agent"
    }
  ];

  // Required. The agent to restore.
  oneof agent {
    // The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI
    // to restore agent from. The format of this URI must be
    // `gs://<bucket-name>/<object-name>`.
    string agent_uri = 2;

    // Uncompressed raw byte content for agent.
    bytes agent_content = 3;
  }
}
