// Copyright 2019 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.v2beta1;

import "google/api/annotations.proto";
import "google/api/resource.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";

option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Dialogflow.V2beta1";
option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/v2beta1;dialogflow";
option java_multiple_files = true;
option java_outer_classname = "KnowledgeBaseProto";
option java_package = "com.google.cloud.dialogflow.v2beta1";
option objc_class_prefix = "DF";

// Manages knowledge bases.
//
// Allows users to setup and maintain knowledge bases with their knowledge data.
service KnowledgeBases {
  // Returns the list of all knowledge bases of the specified agent.
  rpc ListKnowledgeBases(ListKnowledgeBasesRequest) returns (ListKnowledgeBasesResponse) {
    option (google.api.http) = {
      get: "/v2beta1/{parent=projects/*}/knowledgeBases"
      additional_bindings {
        get: "/v2beta1/{parent=projects/*/agent}/knowledgeBases"
      }
    };
  }

  // Retrieves the specified knowledge base.
  rpc GetKnowledgeBase(GetKnowledgeBaseRequest) returns (KnowledgeBase) {
    option (google.api.http) = {
      get: "/v2beta1/{name=projects/*/knowledgeBases/*}"
      additional_bindings {
        get: "/v2beta1/{name=projects/*/agent/knowledgeBases/*}"
      }
    };
  }

  // Creates a knowledge base.
  rpc CreateKnowledgeBase(CreateKnowledgeBaseRequest) returns (KnowledgeBase) {
    option (google.api.http) = {
      post: "/v2beta1/{parent=projects/*}/knowledgeBases"
      body: "knowledge_base"
      additional_bindings {
        post: "/v2beta1/{parent=projects/*/agent}/knowledgeBases"
        body: "knowledge_base"
      }
    };
  }

  // Deletes the specified knowledge base.
  rpc DeleteKnowledgeBase(DeleteKnowledgeBaseRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v2beta1/{name=projects/*/knowledgeBases/*}"
      additional_bindings {
        delete: "/v2beta1/{name=projects/*/agent/knowledgeBases/*}"
      }
    };
  }

  // Updates the specified knowledge base.
  rpc UpdateKnowledgeBase(UpdateKnowledgeBaseRequest) returns (KnowledgeBase) {
    option (google.api.http) = {
      patch: "/v2beta1/{knowledge_base.name=projects/*/knowledgeBases/*}"
      body: "knowledge_base"
      additional_bindings {
        patch: "/v2beta1/{knowledge_base.name=projects/*/agent/knowledgeBases/*}"
        body: "knowledge_base"
      }
    };
  }
}

// Represents knowledge base resource.
//
// Note: resource `projects.agent.knowledgeBases` is deprecated, please use
// `projects.knowledgeBases` instead.
message KnowledgeBase {
  // The knowledge base resource name.
  // The name must be empty when creating a knowledge base.
  // Format: `projects/<Project ID>/knowledgeBases/<Knowledge Base ID>`.
  string name = 1;

  // Required. The display name of the knowledge base. The name must be 1024
  // bytes or less; otherwise, the creation request fails.
  string display_name = 2;
}

// Request message for [KnowledgeBases.ListKnowledgeBases][google.cloud.dialogflow.v2beta1.KnowledgeBases.ListKnowledgeBases].
message ListKnowledgeBasesRequest {
  // Required. The project to list of knowledge bases for.
  // Format: `projects/<Project ID>`.
  string parent = 1;

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

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

// Response message for [KnowledgeBases.ListKnowledgeBases][google.cloud.dialogflow.v2beta1.KnowledgeBases.ListKnowledgeBases].
message ListKnowledgeBasesResponse {
  // The list of knowledge bases.
  repeated KnowledgeBase knowledge_bases = 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;
}

// Request message for [KnowledgeBase.GetDocument][].
message GetKnowledgeBaseRequest {
  // Required. The name of the knowledge base to retrieve.
  // Format `projects/<Project ID>/knowledgeBases/<Knowledge Base ID>`.
  string name = 1;
}

// Request message for [KnowledgeBases.CreateKnowledgeBase][google.cloud.dialogflow.v2beta1.KnowledgeBases.CreateKnowledgeBase].
message CreateKnowledgeBaseRequest {
  // Required. The project to create a knowledge base for.
  // Format: `projects/<Project ID>`.
  string parent = 1;

  // Required. The knowledge base to create.
  KnowledgeBase knowledge_base = 2;
}

// Request message for [KnowledgeBases.DeleteKnowledgeBase][google.cloud.dialogflow.v2beta1.KnowledgeBases.DeleteKnowledgeBase].
message DeleteKnowledgeBaseRequest {
  // Required. The name of the knowledge base to delete.
  // Format: `projects/<Project ID>/knowledgeBases/<Knowledge Base ID>`.
  string name = 1;

  // Optional. Force deletes the knowledge base. When set to true, any documents
  // in the knowledge base are also deleted.
  bool force = 2;
}

// Request message for [KnowledgeBases.UpdateKnowledgeBase][google.cloud.dialogflow.v2beta1.KnowledgeBases.UpdateKnowledgeBase].
message UpdateKnowledgeBaseRequest {
  // Required. The knowledge base to update.
  KnowledgeBase knowledge_base = 1;

  // Optional. Not specified means `update all`.
  // Currently, only `display_name` can be updated, an InvalidArgument will be
  // returned for attempting to update other fields.
  google.protobuf.FieldMask update_mask = 2;
}