document.proto 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.dialogflow.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/longrunning/operations.proto";
  21. import "google/protobuf/field_mask.proto";
  22. import "google/protobuf/timestamp.proto";
  23. import "google/rpc/status.proto";
  24. option cc_enable_arenas = true;
  25. option csharp_namespace = "Google.Cloud.Dialogflow.V2";
  26. option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/v2;dialogflow";
  27. option java_multiple_files = true;
  28. option java_outer_classname = "DocumentProto";
  29. option java_package = "com.google.cloud.dialogflow.v2";
  30. option objc_class_prefix = "DF";
  31. // Service for managing knowledge [Documents][google.cloud.dialogflow.v2.Document].
  32. service Documents {
  33. option (google.api.default_host) = "dialogflow.googleapis.com";
  34. option (google.api.oauth_scopes) =
  35. "https://www.googleapis.com/auth/cloud-platform,"
  36. "https://www.googleapis.com/auth/dialogflow";
  37. // Returns the list of all documents of the knowledge base.
  38. rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) {
  39. option (google.api.http) = {
  40. get: "/v2/{parent=projects/*/knowledgeBases/*}/documents"
  41. additional_bindings {
  42. get: "/v2/{parent=projects/*/locations/*/knowledgeBases/*}/documents"
  43. }
  44. additional_bindings {
  45. get: "/v2/{parent=projects/*/agent/knowledgeBases/*}/documents"
  46. }
  47. };
  48. option (google.api.method_signature) = "parent";
  49. }
  50. // Retrieves the specified document.
  51. rpc GetDocument(GetDocumentRequest) returns (Document) {
  52. option (google.api.http) = {
  53. get: "/v2/{name=projects/*/knowledgeBases/*/documents/*}"
  54. additional_bindings {
  55. get: "/v2/{name=projects/*/locations/*/knowledgeBases/*/documents/*}"
  56. }
  57. additional_bindings {
  58. get: "/v2/{name=projects/*/agent/knowledgeBases/*/documents/*}"
  59. }
  60. };
  61. option (google.api.method_signature) = "name";
  62. }
  63. // Creates a new document.
  64. //
  65. // Operation <response: [Document][google.cloud.dialogflow.v2.Document],
  66. // metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
  67. rpc CreateDocument(CreateDocumentRequest) returns (google.longrunning.Operation) {
  68. option (google.api.http) = {
  69. post: "/v2/{parent=projects/*/knowledgeBases/*}/documents"
  70. body: "document"
  71. additional_bindings {
  72. post: "/v2/{parent=projects/*/locations/*/knowledgeBases/*}/documents"
  73. body: "document"
  74. }
  75. additional_bindings {
  76. post: "/v2/{parent=projects/*/agent/knowledgeBases/*}/documents"
  77. body: "document"
  78. }
  79. };
  80. option (google.api.method_signature) = "parent,document";
  81. option (google.longrunning.operation_info) = {
  82. response_type: "Document"
  83. metadata_type: "KnowledgeOperationMetadata"
  84. };
  85. }
  86. // Deletes the specified document.
  87. //
  88. // Operation <response: [google.protobuf.Empty][google.protobuf.Empty],
  89. // metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
  90. rpc DeleteDocument(DeleteDocumentRequest) returns (google.longrunning.Operation) {
  91. option (google.api.http) = {
  92. delete: "/v2/{name=projects/*/knowledgeBases/*/documents/*}"
  93. additional_bindings {
  94. delete: "/v2/{name=projects/*/locations/*/knowledgeBases/*/documents/*}"
  95. }
  96. additional_bindings {
  97. delete: "/v2/{name=projects/*/agent/knowledgeBases/*/documents/*}"
  98. }
  99. };
  100. option (google.api.method_signature) = "name";
  101. option (google.longrunning.operation_info) = {
  102. response_type: "google.protobuf.Empty"
  103. metadata_type: "KnowledgeOperationMetadata"
  104. };
  105. }
  106. // Updates the specified document.
  107. //
  108. // Operation <response: [Document][google.cloud.dialogflow.v2.Document],
  109. // metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
  110. rpc UpdateDocument(UpdateDocumentRequest) returns (google.longrunning.Operation) {
  111. option (google.api.http) = {
  112. patch: "/v2/{document.name=projects/*/knowledgeBases/*/documents/*}"
  113. body: "document"
  114. additional_bindings {
  115. patch: "/v2/{document.name=projects/*/locations/*/knowledgeBases/*/documents/*}"
  116. body: "document"
  117. }
  118. additional_bindings {
  119. patch: "/v2/{document.name=projects/*/agent/knowledgeBases/*/documents/*}"
  120. body: "document"
  121. }
  122. };
  123. option (google.api.method_signature) = "document,update_mask";
  124. option (google.longrunning.operation_info) = {
  125. response_type: "Document"
  126. metadata_type: "KnowledgeOperationMetadata"
  127. };
  128. }
  129. // Reloads the specified document from its specified source, content_uri or
  130. // content. The previously loaded content of the document will be deleted.
  131. // Note: Even when the content of the document has not changed, there still
  132. // may be side effects because of internal implementation changes.
  133. //
  134. // Note: The `projects.agent.knowledgeBases.documents` resource is deprecated;
  135. // only use `projects.knowledgeBases.documents`.
  136. //
  137. // Operation <response: [Document][google.cloud.dialogflow.v2.Document],
  138. // metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
  139. rpc ReloadDocument(ReloadDocumentRequest) returns (google.longrunning.Operation) {
  140. option (google.api.http) = {
  141. post: "/v2/{name=projects/*/knowledgeBases/*/documents/*}:reload"
  142. body: "*"
  143. additional_bindings {
  144. post: "/v2/{name=projects/*/locations/*/knowledgeBases/*/documents/*}:reload"
  145. body: "*"
  146. }
  147. additional_bindings {
  148. post: "/v2/{name=projects/*/agent/knowledgeBases/*/documents/*}:reload"
  149. body: "*"
  150. }
  151. };
  152. option (google.api.method_signature) = "name,content_uri";
  153. option (google.longrunning.operation_info) = {
  154. response_type: "Document"
  155. metadata_type: "KnowledgeOperationMetadata"
  156. };
  157. }
  158. }
  159. // A knowledge document to be used by a [KnowledgeBase][google.cloud.dialogflow.v2.KnowledgeBase].
  160. //
  161. // For more information, see the [knowledge base
  162. // guide](https://cloud.google.com/dialogflow/docs/how/knowledge-bases).
  163. //
  164. // Note: The `projects.agent.knowledgeBases.documents` resource is deprecated;
  165. // only use `projects.knowledgeBases.documents`.
  166. message Document {
  167. option (google.api.resource) = {
  168. type: "dialogflow.googleapis.com/Document"
  169. pattern: "projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}"
  170. pattern: "projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document}"
  171. };
  172. // The status of a reload attempt.
  173. message ReloadStatus {
  174. // The time of a reload attempt.
  175. // This reload may have been triggered automatically or manually and may
  176. // not have succeeded.
  177. google.protobuf.Timestamp time = 1;
  178. // The status of a reload attempt or the initial load.
  179. google.rpc.Status status = 2;
  180. }
  181. // The knowledge type of document content.
  182. enum KnowledgeType {
  183. // The type is unspecified or arbitrary.
  184. KNOWLEDGE_TYPE_UNSPECIFIED = 0;
  185. // The document content contains question and answer pairs as either HTML or
  186. // CSV. Typical FAQ HTML formats are parsed accurately, but unusual formats
  187. // may fail to be parsed.
  188. //
  189. // CSV must have questions in the first column and answers in the second,
  190. // with no header. Because of this explicit format, they are always parsed
  191. // accurately.
  192. FAQ = 1;
  193. // Documents for which unstructured text is extracted and used for
  194. // question answering.
  195. EXTRACTIVE_QA = 2;
  196. // The entire document content as a whole can be used for query results.
  197. // Only for Contact Center Solutions on Dialogflow.
  198. ARTICLE_SUGGESTION = 3;
  199. }
  200. // Optional. The document resource name.
  201. // The name must be empty when creating a document.
  202. // Format: `projects/<Project ID>/locations/<Location
  203. // ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`.
  204. string name = 1 [(google.api.field_behavior) = OPTIONAL];
  205. // Required. The display name of the document. The name must be 1024 bytes or
  206. // less; otherwise, the creation request fails.
  207. string display_name = 2 [(google.api.field_behavior) = REQUIRED];
  208. // Required. The MIME type of this document.
  209. string mime_type = 3 [(google.api.field_behavior) = REQUIRED];
  210. // Required. The knowledge type of document content.
  211. repeated KnowledgeType knowledge_types = 4 [(google.api.field_behavior) = REQUIRED];
  212. // Required. The source of this document.
  213. oneof source {
  214. // The URI where the file content is located.
  215. //
  216. // For documents stored in Google Cloud Storage, these URIs must have
  217. // the form `gs://<bucket-name>/<object-name>`.
  218. //
  219. // NOTE: External URLs must correspond to public webpages, i.e., they must
  220. // be indexed by Google Search. In particular, URLs for showing documents in
  221. // Google Cloud Storage (i.e. the URL in your browser) are not supported.
  222. // Instead use the `gs://` format URI described above.
  223. string content_uri = 5;
  224. // The raw content of the document. This field is only permitted for
  225. // EXTRACTIVE_QA and FAQ knowledge types.
  226. bytes raw_content = 9;
  227. }
  228. // Optional. If true, we try to automatically reload the document every day
  229. // (at a time picked by the system). If false or unspecified, we don't try
  230. // to automatically reload the document.
  231. //
  232. // Currently you can only enable automatic reload for documents sourced from
  233. // a public url, see `source` field for the source types.
  234. //
  235. // Reload status can be tracked in `latest_reload_status`. If a reload
  236. // fails, we will keep the document unchanged.
  237. //
  238. // If a reload fails with internal errors, the system will try to reload the
  239. // document on the next day.
  240. // If a reload fails with non-retriable errors (e.g. PERMISION_DENIED), the
  241. // system will not try to reload the document anymore. You need to manually
  242. // reload the document successfully by calling `ReloadDocument` and clear the
  243. // errors.
  244. bool enable_auto_reload = 11 [(google.api.field_behavior) = OPTIONAL];
  245. // Output only. The time and status of the latest reload.
  246. // This reload may have been triggered automatically or manually
  247. // and may not have succeeded.
  248. ReloadStatus latest_reload_status = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  249. // Optional. Metadata for the document. The metadata supports arbitrary
  250. // key-value pairs. Suggested use cases include storing a document's title,
  251. // an external URL distinct from the document's content_uri, etc.
  252. // The max size of a `key` or a `value` of the metadata is 1024 bytes.
  253. map<string, string> metadata = 7 [(google.api.field_behavior) = OPTIONAL];
  254. }
  255. // Request message for [Documents.GetDocument][google.cloud.dialogflow.v2.Documents.GetDocument].
  256. message GetDocumentRequest {
  257. // Required. The name of the document to retrieve.
  258. // Format `projects/<Project ID>/locations/<Location
  259. // ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`.
  260. string name = 1 [
  261. (google.api.field_behavior) = REQUIRED,
  262. (google.api.resource_reference) = {
  263. type: "dialogflow.googleapis.com/Document"
  264. }
  265. ];
  266. }
  267. // Request message for [Documents.ListDocuments][google.cloud.dialogflow.v2.Documents.ListDocuments].
  268. message ListDocumentsRequest {
  269. // Required. The knowledge base to list all documents for.
  270. // Format: `projects/<Project ID>/locations/<Location
  271. // ID>/knowledgeBases/<Knowledge Base ID>`.
  272. string parent = 1 [
  273. (google.api.field_behavior) = REQUIRED,
  274. (google.api.resource_reference) = {
  275. child_type: "dialogflow.googleapis.com/Document"
  276. }
  277. ];
  278. // The maximum number of items to return in a single page. By
  279. // default 10 and at most 100.
  280. int32 page_size = 2;
  281. // The next_page_token value returned from a previous list request.
  282. string page_token = 3;
  283. }
  284. // Response message for [Documents.ListDocuments][google.cloud.dialogflow.v2.Documents.ListDocuments].
  285. message ListDocumentsResponse {
  286. // The list of documents.
  287. repeated Document documents = 1;
  288. // Token to retrieve the next page of results, or empty if there are no
  289. // more results in the list.
  290. string next_page_token = 2;
  291. }
  292. // Request message for [Documents.CreateDocument][google.cloud.dialogflow.v2.Documents.CreateDocument].
  293. message CreateDocumentRequest {
  294. // Required. The knowledge base to create a document for.
  295. // Format: `projects/<Project ID>/locations/<Location
  296. // ID>/knowledgeBases/<Knowledge Base ID>`.
  297. string parent = 1 [
  298. (google.api.field_behavior) = REQUIRED,
  299. (google.api.resource_reference) = {
  300. child_type: "dialogflow.googleapis.com/Document"
  301. }
  302. ];
  303. // Required. The document to create.
  304. Document document = 2 [(google.api.field_behavior) = REQUIRED];
  305. }
  306. // Request message for [Documents.DeleteDocument][google.cloud.dialogflow.v2.Documents.DeleteDocument].
  307. message DeleteDocumentRequest {
  308. // Required. The name of the document to delete.
  309. // Format: `projects/<Project ID>/locations/<Location
  310. // ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`.
  311. string name = 1 [
  312. (google.api.field_behavior) = REQUIRED,
  313. (google.api.resource_reference) = {
  314. type: "dialogflow.googleapis.com/Document"
  315. }
  316. ];
  317. }
  318. // Request message for [Documents.UpdateDocument][google.cloud.dialogflow.v2.Documents.UpdateDocument].
  319. message UpdateDocumentRequest {
  320. // Required. The document to update.
  321. Document document = 1 [(google.api.field_behavior) = REQUIRED];
  322. // Optional. Not specified means `update all`.
  323. // Currently, only `display_name` can be updated, an InvalidArgument will be
  324. // returned for attempting to update other fields.
  325. google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
  326. }
  327. // Request message for [Documents.ReloadDocument][google.cloud.dialogflow.v2.Documents.ReloadDocument].
  328. message ReloadDocumentRequest {
  329. // Required. The name of the document to reload.
  330. // Format: `projects/<Project ID>/locations/<Location
  331. // ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`
  332. string name = 1 [
  333. (google.api.field_behavior) = REQUIRED,
  334. (google.api.resource_reference) = {
  335. type: "dialogflow.googleapis.com/Document"
  336. }
  337. ];
  338. // The source for document reloading.
  339. // If provided, the service will load the contents from the source
  340. // and update document in the knowledge base.
  341. oneof source {
  342. // Optional. The path of gcs source file for reloading document content. For now,
  343. // only gcs uri is supported.
  344. //
  345. // For documents stored in Google Cloud Storage, these URIs must have
  346. // the form `gs://<bucket-name>/<object-name>`.
  347. string content_uri = 3 [(google.api.field_behavior) = OPTIONAL];
  348. }
  349. }
  350. // Metadata in google::longrunning::Operation for Knowledge operations.
  351. message KnowledgeOperationMetadata {
  352. // States of the operation.
  353. enum State {
  354. // State unspecified.
  355. STATE_UNSPECIFIED = 0;
  356. // The operation has been created.
  357. PENDING = 1;
  358. // The operation is currently running.
  359. RUNNING = 2;
  360. // The operation is done, either cancelled or completed.
  361. DONE = 3;
  362. }
  363. // Output only. The current state of this operation.
  364. State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  365. }