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