google_developers_knowledge_v1/model.rs
1// Copyright 2026 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// https://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//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21#![no_implicit_prelude]
22extern crate async_trait;
23extern crate bytes;
24extern crate gaxi;
25extern crate google_cloud_gax;
26extern crate serde;
27extern crate serde_json;
28extern crate serde_with;
29extern crate std;
30extern crate tracing;
31extern crate wkt;
32
33mod debug;
34mod deserialize;
35mod serialize;
36
37/// A Document represents a page of documentation in the Developer Knowledge
38/// corpus, like the page at
39/// <https://docs.cloud.google.com/storage/docs/creating-buckets>.
40#[derive(Clone, Default, PartialEq)]
41#[non_exhaustive]
42pub struct Document {
43 /// Identifier. Contains the resource name of the document.
44 /// Format: `documents/{uri_without_scheme}`
45 /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
46 pub name: std::string::String,
47
48 /// Output only. Provides the URI of the content, such as
49 /// `<https://docs.cloud.google.com/storage/docs/creating-buckets>`.
50 pub uri: std::string::String,
51
52 /// Output only. Contains the full content of the document in Markdown format.
53 pub content: std::string::String,
54
55 /// Output only. Provides a description of the document.
56 pub description: std::string::String,
57
58 /// Output only. Specifies the data source of the document.
59 /// Example data source: `firebase.google.com`
60 pub data_source: std::string::String,
61
62 /// Output only. Provides the title of the document.
63 pub title: std::string::String,
64
65 /// Output only. Represents the timestamp when the content or metadata of the
66 /// document was last updated.
67 pub update_time: std::option::Option<wkt::Timestamp>,
68
69 /// Output only. Specifies the
70 /// [DocumentView][google.developers.knowledge.v1.DocumentView] of the
71 /// document.
72 ///
73 /// [google.developers.knowledge.v1.DocumentView]: crate::model::DocumentView
74 pub view: crate::model::DocumentView,
75
76 /// Output only. The length of the `content` field in bytes.
77 pub content_length_bytes: i32,
78
79 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
80}
81
82impl Document {
83 /// Creates a new default instance.
84 pub fn new() -> Self {
85 std::default::Default::default()
86 }
87
88 /// Sets the value of [name][crate::model::Document::name].
89 ///
90 /// # Example
91 /// ```ignore,no_run
92 /// # use google_developers_knowledge_v1::model::Document;
93 /// # let document_id = "document_id";
94 /// let x = Document::new().set_name(format!("documents/{document_id}"));
95 /// ```
96 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
97 self.name = v.into();
98 self
99 }
100
101 /// Sets the value of [uri][crate::model::Document::uri].
102 ///
103 /// # Example
104 /// ```ignore,no_run
105 /// # use google_developers_knowledge_v1::model::Document;
106 /// let x = Document::new().set_uri("example");
107 /// ```
108 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
109 self.uri = v.into();
110 self
111 }
112
113 /// Sets the value of [content][crate::model::Document::content].
114 ///
115 /// # Example
116 /// ```ignore,no_run
117 /// # use google_developers_knowledge_v1::model::Document;
118 /// let x = Document::new().set_content("example");
119 /// ```
120 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
121 self.content = v.into();
122 self
123 }
124
125 /// Sets the value of [description][crate::model::Document::description].
126 ///
127 /// # Example
128 /// ```ignore,no_run
129 /// # use google_developers_knowledge_v1::model::Document;
130 /// let x = Document::new().set_description("example");
131 /// ```
132 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
133 self.description = v.into();
134 self
135 }
136
137 /// Sets the value of [data_source][crate::model::Document::data_source].
138 ///
139 /// # Example
140 /// ```ignore,no_run
141 /// # use google_developers_knowledge_v1::model::Document;
142 /// let x = Document::new().set_data_source("example");
143 /// ```
144 pub fn set_data_source<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
145 self.data_source = v.into();
146 self
147 }
148
149 /// Sets the value of [title][crate::model::Document::title].
150 ///
151 /// # Example
152 /// ```ignore,no_run
153 /// # use google_developers_knowledge_v1::model::Document;
154 /// let x = Document::new().set_title("example");
155 /// ```
156 pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
157 self.title = v.into();
158 self
159 }
160
161 /// Sets the value of [update_time][crate::model::Document::update_time].
162 ///
163 /// # Example
164 /// ```ignore,no_run
165 /// # use google_developers_knowledge_v1::model::Document;
166 /// use wkt::Timestamp;
167 /// let x = Document::new().set_update_time(Timestamp::default()/* use setters */);
168 /// ```
169 pub fn set_update_time<T>(mut self, v: T) -> Self
170 where
171 T: std::convert::Into<wkt::Timestamp>,
172 {
173 self.update_time = std::option::Option::Some(v.into());
174 self
175 }
176
177 /// Sets or clears the value of [update_time][crate::model::Document::update_time].
178 ///
179 /// # Example
180 /// ```ignore,no_run
181 /// # use google_developers_knowledge_v1::model::Document;
182 /// use wkt::Timestamp;
183 /// let x = Document::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
184 /// let x = Document::new().set_or_clear_update_time(None::<Timestamp>);
185 /// ```
186 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
187 where
188 T: std::convert::Into<wkt::Timestamp>,
189 {
190 self.update_time = v.map(|x| x.into());
191 self
192 }
193
194 /// Sets the value of [view][crate::model::Document::view].
195 ///
196 /// # Example
197 /// ```ignore,no_run
198 /// # use google_developers_knowledge_v1::model::Document;
199 /// use google_developers_knowledge_v1::model::DocumentView;
200 /// let x0 = Document::new().set_view(DocumentView::Basic);
201 /// let x1 = Document::new().set_view(DocumentView::Full);
202 /// let x2 = Document::new().set_view(DocumentView::Content);
203 /// ```
204 pub fn set_view<T: std::convert::Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
205 self.view = v.into();
206 self
207 }
208
209 /// Sets the value of [content_length_bytes][crate::model::Document::content_length_bytes].
210 ///
211 /// # Example
212 /// ```ignore,no_run
213 /// # use google_developers_knowledge_v1::model::Document;
214 /// let x = Document::new().set_content_length_bytes(42);
215 /// ```
216 pub fn set_content_length_bytes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
217 self.content_length_bytes = v.into();
218 self
219 }
220}
221
222impl wkt::message::Message for Document {
223 fn typename() -> &'static str {
224 "type.googleapis.com/google.developers.knowledge.v1.Document"
225 }
226}
227
228/// Request message for
229/// [DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
230///
231/// [google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks]: crate::client::DeveloperKnowledge::search_document_chunks
232#[derive(Clone, Default, PartialEq)]
233#[non_exhaustive]
234pub struct SearchDocumentChunksRequest {
235 /// Required. Provides the raw query string provided by the user, such as "How
236 /// to create a Cloud Storage bucket?". The query must not exceed 500
237 /// characters; values longer than 500 characters will result in an
238 /// `INVALID_ARGUMENT` error.
239 pub query: std::string::String,
240
241 /// Optional. Specifies the maximum number of results to return. The service
242 /// may return fewer than this value.
243 ///
244 /// If unspecified, at most 5 results will be returned.
245 ///
246 /// The maximum value is 100; values above 100 will be coerced to 100.
247 pub page_size: i32,
248
249 /// Optional. Contains a page token, received from a previous
250 /// `SearchDocumentChunks` call. Provide this to retrieve the subsequent page.
251 pub page_token: std::string::String,
252
253 /// Optional. Applies a strict filter to the search results. The expression
254 /// supports a subset of the syntax described at <https://google.aip.dev/160>.
255 ///
256 /// While `SearchDocumentChunks` returns
257 /// [DocumentChunk][google.developers.knowledge.v1.DocumentChunk]s, the filter
258 /// is applied to `DocumentChunk.document` fields.
259 ///
260 /// Supported fields for filtering:
261 ///
262 /// * `content_length_bytes` (INTEGER): The length of the `Document.content`
263 /// field in bytes.
264 /// * `data_source` (STRING): The source of the document, e.g.
265 /// `docs.cloud.google.com`. See
266 /// <https://developers.google.com/knowledge/reference/corpus-reference> for
267 /// the complete list of data sources in the corpus.
268 /// * `update_time` (TIMESTAMP): The timestamp of when the document was last
269 /// meaningfully updated. A meaningful update is one that changes document's
270 /// markdown content or metadata.
271 /// * `uri` (STRING): The document URI, e.g.
272 /// `<https://docs.cloud.google.com/bigquery/docs/tables>`.
273 ///
274 /// INTEGER fields support `=`, `<`, `<=`, `>`, and `>=` operators.
275 ///
276 /// STRING fields support `=` (equals) and `!=` (not equals) operators for
277 /// **exact match** on the whole string. Partial match, prefix match, and
278 /// regexp match are not supported.
279 ///
280 /// TIMESTAMP fields support `=`, `<`, `<=`, `>`, and `>=` operators.
281 /// Timestamps must be in RFC-3339 format, e.g., `"2025-01-01T00:00:00Z"`.
282 ///
283 /// Note: Field names must be in `snake_case` (e.g., `data_source`). Values on
284 /// the right-hand side of filtering expressions must be string literals
285 /// enclosed in double quotes (e.g., `"docs.cloud.google.com"`).
286 ///
287 /// You can combine expressions using `AND`, `OR`, and `NOT` (or `-`) logical
288 /// operators. `OR` has higher precedence than `AND`. Use parentheses for
289 /// explicit precedence grouping.
290 ///
291 /// Examples:
292 ///
293 /// * Filter by `Document.content_length_bytes`:
294 /// `content_length_bytes < 50000`
295 /// * `data_source = "docs.cloud.google.com" OR data_source =
296 /// "firebase.google.com"`
297 /// * `data_source != "firebase.google.com"`
298 /// * `update_time < "2024-01-01T00:00:00Z"`
299 /// * `update_time >= "2025-01-22T00:00:00Z" AND (data_source =
300 /// "developer.chrome.com" OR data_source = "web.dev")`
301 /// * `uri = `https://docs.cloud.google.com/release-notes``
302 ///
303 /// The `filter` string must not exceed 500 characters; values longer than 500
304 /// characters will result in an `INVALID_ARGUMENT` error.
305 ///
306 /// [google.developers.knowledge.v1.DocumentChunk]: crate::model::DocumentChunk
307 pub filter: std::string::String,
308
309 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
310}
311
312impl SearchDocumentChunksRequest {
313 /// Creates a new default instance.
314 pub fn new() -> Self {
315 std::default::Default::default()
316 }
317
318 /// Sets the value of [query][crate::model::SearchDocumentChunksRequest::query].
319 ///
320 /// # Example
321 /// ```ignore,no_run
322 /// # use google_developers_knowledge_v1::model::SearchDocumentChunksRequest;
323 /// let x = SearchDocumentChunksRequest::new().set_query("example");
324 /// ```
325 pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
326 self.query = v.into();
327 self
328 }
329
330 /// Sets the value of [page_size][crate::model::SearchDocumentChunksRequest::page_size].
331 ///
332 /// # Example
333 /// ```ignore,no_run
334 /// # use google_developers_knowledge_v1::model::SearchDocumentChunksRequest;
335 /// let x = SearchDocumentChunksRequest::new().set_page_size(42);
336 /// ```
337 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
338 self.page_size = v.into();
339 self
340 }
341
342 /// Sets the value of [page_token][crate::model::SearchDocumentChunksRequest::page_token].
343 ///
344 /// # Example
345 /// ```ignore,no_run
346 /// # use google_developers_knowledge_v1::model::SearchDocumentChunksRequest;
347 /// let x = SearchDocumentChunksRequest::new().set_page_token("example");
348 /// ```
349 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
350 self.page_token = v.into();
351 self
352 }
353
354 /// Sets the value of [filter][crate::model::SearchDocumentChunksRequest::filter].
355 ///
356 /// # Example
357 /// ```ignore,no_run
358 /// # use google_developers_knowledge_v1::model::SearchDocumentChunksRequest;
359 /// let x = SearchDocumentChunksRequest::new().set_filter("example");
360 /// ```
361 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
362 self.filter = v.into();
363 self
364 }
365}
366
367impl wkt::message::Message for SearchDocumentChunksRequest {
368 fn typename() -> &'static str {
369 "type.googleapis.com/google.developers.knowledge.v1.SearchDocumentChunksRequest"
370 }
371}
372
373/// Response message for
374/// [DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
375///
376/// [google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks]: crate::client::DeveloperKnowledge::search_document_chunks
377#[derive(Clone, Default, PartialEq)]
378#[non_exhaustive]
379pub struct SearchDocumentChunksResponse {
380 /// Contains the search results for the given query. Each
381 /// [DocumentChunk][google.developers.knowledge.v1.DocumentChunk] in this list
382 /// contains a snippet of content relevant to the search query. Use the
383 /// [DocumentChunk.parent][google.developers.knowledge.v1.DocumentChunk.parent]
384 /// field of each result with
385 /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
386 /// or
387 /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
388 /// to retrieve the full document content.
389 ///
390 /// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
391 /// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
392 /// [google.developers.knowledge.v1.DocumentChunk]: crate::model::DocumentChunk
393 /// [google.developers.knowledge.v1.DocumentChunk.parent]: crate::model::DocumentChunk::parent
394 pub results: std::vec::Vec<crate::model::DocumentChunk>,
395
396 /// Provides a token that can be sent as `page_token` to retrieve the next
397 /// page.
398 /// If this field is omitted, there are no subsequent pages.
399 pub next_page_token: std::string::String,
400
401 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
402}
403
404impl SearchDocumentChunksResponse {
405 /// Creates a new default instance.
406 pub fn new() -> Self {
407 std::default::Default::default()
408 }
409
410 /// Sets the value of [results][crate::model::SearchDocumentChunksResponse::results].
411 ///
412 /// # Example
413 /// ```ignore,no_run
414 /// # use google_developers_knowledge_v1::model::SearchDocumentChunksResponse;
415 /// use google_developers_knowledge_v1::model::DocumentChunk;
416 /// let x = SearchDocumentChunksResponse::new()
417 /// .set_results([
418 /// DocumentChunk::default()/* use setters */,
419 /// DocumentChunk::default()/* use (different) setters */,
420 /// ]);
421 /// ```
422 pub fn set_results<T, V>(mut self, v: T) -> Self
423 where
424 T: std::iter::IntoIterator<Item = V>,
425 V: std::convert::Into<crate::model::DocumentChunk>,
426 {
427 use std::iter::Iterator;
428 self.results = v.into_iter().map(|i| i.into()).collect();
429 self
430 }
431
432 /// Sets the value of [next_page_token][crate::model::SearchDocumentChunksResponse::next_page_token].
433 ///
434 /// # Example
435 /// ```ignore,no_run
436 /// # use google_developers_knowledge_v1::model::SearchDocumentChunksResponse;
437 /// let x = SearchDocumentChunksResponse::new().set_next_page_token("example");
438 /// ```
439 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
440 self.next_page_token = v.into();
441 self
442 }
443}
444
445impl wkt::message::Message for SearchDocumentChunksResponse {
446 fn typename() -> &'static str {
447 "type.googleapis.com/google.developers.knowledge.v1.SearchDocumentChunksResponse"
448 }
449}
450
451#[doc(hidden)]
452impl google_cloud_gax::paginator::internal::PageableResponse for SearchDocumentChunksResponse {
453 type PageItem = crate::model::DocumentChunk;
454
455 fn items(self) -> std::vec::Vec<Self::PageItem> {
456 self.results
457 }
458
459 fn next_page_token(&self) -> std::string::String {
460 use std::clone::Clone;
461 self.next_page_token.clone()
462 }
463}
464
465/// Request message for
466/// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument].
467///
468/// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
469#[derive(Clone, Default, PartialEq)]
470#[non_exhaustive]
471pub struct GetDocumentRequest {
472 /// Required. Specifies the name of the document to retrieve.
473 /// Format: `documents/{uri_without_scheme}`
474 /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
475 ///
476 /// The name must not exceed 500 characters; values longer than 500 characters
477 /// will result in an `INVALID_ARGUMENT` error.
478 pub name: std::string::String,
479
480 /// Optional. Specifies the
481 /// [DocumentView][google.developers.knowledge.v1.DocumentView] of the
482 /// document. If unspecified,
483 /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
484 /// defaults to `DOCUMENT_VIEW_CONTENT`.
485 ///
486 /// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
487 /// [google.developers.knowledge.v1.DocumentView]: crate::model::DocumentView
488 pub view: crate::model::DocumentView,
489
490 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
491}
492
493impl GetDocumentRequest {
494 /// Creates a new default instance.
495 pub fn new() -> Self {
496 std::default::Default::default()
497 }
498
499 /// Sets the value of [name][crate::model::GetDocumentRequest::name].
500 ///
501 /// # Example
502 /// ```ignore,no_run
503 /// # use google_developers_knowledge_v1::model::GetDocumentRequest;
504 /// # let document_id = "document_id";
505 /// let x = GetDocumentRequest::new().set_name(format!("documents/{document_id}"));
506 /// ```
507 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
508 self.name = v.into();
509 self
510 }
511
512 /// Sets the value of [view][crate::model::GetDocumentRequest::view].
513 ///
514 /// # Example
515 /// ```ignore,no_run
516 /// # use google_developers_knowledge_v1::model::GetDocumentRequest;
517 /// use google_developers_knowledge_v1::model::DocumentView;
518 /// let x0 = GetDocumentRequest::new().set_view(DocumentView::Basic);
519 /// let x1 = GetDocumentRequest::new().set_view(DocumentView::Full);
520 /// let x2 = GetDocumentRequest::new().set_view(DocumentView::Content);
521 /// ```
522 pub fn set_view<T: std::convert::Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
523 self.view = v.into();
524 self
525 }
526}
527
528impl wkt::message::Message for GetDocumentRequest {
529 fn typename() -> &'static str {
530 "type.googleapis.com/google.developers.knowledge.v1.GetDocumentRequest"
531 }
532}
533
534/// Request message for
535/// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
536///
537/// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
538#[derive(Clone, Default, PartialEq)]
539#[non_exhaustive]
540pub struct BatchGetDocumentsRequest {
541 /// Required. Specifies the names of the documents to retrieve. A maximum of 20
542 /// documents can be retrieved in a batch. The documents are returned in the
543 /// same order as the `names` in the request.
544 ///
545 /// Format: `documents/{uri_without_scheme}`
546 /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
547 ///
548 /// Each name must not exceed 500 characters; values longer than 500 characters
549 /// will result in an `INVALID_ARGUMENT` error.
550 pub names: std::vec::Vec<std::string::String>,
551
552 /// Optional. Specifies the
553 /// [DocumentView][google.developers.knowledge.v1.DocumentView] of the
554 /// document. If unspecified,
555 /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
556 /// defaults to `DOCUMENT_VIEW_CONTENT`.
557 ///
558 /// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
559 /// [google.developers.knowledge.v1.DocumentView]: crate::model::DocumentView
560 pub view: crate::model::DocumentView,
561
562 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
563}
564
565impl BatchGetDocumentsRequest {
566 /// Creates a new default instance.
567 pub fn new() -> Self {
568 std::default::Default::default()
569 }
570
571 /// Sets the value of [names][crate::model::BatchGetDocumentsRequest::names].
572 ///
573 /// # Example
574 /// ```ignore,no_run
575 /// # use google_developers_knowledge_v1::model::BatchGetDocumentsRequest;
576 /// let x = BatchGetDocumentsRequest::new().set_names(["a", "b", "c"]);
577 /// ```
578 pub fn set_names<T, V>(mut self, v: T) -> Self
579 where
580 T: std::iter::IntoIterator<Item = V>,
581 V: std::convert::Into<std::string::String>,
582 {
583 use std::iter::Iterator;
584 self.names = v.into_iter().map(|i| i.into()).collect();
585 self
586 }
587
588 /// Sets the value of [view][crate::model::BatchGetDocumentsRequest::view].
589 ///
590 /// # Example
591 /// ```ignore,no_run
592 /// # use google_developers_knowledge_v1::model::BatchGetDocumentsRequest;
593 /// use google_developers_knowledge_v1::model::DocumentView;
594 /// let x0 = BatchGetDocumentsRequest::new().set_view(DocumentView::Basic);
595 /// let x1 = BatchGetDocumentsRequest::new().set_view(DocumentView::Full);
596 /// let x2 = BatchGetDocumentsRequest::new().set_view(DocumentView::Content);
597 /// ```
598 pub fn set_view<T: std::convert::Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
599 self.view = v.into();
600 self
601 }
602}
603
604impl wkt::message::Message for BatchGetDocumentsRequest {
605 fn typename() -> &'static str {
606 "type.googleapis.com/google.developers.knowledge.v1.BatchGetDocumentsRequest"
607 }
608}
609
610/// Response message for
611/// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
612///
613/// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
614#[derive(Clone, Default, PartialEq)]
615#[non_exhaustive]
616pub struct BatchGetDocumentsResponse {
617 /// Contains the documents requested.
618 pub documents: std::vec::Vec<crate::model::Document>,
619
620 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
621}
622
623impl BatchGetDocumentsResponse {
624 /// Creates a new default instance.
625 pub fn new() -> Self {
626 std::default::Default::default()
627 }
628
629 /// Sets the value of [documents][crate::model::BatchGetDocumentsResponse::documents].
630 ///
631 /// # Example
632 /// ```ignore,no_run
633 /// # use google_developers_knowledge_v1::model::BatchGetDocumentsResponse;
634 /// use google_developers_knowledge_v1::model::Document;
635 /// let x = BatchGetDocumentsResponse::new()
636 /// .set_documents([
637 /// Document::default()/* use setters */,
638 /// Document::default()/* use (different) setters */,
639 /// ]);
640 /// ```
641 pub fn set_documents<T, V>(mut self, v: T) -> Self
642 where
643 T: std::iter::IntoIterator<Item = V>,
644 V: std::convert::Into<crate::model::Document>,
645 {
646 use std::iter::Iterator;
647 self.documents = v.into_iter().map(|i| i.into()).collect();
648 self
649 }
650}
651
652impl wkt::message::Message for BatchGetDocumentsResponse {
653 fn typename() -> &'static str {
654 "type.googleapis.com/google.developers.knowledge.v1.BatchGetDocumentsResponse"
655 }
656}
657
658/// Request message for
659/// [DeveloperKnowledge.AnswerQuery][google.developers.knowledge.v1.DeveloperKnowledge.AnswerQuery].
660///
661/// [google.developers.knowledge.v1.DeveloperKnowledge.AnswerQuery]: crate::client::DeveloperKnowledge::answer_query
662#[derive(Clone, Default, PartialEq)]
663#[non_exhaustive]
664pub struct AnswerQueryRequest {
665 /// Required. The query to answer.
666 pub query: std::string::String,
667
668 /// Optional. Applies a strict filter to the search results used to ground the
669 /// answer. The expression supports a subset of the syntax described at
670 /// <https://google.aip.dev/160>.
671 ///
672 /// Supported fields for filtering:
673 ///
674 /// * `content_length_bytes` (INTEGER): The length of the `Document.content`
675 /// field in bytes.
676 /// * `data_source` (STRING): The source of the document, e.g.
677 /// `docs.cloud.google.com`. See
678 /// <https://developers.google.com/knowledge/reference/corpus-reference> for
679 /// the complete list of data sources in the corpus.
680 /// * `update_time` (TIMESTAMP): The timestamp of when the document was last
681 /// meaningfully updated. A meaningful update is one that changes document's
682 /// markdown content or metadata.
683 /// * `uri` (STRING): The document URI, e.g.
684 /// `<https://docs.cloud.google.com/bigquery/docs/tables>`.
685 ///
686 /// INTEGER fields support `=`, `<`, `<=`, `>`, and `>=` operators.
687 ///
688 /// STRING fields support `=` (equals) and `!=` (not equals) operators for
689 /// **exact match** on the whole string. Partial match, prefix match, and
690 /// regexp match are not supported.
691 ///
692 /// TIMESTAMP fields support `=`, `<`, `<=`, `>`, and `>=` operators.
693 /// Timestamps must be in RFC-3339 format, e.g., `"2025-01-01T00:00:00Z"`.
694 ///
695 /// You can combine expressions using `AND`, `OR`, and `NOT` (or `-`) logical
696 /// operators. `OR` has higher precedence than `AND`. Use parentheses for
697 /// explicit precedence grouping.
698 ///
699 /// Examples:
700 ///
701 /// * Filter by `Document.content_length_bytes`:
702 /// `content_length_bytes < 50000`
703 /// * `data_source = "docs.cloud.google.com" OR data_source =
704 /// "firebase.google.com"`
705 /// * `data_source != "firebase.google.com"`
706 /// * `update_time < "2024-01-01T00:00:00Z"`
707 /// * `update_time >= "2025-01-22T00:00:00Z" AND (data_source =
708 /// "developer.chrome.com" OR data_source = "web.dev")`
709 /// * `uri = `https://docs.cloud.google.com/release-notes``
710 ///
711 /// The `filter` string must not exceed 500 characters; values longer than 500
712 /// characters will result in an `INVALID_ARGUMENT` error.
713 pub filter: std::string::String,
714
715 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
716}
717
718impl AnswerQueryRequest {
719 /// Creates a new default instance.
720 pub fn new() -> Self {
721 std::default::Default::default()
722 }
723
724 /// Sets the value of [query][crate::model::AnswerQueryRequest::query].
725 ///
726 /// # Example
727 /// ```ignore,no_run
728 /// # use google_developers_knowledge_v1::model::AnswerQueryRequest;
729 /// let x = AnswerQueryRequest::new().set_query("example");
730 /// ```
731 pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
732 self.query = v.into();
733 self
734 }
735
736 /// Sets the value of [filter][crate::model::AnswerQueryRequest::filter].
737 ///
738 /// # Example
739 /// ```ignore,no_run
740 /// # use google_developers_knowledge_v1::model::AnswerQueryRequest;
741 /// let x = AnswerQueryRequest::new().set_filter("example");
742 /// ```
743 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
744 self.filter = v.into();
745 self
746 }
747}
748
749impl wkt::message::Message for AnswerQueryRequest {
750 fn typename() -> &'static str {
751 "type.googleapis.com/google.developers.knowledge.v1.AnswerQueryRequest"
752 }
753}
754
755/// Response message for
756/// [DeveloperKnowledge.AnswerQuery][google.developers.knowledge.v1.DeveloperKnowledge.AnswerQuery].
757///
758/// [google.developers.knowledge.v1.DeveloperKnowledge.AnswerQuery]: crate::client::DeveloperKnowledge::answer_query
759#[derive(Clone, Default, PartialEq)]
760#[non_exhaustive]
761pub struct AnswerQueryResponse {
762 /// The answer to the query.
763 pub answer: std::option::Option<crate::model::Answer>,
764
765 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
766}
767
768impl AnswerQueryResponse {
769 /// Creates a new default instance.
770 pub fn new() -> Self {
771 std::default::Default::default()
772 }
773
774 /// Sets the value of [answer][crate::model::AnswerQueryResponse::answer].
775 ///
776 /// # Example
777 /// ```ignore,no_run
778 /// # use google_developers_knowledge_v1::model::AnswerQueryResponse;
779 /// use google_developers_knowledge_v1::model::Answer;
780 /// let x = AnswerQueryResponse::new().set_answer(Answer::default()/* use setters */);
781 /// ```
782 pub fn set_answer<T>(mut self, v: T) -> Self
783 where
784 T: std::convert::Into<crate::model::Answer>,
785 {
786 self.answer = std::option::Option::Some(v.into());
787 self
788 }
789
790 /// Sets or clears the value of [answer][crate::model::AnswerQueryResponse::answer].
791 ///
792 /// # Example
793 /// ```ignore,no_run
794 /// # use google_developers_knowledge_v1::model::AnswerQueryResponse;
795 /// use google_developers_knowledge_v1::model::Answer;
796 /// let x = AnswerQueryResponse::new().set_or_clear_answer(Some(Answer::default()/* use setters */));
797 /// let x = AnswerQueryResponse::new().set_or_clear_answer(None::<Answer>);
798 /// ```
799 pub fn set_or_clear_answer<T>(mut self, v: std::option::Option<T>) -> Self
800 where
801 T: std::convert::Into<crate::model::Answer>,
802 {
803 self.answer = v.map(|x| x.into());
804 self
805 }
806}
807
808impl wkt::message::Message for AnswerQueryResponse {
809 fn typename() -> &'static str {
810 "type.googleapis.com/google.developers.knowledge.v1.AnswerQueryResponse"
811 }
812}
813
814/// An answer to a query.
815#[derive(Clone, Default, PartialEq)]
816#[non_exhaustive]
817pub struct Answer {
818 /// Contains the text of the answer.
819 pub answer_text: std::string::String,
820
821 /// Output only. Contains citations for the answer.
822 pub citations: std::vec::Vec<crate::model::answer::AnswerCitation>,
823
824 /// Output only. Contains references for the answer.
825 pub references: std::vec::Vec<crate::model::answer::AnswerReference>,
826
827 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
828}
829
830impl Answer {
831 /// Creates a new default instance.
832 pub fn new() -> Self {
833 std::default::Default::default()
834 }
835
836 /// Sets the value of [answer_text][crate::model::Answer::answer_text].
837 ///
838 /// # Example
839 /// ```ignore,no_run
840 /// # use google_developers_knowledge_v1::model::Answer;
841 /// let x = Answer::new().set_answer_text("example");
842 /// ```
843 pub fn set_answer_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
844 self.answer_text = v.into();
845 self
846 }
847
848 /// Sets the value of [citations][crate::model::Answer::citations].
849 ///
850 /// # Example
851 /// ```ignore,no_run
852 /// # use google_developers_knowledge_v1::model::Answer;
853 /// use google_developers_knowledge_v1::model::answer::AnswerCitation;
854 /// let x = Answer::new()
855 /// .set_citations([
856 /// AnswerCitation::default()/* use setters */,
857 /// AnswerCitation::default()/* use (different) setters */,
858 /// ]);
859 /// ```
860 pub fn set_citations<T, V>(mut self, v: T) -> Self
861 where
862 T: std::iter::IntoIterator<Item = V>,
863 V: std::convert::Into<crate::model::answer::AnswerCitation>,
864 {
865 use std::iter::Iterator;
866 self.citations = v.into_iter().map(|i| i.into()).collect();
867 self
868 }
869
870 /// Sets the value of [references][crate::model::Answer::references].
871 ///
872 /// # Example
873 /// ```ignore,no_run
874 /// # use google_developers_knowledge_v1::model::Answer;
875 /// use google_developers_knowledge_v1::model::answer::AnswerReference;
876 /// let x = Answer::new()
877 /// .set_references([
878 /// AnswerReference::default()/* use setters */,
879 /// AnswerReference::default()/* use (different) setters */,
880 /// ]);
881 /// ```
882 pub fn set_references<T, V>(mut self, v: T) -> Self
883 where
884 T: std::iter::IntoIterator<Item = V>,
885 V: std::convert::Into<crate::model::answer::AnswerReference>,
886 {
887 use std::iter::Iterator;
888 self.references = v.into_iter().map(|i| i.into()).collect();
889 self
890 }
891}
892
893impl wkt::message::Message for Answer {
894 fn typename() -> &'static str {
895 "type.googleapis.com/google.developers.knowledge.v1.Answer"
896 }
897}
898
899/// Defines additional types related to [Answer].
900pub mod answer {
901 #[allow(unused_imports)]
902 use super::*;
903
904 /// Citation info for a segment.
905 #[derive(Clone, Default, PartialEq)]
906 #[non_exhaustive]
907 pub struct AnswerCitation {
908 /// Output only. Indicates the start of the segment, measured in bytes (UTF-8
909 /// unicode), inclusive. If there are multi-byte characters, such as
910 /// non-ASCII characters, the index measurement is longer than the string
911 /// length.
912 pub start_index: i32,
913
914 /// Output only. Indicates the end of the segment, measured in bytes (UTF-8
915 /// unicode), exclusive. If there are multi-byte characters, such as
916 /// non-ASCII characters, the index measurement is longer than the string
917 /// length.
918 pub end_index: i32,
919
920 /// Output only. Contains citation sources for the attributed segment.
921 pub sources: std::vec::Vec<crate::model::answer::CitationSource>,
922
923 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
924 }
925
926 impl AnswerCitation {
927 /// Creates a new default instance.
928 pub fn new() -> Self {
929 std::default::Default::default()
930 }
931
932 /// Sets the value of [start_index][crate::model::answer::AnswerCitation::start_index].
933 ///
934 /// # Example
935 /// ```ignore,no_run
936 /// # use google_developers_knowledge_v1::model::answer::AnswerCitation;
937 /// let x = AnswerCitation::new().set_start_index(42);
938 /// ```
939 pub fn set_start_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
940 self.start_index = v.into();
941 self
942 }
943
944 /// Sets the value of [end_index][crate::model::answer::AnswerCitation::end_index].
945 ///
946 /// # Example
947 /// ```ignore,no_run
948 /// # use google_developers_knowledge_v1::model::answer::AnswerCitation;
949 /// let x = AnswerCitation::new().set_end_index(42);
950 /// ```
951 pub fn set_end_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
952 self.end_index = v.into();
953 self
954 }
955
956 /// Sets the value of [sources][crate::model::answer::AnswerCitation::sources].
957 ///
958 /// # Example
959 /// ```ignore,no_run
960 /// # use google_developers_knowledge_v1::model::answer::AnswerCitation;
961 /// use google_developers_knowledge_v1::model::answer::CitationSource;
962 /// let x = AnswerCitation::new()
963 /// .set_sources([
964 /// CitationSource::default()/* use setters */,
965 /// CitationSource::default()/* use (different) setters */,
966 /// ]);
967 /// ```
968 pub fn set_sources<T, V>(mut self, v: T) -> Self
969 where
970 T: std::iter::IntoIterator<Item = V>,
971 V: std::convert::Into<crate::model::answer::CitationSource>,
972 {
973 use std::iter::Iterator;
974 self.sources = v.into_iter().map(|i| i.into()).collect();
975 self
976 }
977 }
978
979 impl wkt::message::Message for AnswerCitation {
980 fn typename() -> &'static str {
981 "type.googleapis.com/google.developers.knowledge.v1.Answer.AnswerCitation"
982 }
983 }
984
985 /// Citation source.
986 #[derive(Clone, Default, PartialEq)]
987 #[non_exhaustive]
988 pub struct CitationSource {
989 /// Output only. Contains the index of the
990 /// [Answer.AnswerReference][google.developers.knowledge.v1.Answer.AnswerReference]
991 /// in the `references` repeated field.
992 ///
993 /// [google.developers.knowledge.v1.Answer.AnswerReference]: crate::model::answer::AnswerReference
994 pub reference_index: i32,
995
996 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
997 }
998
999 impl CitationSource {
1000 /// Creates a new default instance.
1001 pub fn new() -> Self {
1002 std::default::Default::default()
1003 }
1004
1005 /// Sets the value of [reference_index][crate::model::answer::CitationSource::reference_index].
1006 ///
1007 /// # Example
1008 /// ```ignore,no_run
1009 /// # use google_developers_knowledge_v1::model::answer::CitationSource;
1010 /// let x = CitationSource::new().set_reference_index(42);
1011 /// ```
1012 pub fn set_reference_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1013 self.reference_index = v.into();
1014 self
1015 }
1016 }
1017
1018 impl wkt::message::Message for CitationSource {
1019 fn typename() -> &'static str {
1020 "type.googleapis.com/google.developers.knowledge.v1.Answer.CitationSource"
1021 }
1022 }
1023
1024 /// Represents a reference to a source.
1025 #[derive(Clone, Default, PartialEq)]
1026 #[non_exhaustive]
1027 pub struct AnswerReference {
1028 /// Contains the content of the reference.
1029 pub content: std::option::Option<crate::model::answer::answer_reference::Content>,
1030
1031 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1032 }
1033
1034 impl AnswerReference {
1035 /// Creates a new default instance.
1036 pub fn new() -> Self {
1037 std::default::Default::default()
1038 }
1039
1040 /// Sets the value of [content][crate::model::answer::AnswerReference::content].
1041 ///
1042 /// Note that all the setters affecting `content` are mutually
1043 /// exclusive.
1044 ///
1045 /// # Example
1046 /// ```ignore,no_run
1047 /// # use google_developers_knowledge_v1::model::answer::AnswerReference;
1048 /// use google_developers_knowledge_v1::model::answer::DocumentReference;
1049 /// let x = AnswerReference::new().set_content(Some(
1050 /// google_developers_knowledge_v1::model::answer::answer_reference::Content::DocumentReference(DocumentReference::default().into())));
1051 /// ```
1052 pub fn set_content<
1053 T: std::convert::Into<
1054 std::option::Option<crate::model::answer::answer_reference::Content>,
1055 >,
1056 >(
1057 mut self,
1058 v: T,
1059 ) -> Self {
1060 self.content = v.into();
1061 self
1062 }
1063
1064 /// The value of [content][crate::model::answer::AnswerReference::content]
1065 /// if it holds a `DocumentReference`, `None` if the field is not set or
1066 /// holds a different branch.
1067 pub fn document_reference(
1068 &self,
1069 ) -> std::option::Option<&std::boxed::Box<crate::model::answer::DocumentReference>>
1070 {
1071 #[allow(unreachable_patterns)]
1072 self.content.as_ref().and_then(|v| match v {
1073 crate::model::answer::answer_reference::Content::DocumentReference(v) => {
1074 std::option::Option::Some(v)
1075 }
1076 _ => std::option::Option::None,
1077 })
1078 }
1079
1080 /// Sets the value of [content][crate::model::answer::AnswerReference::content]
1081 /// to hold a `DocumentReference`.
1082 ///
1083 /// Note that all the setters affecting `content` are
1084 /// mutually exclusive.
1085 ///
1086 /// # Example
1087 /// ```ignore,no_run
1088 /// # use google_developers_knowledge_v1::model::answer::AnswerReference;
1089 /// use google_developers_knowledge_v1::model::answer::DocumentReference;
1090 /// let x = AnswerReference::new().set_document_reference(DocumentReference::default()/* use setters */);
1091 /// assert!(x.document_reference().is_some());
1092 /// ```
1093 pub fn set_document_reference<
1094 T: std::convert::Into<std::boxed::Box<crate::model::answer::DocumentReference>>,
1095 >(
1096 mut self,
1097 v: T,
1098 ) -> Self {
1099 self.content = std::option::Option::Some(
1100 crate::model::answer::answer_reference::Content::DocumentReference(v.into()),
1101 );
1102 self
1103 }
1104 }
1105
1106 impl wkt::message::Message for AnswerReference {
1107 fn typename() -> &'static str {
1108 "type.googleapis.com/google.developers.knowledge.v1.Answer.AnswerReference"
1109 }
1110 }
1111
1112 /// Defines additional types related to [AnswerReference].
1113 pub mod answer_reference {
1114 #[allow(unused_imports)]
1115 use super::*;
1116
1117 /// Contains the content of the reference.
1118 #[derive(Clone, Debug, PartialEq)]
1119 #[non_exhaustive]
1120 pub enum Content {
1121 /// Output only. The reference document.
1122 DocumentReference(std::boxed::Box<crate::model::answer::DocumentReference>),
1123 }
1124 }
1125
1126 /// Represents a reference to a document.
1127 #[derive(Clone, Default, PartialEq)]
1128 #[non_exhaustive]
1129 pub struct DocumentReference {
1130 /// Output only. Contains the document chunk. The `document_chunk.id` field
1131 /// is not set and will be empty.
1132 pub document_chunk: std::option::Option<crate::model::DocumentChunk>,
1133
1134 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1135 }
1136
1137 impl DocumentReference {
1138 /// Creates a new default instance.
1139 pub fn new() -> Self {
1140 std::default::Default::default()
1141 }
1142
1143 /// Sets the value of [document_chunk][crate::model::answer::DocumentReference::document_chunk].
1144 ///
1145 /// # Example
1146 /// ```ignore,no_run
1147 /// # use google_developers_knowledge_v1::model::answer::DocumentReference;
1148 /// use google_developers_knowledge_v1::model::DocumentChunk;
1149 /// let x = DocumentReference::new().set_document_chunk(DocumentChunk::default()/* use setters */);
1150 /// ```
1151 pub fn set_document_chunk<T>(mut self, v: T) -> Self
1152 where
1153 T: std::convert::Into<crate::model::DocumentChunk>,
1154 {
1155 self.document_chunk = std::option::Option::Some(v.into());
1156 self
1157 }
1158
1159 /// Sets or clears the value of [document_chunk][crate::model::answer::DocumentReference::document_chunk].
1160 ///
1161 /// # Example
1162 /// ```ignore,no_run
1163 /// # use google_developers_knowledge_v1::model::answer::DocumentReference;
1164 /// use google_developers_knowledge_v1::model::DocumentChunk;
1165 /// let x = DocumentReference::new().set_or_clear_document_chunk(Some(DocumentChunk::default()/* use setters */));
1166 /// let x = DocumentReference::new().set_or_clear_document_chunk(None::<DocumentChunk>);
1167 /// ```
1168 pub fn set_or_clear_document_chunk<T>(mut self, v: std::option::Option<T>) -> Self
1169 where
1170 T: std::convert::Into<crate::model::DocumentChunk>,
1171 {
1172 self.document_chunk = v.map(|x| x.into());
1173 self
1174 }
1175 }
1176
1177 impl wkt::message::Message for DocumentReference {
1178 fn typename() -> &'static str {
1179 "type.googleapis.com/google.developers.knowledge.v1.Answer.DocumentReference"
1180 }
1181 }
1182}
1183
1184/// A DocumentChunk represents a piece of content from a
1185/// [Document][google.developers.knowledge.v1.Document] in the DeveloperKnowledge
1186/// corpus. To fetch the entire document content, pass the `parent` to
1187/// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1188/// or
1189/// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
1190///
1191/// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
1192/// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
1193/// [google.developers.knowledge.v1.Document]: crate::model::Document
1194#[derive(Clone, Default, PartialEq)]
1195#[non_exhaustive]
1196pub struct DocumentChunk {
1197 /// Output only. Contains the resource name of the document this chunk is from.
1198 /// Format: `documents/{uri_without_scheme}`
1199 /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
1200 pub parent: std::string::String,
1201
1202 /// Output only. Specifies the ID of this chunk within the document. The chunk
1203 /// ID is unique within a document, but not globally unique across documents.
1204 /// The chunk ID is not stable and may change over time.
1205 pub id: std::string::String,
1206
1207 /// Output only. Contains the content of the document chunk.
1208 pub content: std::string::String,
1209
1210 /// Output only. Represents metadata about the
1211 /// [Document][google.developers.knowledge.v1.Document] this chunk is from. The
1212 /// [DocumentView][google.developers.knowledge.v1.DocumentView] of this
1213 /// [Document][google.developers.knowledge.v1.Document] message will be set to
1214 /// `DOCUMENT_VIEW_BASIC`. It is included here for convenience so that clients
1215 /// do not need to call
1216 /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1217 /// or
1218 /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
1219 /// if they only need the metadata fields. Otherwise, clients should use
1220 /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1221 /// or
1222 /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
1223 /// to fetch the full document content.
1224 ///
1225 /// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
1226 /// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
1227 /// [google.developers.knowledge.v1.Document]: crate::model::Document
1228 /// [google.developers.knowledge.v1.DocumentView]: crate::model::DocumentView
1229 pub document: std::option::Option<crate::model::Document>,
1230
1231 /// Output only. Represents the relevance score of the chunk to the search
1232 /// query. Higher score indicates higher chunk relevance. The score is in range
1233 /// [0.0, 1.0].
1234 pub relevance_score: std::option::Option<f64>,
1235
1236 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1237}
1238
1239impl DocumentChunk {
1240 /// Creates a new default instance.
1241 pub fn new() -> Self {
1242 std::default::Default::default()
1243 }
1244
1245 /// Sets the value of [parent][crate::model::DocumentChunk::parent].
1246 ///
1247 /// # Example
1248 /// ```ignore,no_run
1249 /// # use google_developers_knowledge_v1::model::DocumentChunk;
1250 /// # let document_id = "document_id";
1251 /// let x = DocumentChunk::new().set_parent(format!("documents/{document_id}"));
1252 /// ```
1253 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1254 self.parent = v.into();
1255 self
1256 }
1257
1258 /// Sets the value of [id][crate::model::DocumentChunk::id].
1259 ///
1260 /// # Example
1261 /// ```ignore,no_run
1262 /// # use google_developers_knowledge_v1::model::DocumentChunk;
1263 /// let x = DocumentChunk::new().set_id("example");
1264 /// ```
1265 pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1266 self.id = v.into();
1267 self
1268 }
1269
1270 /// Sets the value of [content][crate::model::DocumentChunk::content].
1271 ///
1272 /// # Example
1273 /// ```ignore,no_run
1274 /// # use google_developers_knowledge_v1::model::DocumentChunk;
1275 /// let x = DocumentChunk::new().set_content("example");
1276 /// ```
1277 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1278 self.content = v.into();
1279 self
1280 }
1281
1282 /// Sets the value of [document][crate::model::DocumentChunk::document].
1283 ///
1284 /// # Example
1285 /// ```ignore,no_run
1286 /// # use google_developers_knowledge_v1::model::DocumentChunk;
1287 /// use google_developers_knowledge_v1::model::Document;
1288 /// let x = DocumentChunk::new().set_document(Document::default()/* use setters */);
1289 /// ```
1290 pub fn set_document<T>(mut self, v: T) -> Self
1291 where
1292 T: std::convert::Into<crate::model::Document>,
1293 {
1294 self.document = std::option::Option::Some(v.into());
1295 self
1296 }
1297
1298 /// Sets or clears the value of [document][crate::model::DocumentChunk::document].
1299 ///
1300 /// # Example
1301 /// ```ignore,no_run
1302 /// # use google_developers_knowledge_v1::model::DocumentChunk;
1303 /// use google_developers_knowledge_v1::model::Document;
1304 /// let x = DocumentChunk::new().set_or_clear_document(Some(Document::default()/* use setters */));
1305 /// let x = DocumentChunk::new().set_or_clear_document(None::<Document>);
1306 /// ```
1307 pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1308 where
1309 T: std::convert::Into<crate::model::Document>,
1310 {
1311 self.document = v.map(|x| x.into());
1312 self
1313 }
1314
1315 /// Sets the value of [relevance_score][crate::model::DocumentChunk::relevance_score].
1316 ///
1317 /// # Example
1318 /// ```ignore,no_run
1319 /// # use google_developers_knowledge_v1::model::DocumentChunk;
1320 /// let x = DocumentChunk::new().set_relevance_score(42.0);
1321 /// ```
1322 pub fn set_relevance_score<T>(mut self, v: T) -> Self
1323 where
1324 T: std::convert::Into<f64>,
1325 {
1326 self.relevance_score = std::option::Option::Some(v.into());
1327 self
1328 }
1329
1330 /// Sets or clears the value of [relevance_score][crate::model::DocumentChunk::relevance_score].
1331 ///
1332 /// # Example
1333 /// ```ignore,no_run
1334 /// # use google_developers_knowledge_v1::model::DocumentChunk;
1335 /// let x = DocumentChunk::new().set_or_clear_relevance_score(Some(42.0));
1336 /// let x = DocumentChunk::new().set_or_clear_relevance_score(None::<f32>);
1337 /// ```
1338 pub fn set_or_clear_relevance_score<T>(mut self, v: std::option::Option<T>) -> Self
1339 where
1340 T: std::convert::Into<f64>,
1341 {
1342 self.relevance_score = v.map(|x| x.into());
1343 self
1344 }
1345}
1346
1347impl wkt::message::Message for DocumentChunk {
1348 fn typename() -> &'static str {
1349 "type.googleapis.com/google.developers.knowledge.v1.DocumentChunk"
1350 }
1351}
1352
1353/// Specifies which fields of the
1354/// [Document][google.developers.knowledge.v1.Document] are included.
1355///
1356/// [google.developers.knowledge.v1.Document]: crate::model::Document
1357///
1358/// # Working with unknown values
1359///
1360/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1361/// additional enum variants at any time. Adding new variants is not considered
1362/// a breaking change. Applications should write their code in anticipation of:
1363///
1364/// - New values appearing in future releases of the client library, **and**
1365/// - New values received dynamically, without application changes.
1366///
1367/// Please consult the [Working with enums] section in the user guide for some
1368/// guidelines.
1369///
1370/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1371#[derive(Clone, Debug, PartialEq)]
1372#[non_exhaustive]
1373pub enum DocumentView {
1374 /// The default / unset value. See each API method for its default value if
1375 /// [DocumentView][google.developers.knowledge.v1.DocumentView] is not
1376 /// specified.
1377 ///
1378 /// [google.developers.knowledge.v1.DocumentView]: crate::model::DocumentView
1379 Unspecified,
1380 /// Includes only the basic metadata fields:
1381 ///
1382 /// - `name`
1383 /// - `uri`
1384 /// - `data_source`
1385 /// - `title`
1386 /// - `description`
1387 /// - `update_time`
1388 /// - `view`
1389 /// - `content_length_bytes`
1390 ///
1391 /// This is the default of view for
1392 /// [DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
1393 ///
1394 /// [google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks]: crate::client::DeveloperKnowledge::search_document_chunks
1395 Basic,
1396 /// Includes all [Document][google.developers.knowledge.v1.Document] fields.
1397 ///
1398 /// [google.developers.knowledge.v1.Document]: crate::model::Document
1399 Full,
1400 /// Includes the `DOCUMENT_VIEW_BASIC` fields and the `content` field.
1401 ///
1402 /// This is the default of view for
1403 /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1404 /// and
1405 /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
1406 ///
1407 /// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
1408 /// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
1409 Content,
1410 /// If set, the enum was initialized with an unknown value.
1411 ///
1412 /// Applications can examine the value using [DocumentView::value] or
1413 /// [DocumentView::name].
1414 UnknownValue(document_view::UnknownValue),
1415}
1416
1417#[doc(hidden)]
1418pub mod document_view {
1419 #[allow(unused_imports)]
1420 use super::*;
1421 #[derive(Clone, Debug, PartialEq)]
1422 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1423}
1424
1425impl DocumentView {
1426 /// Gets the enum value.
1427 ///
1428 /// Returns `None` if the enum contains an unknown value deserialized from
1429 /// the string representation of enums.
1430 pub fn value(&self) -> std::option::Option<i32> {
1431 match self {
1432 Self::Unspecified => std::option::Option::Some(0),
1433 Self::Basic => std::option::Option::Some(1),
1434 Self::Full => std::option::Option::Some(2),
1435 Self::Content => std::option::Option::Some(3),
1436 Self::UnknownValue(u) => u.0.value(),
1437 }
1438 }
1439
1440 /// Gets the enum value as a string.
1441 ///
1442 /// Returns `None` if the enum contains an unknown value deserialized from
1443 /// the integer representation of enums.
1444 pub fn name(&self) -> std::option::Option<&str> {
1445 match self {
1446 Self::Unspecified => std::option::Option::Some("DOCUMENT_VIEW_UNSPECIFIED"),
1447 Self::Basic => std::option::Option::Some("DOCUMENT_VIEW_BASIC"),
1448 Self::Full => std::option::Option::Some("DOCUMENT_VIEW_FULL"),
1449 Self::Content => std::option::Option::Some("DOCUMENT_VIEW_CONTENT"),
1450 Self::UnknownValue(u) => u.0.name(),
1451 }
1452 }
1453}
1454
1455impl std::default::Default for DocumentView {
1456 fn default() -> Self {
1457 use std::convert::From;
1458 Self::from(0)
1459 }
1460}
1461
1462impl std::fmt::Display for DocumentView {
1463 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1464 wkt::internal::display_enum(f, self.name(), self.value())
1465 }
1466}
1467
1468impl std::convert::From<i32> for DocumentView {
1469 fn from(value: i32) -> Self {
1470 match value {
1471 0 => Self::Unspecified,
1472 1 => Self::Basic,
1473 2 => Self::Full,
1474 3 => Self::Content,
1475 _ => Self::UnknownValue(document_view::UnknownValue(
1476 wkt::internal::UnknownEnumValue::Integer(value),
1477 )),
1478 }
1479 }
1480}
1481
1482impl std::convert::From<&str> for DocumentView {
1483 fn from(value: &str) -> Self {
1484 use std::string::ToString;
1485 match value {
1486 "DOCUMENT_VIEW_UNSPECIFIED" => Self::Unspecified,
1487 "DOCUMENT_VIEW_BASIC" => Self::Basic,
1488 "DOCUMENT_VIEW_FULL" => Self::Full,
1489 "DOCUMENT_VIEW_CONTENT" => Self::Content,
1490 _ => Self::UnknownValue(document_view::UnknownValue(
1491 wkt::internal::UnknownEnumValue::String(value.to_string()),
1492 )),
1493 }
1494 }
1495}
1496
1497impl serde::ser::Serialize for DocumentView {
1498 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1499 where
1500 S: serde::Serializer,
1501 {
1502 match self {
1503 Self::Unspecified => serializer.serialize_i32(0),
1504 Self::Basic => serializer.serialize_i32(1),
1505 Self::Full => serializer.serialize_i32(2),
1506 Self::Content => serializer.serialize_i32(3),
1507 Self::UnknownValue(u) => u.0.serialize(serializer),
1508 }
1509 }
1510}
1511
1512impl<'de> serde::de::Deserialize<'de> for DocumentView {
1513 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1514 where
1515 D: serde::Deserializer<'de>,
1516 {
1517 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DocumentView>::new(
1518 ".google.developers.knowledge.v1.DocumentView",
1519 ))
1520 }
1521}