xref: /aosp_15_r20/external/googleapis/google/cloud/contentwarehouse/v1/document_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 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
15syntax = "proto3";
16
17package google.cloud.contentwarehouse.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/resource.proto";
22import "google/cloud/contentwarehouse/v1/common.proto";
23import "google/cloud/contentwarehouse/v1/document.proto";
24import "google/cloud/contentwarehouse/v1/document_service_request.proto";
25import "google/cloud/contentwarehouse/v1/histogram.proto";
26import "google/cloud/contentwarehouse/v1/rule_engine.proto";
27import "google/iam/v1/policy.proto";
28import "google/longrunning/operations.proto";
29import "google/protobuf/empty.proto";
30
31option csharp_namespace = "Google.Cloud.ContentWarehouse.V1";
32option go_package = "cloud.google.com/go/contentwarehouse/apiv1/contentwarehousepb;contentwarehousepb";
33option java_multiple_files = true;
34option java_outer_classname = "DocumentServiceProto";
35option java_package = "com.google.cloud.contentwarehouse.v1";
36option php_namespace = "Google\\Cloud\\ContentWarehouse\\V1";
37option ruby_package = "Google::Cloud::ContentWarehouse::V1";
38
39// This service lets you manage document.
40service DocumentService {
41  option (google.api.default_host) = "contentwarehouse.googleapis.com";
42  option (google.api.oauth_scopes) =
43      "https://www.googleapis.com/auth/cloud-platform";
44
45  // Creates a document.
46  rpc CreateDocument(CreateDocumentRequest) returns (CreateDocumentResponse) {
47    option (google.api.http) = {
48      post: "/v1/{parent=projects/*/locations/*}/documents"
49      body: "*"
50    };
51    option (google.api.method_signature) = "parent,document";
52  }
53
54  // Gets a document. Returns NOT_FOUND if the document does not exist.
55  rpc GetDocument(GetDocumentRequest) returns (Document) {
56    option (google.api.http) = {
57      post: "/v1/{name=projects/*/locations/*/documents/*}:get"
58      body: "*"
59      additional_bindings {
60        post: "/v1/{name=projects/*/locations/*/documents/referenceId/*}:get"
61        body: "*"
62      }
63    };
64    option (google.api.method_signature) = "name";
65  }
66
67  // Updates a document. Returns INVALID_ARGUMENT if the name of the document
68  // is non-empty and does not equal the existing name.
69  rpc UpdateDocument(UpdateDocumentRequest) returns (UpdateDocumentResponse) {
70    option (google.api.http) = {
71      patch: "/v1/{name=projects/*/locations/*/documents/*}"
72      body: "*"
73      additional_bindings {
74        patch: "/v1/{name=projects/*/locations/*/documents/referenceId/*}"
75        body: "*"
76      }
77    };
78    option (google.api.method_signature) = "name,document";
79  }
80
81  // Deletes a document. Returns NOT_FOUND if the document does not exist.
82  rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) {
83    option (google.api.http) = {
84      post: "/v1/{name=projects/*/locations/*/documents/*}:delete"
85      body: "*"
86      additional_bindings {
87        post: "/v1/{name=projects/*/locations/*/documents/referenceId/*}:delete"
88        body: "*"
89      }
90    };
91    option (google.api.method_signature) = "name";
92  }
93
94  // Searches for documents using provided
95  // [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest].
96  // This call only returns documents that the caller has permission to search
97  // against.
98  rpc SearchDocuments(SearchDocumentsRequest)
99      returns (SearchDocumentsResponse) {
100    option (google.api.http) = {
101      post: "/v1/{parent=projects/*/locations/*}/documents:search"
102      body: "*"
103    };
104    option (google.api.method_signature) = "parent";
105  }
106
107  // Lock the document so the document cannot be updated by other users.
108  rpc LockDocument(LockDocumentRequest) returns (Document) {
109    option (google.api.http) = {
110      post: "/v1/{name=projects/*/locations/*/documents/*}:lock"
111      body: "*"
112    };
113    option (google.api.method_signature) = "name";
114  }
115
116  // Gets the access control policy for a resource. Returns NOT_FOUND error if
117  // the resource does not exist. Returns an empty policy if the resource exists
118  // but does not have a policy set.
119  rpc FetchAcl(FetchAclRequest) returns (FetchAclResponse) {
120    option (google.api.http) = {
121      post: "/v1/{resource=projects/*/locations/*/documents/*}:fetchAcl"
122      body: "*"
123      additional_bindings {
124        post: "/v1/{resource=projects/*}:fetchAcl"
125        body: "*"
126      }
127    };
128    option (google.api.method_signature) = "resource";
129  }
130
131  // Sets the access control policy for a resource. Replaces any existing
132  // policy.
133  rpc SetAcl(SetAclRequest) returns (SetAclResponse) {
134    option (google.api.http) = {
135      post: "/v1/{resource=projects/*/locations/*/documents/*}:setAcl"
136      body: "*"
137      additional_bindings { post: "/v1/{resource=projects/*}:setAcl" body: "*" }
138    };
139    option (google.api.method_signature) = "resource,policy";
140  }
141}
142
143// Response message for DocumentService.CreateDocument.
144message CreateDocumentResponse {
145  // Document created after executing create request.
146  Document document = 1;
147
148  // Output from Rule Engine recording the rule evaluator and action executor's
149  // output.
150  //
151  // Refer format in: google/cloud/contentwarehouse/v1/rule_engine.proto
152  RuleEngineOutput rule_engine_output = 2;
153
154  // Additional information for the API invocation, such as the request tracking
155  // id.
156  ResponseMetadata metadata = 3;
157
158  // post-processing LROs
159  repeated google.longrunning.Operation long_running_operations = 4;
160}
161
162// Response message for DocumentService.UpdateDocument.
163message UpdateDocumentResponse {
164  // Updated document after executing update request.
165  Document document = 1;
166
167  // Output from Rule Engine recording the rule evaluator and action executor's
168  // output.
169  //
170  // Refer format in: google/cloud/contentwarehouse/v1/rule_engine.proto
171  RuleEngineOutput rule_engine_output = 2;
172
173  // Additional information for the API invocation, such as the request tracking
174  // id.
175  ResponseMetadata metadata = 3;
176}
177
178// Additional result info for the question-answering feature.
179message QAResult {
180  // A text span in the search text snippet that represents a highlighted
181  // section (answer context, highly relevant sentence, etc.).
182  message Highlight {
183    // Start index of the highlight.
184    int32 start_index = 1;
185
186    // End index of the highlight, exclusive.
187    int32 end_index = 2;
188  }
189
190  // Highlighted sections in the snippet.
191  repeated Highlight highlights = 1;
192
193  // The calibrated confidence score for this document, in the range
194  // [0., 1.]. This represents the confidence level for whether the returned
195  // document and snippet answers the user's query.
196  float confidence_score = 2;
197}
198
199// Response message for DocumentService.SearchDocuments.
200message SearchDocumentsResponse {
201  // Document entry with metadata inside
202  // [SearchDocumentsResponse][google.cloud.contentwarehouse.v1.SearchDocumentsResponse]
203  message MatchingDocument {
204    // Document that matches the specified
205    // [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest].
206    // This document only contains indexed metadata information.
207    Document document = 1;
208
209    // Contains snippets of text from the document full raw text that most
210    // closely match a search query's keywords, if available. All HTML tags in
211    // the original fields are stripped when returned in this field, and
212    // matching query keywords are enclosed in HTML bold tags.
213    //
214    // If the question-answering feature is enabled, this field will instead
215    // contain a snippet that answers the user's natural-language query. No HTML
216    // bold tags will be present, and highlights in the answer snippet can be
217    // found in
218    // [QAResult.highlights][google.cloud.contentwarehouse.v1.QAResult.highlights].
219    string search_text_snippet = 2;
220
221    // Experimental.
222    // Additional result info if the question-answering feature is enabled.
223    QAResult qa_result = 3;
224
225    // Return the 1-based page indices where those pages have one or more
226    // matched tokens.
227    repeated int64 matched_token_page_indices = 4;
228  }
229
230  // The document entities that match the specified
231  // [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest].
232  repeated MatchingDocument matching_documents = 1;
233
234  // The token that specifies the starting position of the next page of results.
235  // This field is empty if there are no more results.
236  string next_page_token = 2;
237
238  // The total number of matched documents which is available only if the client
239  // set
240  // [SearchDocumentsRequest.require_total_size][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.require_total_size]
241  // to `true` or set
242  // [SearchDocumentsRequest.total_result_size][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.total_result_size]
243  // to `ESTIMATED_SIZE` or `ACTUAL_SIZE`. Otherwise, the value will be `-1`.
244  // Typically a UI would handle this condition by displaying "of
245  // many", for example: "Displaying 10 of many".
246  int32 total_size = 3;
247
248  // Additional information for the API invocation, such as the request tracking
249  // id.
250  ResponseMetadata metadata = 4;
251
252  // The histogram results that match with the specified
253  // [SearchDocumentsRequest.histogram_queries][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.histogram_queries].
254  repeated HistogramQueryResult histogram_query_results = 6;
255
256  // Experimental.
257  // Question answer from the query against the document.
258  string question_answer = 7;
259}
260
261// Response message for DocumentService.FetchAcl.
262message FetchAclResponse {
263  // The IAM policy.
264  google.iam.v1.Policy policy = 1;
265
266  // Additional information for the API invocation, such as the request tracking
267  // id.
268  ResponseMetadata metadata = 2;
269}
270
271// Response message for DocumentService.SetAcl.
272message SetAclResponse {
273  // The policy will be attached to a resource (e.g. projecct, document).
274  google.iam.v1.Policy policy = 1;
275
276  // Additional information for the API invocation, such as the request tracking
277  // id.
278  ResponseMetadata metadata = 2;
279}
280