Skip to main content

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    /// `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    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
669}
670
671impl AnswerQueryRequest {
672    /// Creates a new default instance.
673    pub fn new() -> Self {
674        std::default::Default::default()
675    }
676
677    /// Sets the value of [query][crate::model::AnswerQueryRequest::query].
678    ///
679    /// # Example
680    /// ```ignore,no_run
681    /// # use google_developers_knowledge_v1::model::AnswerQueryRequest;
682    /// let x = AnswerQueryRequest::new().set_query("example");
683    /// ```
684    pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
685        self.query = v.into();
686        self
687    }
688}
689
690impl wkt::message::Message for AnswerQueryRequest {
691    fn typename() -> &'static str {
692        "type.googleapis.com/google.developers.knowledge.v1.AnswerQueryRequest"
693    }
694}
695
696/// Response message for
697/// [DeveloperKnowledge.AnswerQuery][google.developers.knowledge.v1.DeveloperKnowledge.AnswerQuery].
698///
699/// [google.developers.knowledge.v1.DeveloperKnowledge.AnswerQuery]: crate::client::DeveloperKnowledge::answer_query
700#[derive(Clone, Default, PartialEq)]
701#[non_exhaustive]
702pub struct AnswerQueryResponse {
703    /// The answer to the query.
704    pub answer: std::option::Option<crate::model::Answer>,
705
706    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
707}
708
709impl AnswerQueryResponse {
710    /// Creates a new default instance.
711    pub fn new() -> Self {
712        std::default::Default::default()
713    }
714
715    /// Sets the value of [answer][crate::model::AnswerQueryResponse::answer].
716    ///
717    /// # Example
718    /// ```ignore,no_run
719    /// # use google_developers_knowledge_v1::model::AnswerQueryResponse;
720    /// use google_developers_knowledge_v1::model::Answer;
721    /// let x = AnswerQueryResponse::new().set_answer(Answer::default()/* use setters */);
722    /// ```
723    pub fn set_answer<T>(mut self, v: T) -> Self
724    where
725        T: std::convert::Into<crate::model::Answer>,
726    {
727        self.answer = std::option::Option::Some(v.into());
728        self
729    }
730
731    /// Sets or clears the value of [answer][crate::model::AnswerQueryResponse::answer].
732    ///
733    /// # Example
734    /// ```ignore,no_run
735    /// # use google_developers_knowledge_v1::model::AnswerQueryResponse;
736    /// use google_developers_knowledge_v1::model::Answer;
737    /// let x = AnswerQueryResponse::new().set_or_clear_answer(Some(Answer::default()/* use setters */));
738    /// let x = AnswerQueryResponse::new().set_or_clear_answer(None::<Answer>);
739    /// ```
740    pub fn set_or_clear_answer<T>(mut self, v: std::option::Option<T>) -> Self
741    where
742        T: std::convert::Into<crate::model::Answer>,
743    {
744        self.answer = v.map(|x| x.into());
745        self
746    }
747}
748
749impl wkt::message::Message for AnswerQueryResponse {
750    fn typename() -> &'static str {
751        "type.googleapis.com/google.developers.knowledge.v1.AnswerQueryResponse"
752    }
753}
754
755/// An answer to a query.
756#[derive(Clone, Default, PartialEq)]
757#[non_exhaustive]
758pub struct Answer {
759    /// Contains the text of the answer.
760    pub answer_text: std::string::String,
761
762    /// Output only. Contains citations for the answer.
763    pub citations: std::vec::Vec<crate::model::answer::AnswerCitation>,
764
765    /// Output only. Contains references for the answer.
766    pub references: std::vec::Vec<crate::model::answer::AnswerReference>,
767
768    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
769}
770
771impl Answer {
772    /// Creates a new default instance.
773    pub fn new() -> Self {
774        std::default::Default::default()
775    }
776
777    /// Sets the value of [answer_text][crate::model::Answer::answer_text].
778    ///
779    /// # Example
780    /// ```ignore,no_run
781    /// # use google_developers_knowledge_v1::model::Answer;
782    /// let x = Answer::new().set_answer_text("example");
783    /// ```
784    pub fn set_answer_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
785        self.answer_text = v.into();
786        self
787    }
788
789    /// Sets the value of [citations][crate::model::Answer::citations].
790    ///
791    /// # Example
792    /// ```ignore,no_run
793    /// # use google_developers_knowledge_v1::model::Answer;
794    /// use google_developers_knowledge_v1::model::answer::AnswerCitation;
795    /// let x = Answer::new()
796    ///     .set_citations([
797    ///         AnswerCitation::default()/* use setters */,
798    ///         AnswerCitation::default()/* use (different) setters */,
799    ///     ]);
800    /// ```
801    pub fn set_citations<T, V>(mut self, v: T) -> Self
802    where
803        T: std::iter::IntoIterator<Item = V>,
804        V: std::convert::Into<crate::model::answer::AnswerCitation>,
805    {
806        use std::iter::Iterator;
807        self.citations = v.into_iter().map(|i| i.into()).collect();
808        self
809    }
810
811    /// Sets the value of [references][crate::model::Answer::references].
812    ///
813    /// # Example
814    /// ```ignore,no_run
815    /// # use google_developers_knowledge_v1::model::Answer;
816    /// use google_developers_knowledge_v1::model::answer::AnswerReference;
817    /// let x = Answer::new()
818    ///     .set_references([
819    ///         AnswerReference::default()/* use setters */,
820    ///         AnswerReference::default()/* use (different) setters */,
821    ///     ]);
822    /// ```
823    pub fn set_references<T, V>(mut self, v: T) -> Self
824    where
825        T: std::iter::IntoIterator<Item = V>,
826        V: std::convert::Into<crate::model::answer::AnswerReference>,
827    {
828        use std::iter::Iterator;
829        self.references = v.into_iter().map(|i| i.into()).collect();
830        self
831    }
832}
833
834impl wkt::message::Message for Answer {
835    fn typename() -> &'static str {
836        "type.googleapis.com/google.developers.knowledge.v1.Answer"
837    }
838}
839
840/// Defines additional types related to [Answer].
841pub mod answer {
842    #[allow(unused_imports)]
843    use super::*;
844
845    /// Citation info for a segment.
846    #[derive(Clone, Default, PartialEq)]
847    #[non_exhaustive]
848    pub struct AnswerCitation {
849        /// Output only. Indicates the start of the segment, measured in bytes (UTF-8
850        /// unicode), inclusive. If there are multi-byte characters, such as
851        /// non-ASCII characters, the index measurement is longer than the string
852        /// length.
853        pub start_index: i32,
854
855        /// Output only. Indicates the end of the segment, measured in bytes (UTF-8
856        /// unicode), exclusive. If there are multi-byte characters, such as
857        /// non-ASCII characters, the index measurement is longer than the string
858        /// length.
859        pub end_index: i32,
860
861        /// Output only. Contains citation sources for the attributed segment.
862        pub sources: std::vec::Vec<crate::model::answer::CitationSource>,
863
864        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
865    }
866
867    impl AnswerCitation {
868        /// Creates a new default instance.
869        pub fn new() -> Self {
870            std::default::Default::default()
871        }
872
873        /// Sets the value of [start_index][crate::model::answer::AnswerCitation::start_index].
874        ///
875        /// # Example
876        /// ```ignore,no_run
877        /// # use google_developers_knowledge_v1::model::answer::AnswerCitation;
878        /// let x = AnswerCitation::new().set_start_index(42);
879        /// ```
880        pub fn set_start_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
881            self.start_index = v.into();
882            self
883        }
884
885        /// Sets the value of [end_index][crate::model::answer::AnswerCitation::end_index].
886        ///
887        /// # Example
888        /// ```ignore,no_run
889        /// # use google_developers_knowledge_v1::model::answer::AnswerCitation;
890        /// let x = AnswerCitation::new().set_end_index(42);
891        /// ```
892        pub fn set_end_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
893            self.end_index = v.into();
894            self
895        }
896
897        /// Sets the value of [sources][crate::model::answer::AnswerCitation::sources].
898        ///
899        /// # Example
900        /// ```ignore,no_run
901        /// # use google_developers_knowledge_v1::model::answer::AnswerCitation;
902        /// use google_developers_knowledge_v1::model::answer::CitationSource;
903        /// let x = AnswerCitation::new()
904        ///     .set_sources([
905        ///         CitationSource::default()/* use setters */,
906        ///         CitationSource::default()/* use (different) setters */,
907        ///     ]);
908        /// ```
909        pub fn set_sources<T, V>(mut self, v: T) -> Self
910        where
911            T: std::iter::IntoIterator<Item = V>,
912            V: std::convert::Into<crate::model::answer::CitationSource>,
913        {
914            use std::iter::Iterator;
915            self.sources = v.into_iter().map(|i| i.into()).collect();
916            self
917        }
918    }
919
920    impl wkt::message::Message for AnswerCitation {
921        fn typename() -> &'static str {
922            "type.googleapis.com/google.developers.knowledge.v1.Answer.AnswerCitation"
923        }
924    }
925
926    /// Citation source.
927    #[derive(Clone, Default, PartialEq)]
928    #[non_exhaustive]
929    pub struct CitationSource {
930        /// Output only. Contains the index of the
931        /// [Answer.AnswerReference][google.developers.knowledge.v1.Answer.AnswerReference]
932        /// in the `references` repeated field.
933        ///
934        /// [google.developers.knowledge.v1.Answer.AnswerReference]: crate::model::answer::AnswerReference
935        pub reference_index: i32,
936
937        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
938    }
939
940    impl CitationSource {
941        /// Creates a new default instance.
942        pub fn new() -> Self {
943            std::default::Default::default()
944        }
945
946        /// Sets the value of [reference_index][crate::model::answer::CitationSource::reference_index].
947        ///
948        /// # Example
949        /// ```ignore,no_run
950        /// # use google_developers_knowledge_v1::model::answer::CitationSource;
951        /// let x = CitationSource::new().set_reference_index(42);
952        /// ```
953        pub fn set_reference_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
954            self.reference_index = v.into();
955            self
956        }
957    }
958
959    impl wkt::message::Message for CitationSource {
960        fn typename() -> &'static str {
961            "type.googleapis.com/google.developers.knowledge.v1.Answer.CitationSource"
962        }
963    }
964
965    /// Represents a reference to a source.
966    #[derive(Clone, Default, PartialEq)]
967    #[non_exhaustive]
968    pub struct AnswerReference {
969        /// Contains the content of the reference.
970        pub content: std::option::Option<crate::model::answer::answer_reference::Content>,
971
972        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
973    }
974
975    impl AnswerReference {
976        /// Creates a new default instance.
977        pub fn new() -> Self {
978            std::default::Default::default()
979        }
980
981        /// Sets the value of [content][crate::model::answer::AnswerReference::content].
982        ///
983        /// Note that all the setters affecting `content` are mutually
984        /// exclusive.
985        ///
986        /// # Example
987        /// ```ignore,no_run
988        /// # use google_developers_knowledge_v1::model::answer::AnswerReference;
989        /// use google_developers_knowledge_v1::model::answer::DocumentReference;
990        /// let x = AnswerReference::new().set_content(Some(
991        ///     google_developers_knowledge_v1::model::answer::answer_reference::Content::DocumentReference(DocumentReference::default().into())));
992        /// ```
993        pub fn set_content<
994            T: std::convert::Into<
995                    std::option::Option<crate::model::answer::answer_reference::Content>,
996                >,
997        >(
998            mut self,
999            v: T,
1000        ) -> Self {
1001            self.content = v.into();
1002            self
1003        }
1004
1005        /// The value of [content][crate::model::answer::AnswerReference::content]
1006        /// if it holds a `DocumentReference`, `None` if the field is not set or
1007        /// holds a different branch.
1008        pub fn document_reference(
1009            &self,
1010        ) -> std::option::Option<&std::boxed::Box<crate::model::answer::DocumentReference>>
1011        {
1012            #[allow(unreachable_patterns)]
1013            self.content.as_ref().and_then(|v| match v {
1014                crate::model::answer::answer_reference::Content::DocumentReference(v) => {
1015                    std::option::Option::Some(v)
1016                }
1017                _ => std::option::Option::None,
1018            })
1019        }
1020
1021        /// Sets the value of [content][crate::model::answer::AnswerReference::content]
1022        /// to hold a `DocumentReference`.
1023        ///
1024        /// Note that all the setters affecting `content` are
1025        /// mutually exclusive.
1026        ///
1027        /// # Example
1028        /// ```ignore,no_run
1029        /// # use google_developers_knowledge_v1::model::answer::AnswerReference;
1030        /// use google_developers_knowledge_v1::model::answer::DocumentReference;
1031        /// let x = AnswerReference::new().set_document_reference(DocumentReference::default()/* use setters */);
1032        /// assert!(x.document_reference().is_some());
1033        /// ```
1034        pub fn set_document_reference<
1035            T: std::convert::Into<std::boxed::Box<crate::model::answer::DocumentReference>>,
1036        >(
1037            mut self,
1038            v: T,
1039        ) -> Self {
1040            self.content = std::option::Option::Some(
1041                crate::model::answer::answer_reference::Content::DocumentReference(v.into()),
1042            );
1043            self
1044        }
1045    }
1046
1047    impl wkt::message::Message for AnswerReference {
1048        fn typename() -> &'static str {
1049            "type.googleapis.com/google.developers.knowledge.v1.Answer.AnswerReference"
1050        }
1051    }
1052
1053    /// Defines additional types related to [AnswerReference].
1054    pub mod answer_reference {
1055        #[allow(unused_imports)]
1056        use super::*;
1057
1058        /// Contains the content of the reference.
1059        #[derive(Clone, Debug, PartialEq)]
1060        #[non_exhaustive]
1061        pub enum Content {
1062            /// Output only. The reference document.
1063            DocumentReference(std::boxed::Box<crate::model::answer::DocumentReference>),
1064        }
1065    }
1066
1067    /// Represents a reference to a document.
1068    #[derive(Clone, Default, PartialEq)]
1069    #[non_exhaustive]
1070    pub struct DocumentReference {
1071        /// Output only. Contains the document chunk. The `document_chunk.id` field
1072        /// is not set and will be empty.
1073        pub document_chunk: std::option::Option<crate::model::DocumentChunk>,
1074
1075        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1076    }
1077
1078    impl DocumentReference {
1079        /// Creates a new default instance.
1080        pub fn new() -> Self {
1081            std::default::Default::default()
1082        }
1083
1084        /// Sets the value of [document_chunk][crate::model::answer::DocumentReference::document_chunk].
1085        ///
1086        /// # Example
1087        /// ```ignore,no_run
1088        /// # use google_developers_knowledge_v1::model::answer::DocumentReference;
1089        /// use google_developers_knowledge_v1::model::DocumentChunk;
1090        /// let x = DocumentReference::new().set_document_chunk(DocumentChunk::default()/* use setters */);
1091        /// ```
1092        pub fn set_document_chunk<T>(mut self, v: T) -> Self
1093        where
1094            T: std::convert::Into<crate::model::DocumentChunk>,
1095        {
1096            self.document_chunk = std::option::Option::Some(v.into());
1097            self
1098        }
1099
1100        /// Sets or clears the value of [document_chunk][crate::model::answer::DocumentReference::document_chunk].
1101        ///
1102        /// # Example
1103        /// ```ignore,no_run
1104        /// # use google_developers_knowledge_v1::model::answer::DocumentReference;
1105        /// use google_developers_knowledge_v1::model::DocumentChunk;
1106        /// let x = DocumentReference::new().set_or_clear_document_chunk(Some(DocumentChunk::default()/* use setters */));
1107        /// let x = DocumentReference::new().set_or_clear_document_chunk(None::<DocumentChunk>);
1108        /// ```
1109        pub fn set_or_clear_document_chunk<T>(mut self, v: std::option::Option<T>) -> Self
1110        where
1111            T: std::convert::Into<crate::model::DocumentChunk>,
1112        {
1113            self.document_chunk = v.map(|x| x.into());
1114            self
1115        }
1116    }
1117
1118    impl wkt::message::Message for DocumentReference {
1119        fn typename() -> &'static str {
1120            "type.googleapis.com/google.developers.knowledge.v1.Answer.DocumentReference"
1121        }
1122    }
1123}
1124
1125/// A DocumentChunk represents a piece of content from a
1126/// [Document][google.developers.knowledge.v1.Document] in the DeveloperKnowledge
1127/// corpus. To fetch the entire document content, pass the `parent` to
1128/// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1129/// or
1130/// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
1131///
1132/// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
1133/// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
1134/// [google.developers.knowledge.v1.Document]: crate::model::Document
1135#[derive(Clone, Default, PartialEq)]
1136#[non_exhaustive]
1137pub struct DocumentChunk {
1138    /// Output only. Contains the resource name of the document this chunk is from.
1139    /// Format: `documents/{uri_without_scheme}`
1140    /// Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
1141    pub parent: std::string::String,
1142
1143    /// Output only. Specifies the ID of this chunk within the document. The chunk
1144    /// ID is unique within a document, but not globally unique across documents.
1145    /// The chunk ID is not stable and may change over time.
1146    pub id: std::string::String,
1147
1148    /// Output only. Contains the content of the document chunk.
1149    pub content: std::string::String,
1150
1151    /// Output only. Represents metadata about the
1152    /// [Document][google.developers.knowledge.v1.Document] this chunk is from. The
1153    /// [DocumentView][google.developers.knowledge.v1.DocumentView] of this
1154    /// [Document][google.developers.knowledge.v1.Document] message will be set to
1155    /// `DOCUMENT_VIEW_BASIC`. It is included here for convenience so that clients
1156    /// do not need to call
1157    /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1158    /// or
1159    /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
1160    /// if they only need the metadata fields. Otherwise, clients should use
1161    /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1162    /// or
1163    /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
1164    /// to fetch the full document content.
1165    ///
1166    /// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
1167    /// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
1168    /// [google.developers.knowledge.v1.Document]: crate::model::Document
1169    /// [google.developers.knowledge.v1.DocumentView]: crate::model::DocumentView
1170    pub document: std::option::Option<crate::model::Document>,
1171
1172    /// Output only. Represents the relevance score of the chunk to the search
1173    /// query. Higher score indicates higher chunk relevance. The score is in range
1174    /// [0.0, 1.0].
1175    pub relevance_score: std::option::Option<f64>,
1176
1177    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1178}
1179
1180impl DocumentChunk {
1181    /// Creates a new default instance.
1182    pub fn new() -> Self {
1183        std::default::Default::default()
1184    }
1185
1186    /// Sets the value of [parent][crate::model::DocumentChunk::parent].
1187    ///
1188    /// # Example
1189    /// ```ignore,no_run
1190    /// # use google_developers_knowledge_v1::model::DocumentChunk;
1191    /// # let document_id = "document_id";
1192    /// let x = DocumentChunk::new().set_parent(format!("documents/{document_id}"));
1193    /// ```
1194    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1195        self.parent = v.into();
1196        self
1197    }
1198
1199    /// Sets the value of [id][crate::model::DocumentChunk::id].
1200    ///
1201    /// # Example
1202    /// ```ignore,no_run
1203    /// # use google_developers_knowledge_v1::model::DocumentChunk;
1204    /// let x = DocumentChunk::new().set_id("example");
1205    /// ```
1206    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1207        self.id = v.into();
1208        self
1209    }
1210
1211    /// Sets the value of [content][crate::model::DocumentChunk::content].
1212    ///
1213    /// # Example
1214    /// ```ignore,no_run
1215    /// # use google_developers_knowledge_v1::model::DocumentChunk;
1216    /// let x = DocumentChunk::new().set_content("example");
1217    /// ```
1218    pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1219        self.content = v.into();
1220        self
1221    }
1222
1223    /// Sets the value of [document][crate::model::DocumentChunk::document].
1224    ///
1225    /// # Example
1226    /// ```ignore,no_run
1227    /// # use google_developers_knowledge_v1::model::DocumentChunk;
1228    /// use google_developers_knowledge_v1::model::Document;
1229    /// let x = DocumentChunk::new().set_document(Document::default()/* use setters */);
1230    /// ```
1231    pub fn set_document<T>(mut self, v: T) -> Self
1232    where
1233        T: std::convert::Into<crate::model::Document>,
1234    {
1235        self.document = std::option::Option::Some(v.into());
1236        self
1237    }
1238
1239    /// Sets or clears the value of [document][crate::model::DocumentChunk::document].
1240    ///
1241    /// # Example
1242    /// ```ignore,no_run
1243    /// # use google_developers_knowledge_v1::model::DocumentChunk;
1244    /// use google_developers_knowledge_v1::model::Document;
1245    /// let x = DocumentChunk::new().set_or_clear_document(Some(Document::default()/* use setters */));
1246    /// let x = DocumentChunk::new().set_or_clear_document(None::<Document>);
1247    /// ```
1248    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1249    where
1250        T: std::convert::Into<crate::model::Document>,
1251    {
1252        self.document = v.map(|x| x.into());
1253        self
1254    }
1255
1256    /// Sets the value of [relevance_score][crate::model::DocumentChunk::relevance_score].
1257    ///
1258    /// # Example
1259    /// ```ignore,no_run
1260    /// # use google_developers_knowledge_v1::model::DocumentChunk;
1261    /// let x = DocumentChunk::new().set_relevance_score(42.0);
1262    /// ```
1263    pub fn set_relevance_score<T>(mut self, v: T) -> Self
1264    where
1265        T: std::convert::Into<f64>,
1266    {
1267        self.relevance_score = std::option::Option::Some(v.into());
1268        self
1269    }
1270
1271    /// Sets or clears the value of [relevance_score][crate::model::DocumentChunk::relevance_score].
1272    ///
1273    /// # Example
1274    /// ```ignore,no_run
1275    /// # use google_developers_knowledge_v1::model::DocumentChunk;
1276    /// let x = DocumentChunk::new().set_or_clear_relevance_score(Some(42.0));
1277    /// let x = DocumentChunk::new().set_or_clear_relevance_score(None::<f32>);
1278    /// ```
1279    pub fn set_or_clear_relevance_score<T>(mut self, v: std::option::Option<T>) -> Self
1280    where
1281        T: std::convert::Into<f64>,
1282    {
1283        self.relevance_score = v.map(|x| x.into());
1284        self
1285    }
1286}
1287
1288impl wkt::message::Message for DocumentChunk {
1289    fn typename() -> &'static str {
1290        "type.googleapis.com/google.developers.knowledge.v1.DocumentChunk"
1291    }
1292}
1293
1294/// Specifies which fields of the
1295/// [Document][google.developers.knowledge.v1.Document] are included.
1296///
1297/// [google.developers.knowledge.v1.Document]: crate::model::Document
1298///
1299/// # Working with unknown values
1300///
1301/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1302/// additional enum variants at any time. Adding new variants is not considered
1303/// a breaking change. Applications should write their code in anticipation of:
1304///
1305/// - New values appearing in future releases of the client library, **and**
1306/// - New values received dynamically, without application changes.
1307///
1308/// Please consult the [Working with enums] section in the user guide for some
1309/// guidelines.
1310///
1311/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1312#[derive(Clone, Debug, PartialEq)]
1313#[non_exhaustive]
1314pub enum DocumentView {
1315    /// The default / unset value. See each API method for its default value if
1316    /// [DocumentView][google.developers.knowledge.v1.DocumentView] is not
1317    /// specified.
1318    ///
1319    /// [google.developers.knowledge.v1.DocumentView]: crate::model::DocumentView
1320    Unspecified,
1321    /// Includes only the basic metadata fields:
1322    ///
1323    /// - `name`
1324    /// - `uri`
1325    /// - `data_source`
1326    /// - `title`
1327    /// - `description`
1328    /// - `update_time`
1329    /// - `view`
1330    /// - `content_length_bytes`
1331    ///
1332    /// This is the default of view for
1333    /// [DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
1334    ///
1335    /// [google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks]: crate::client::DeveloperKnowledge::search_document_chunks
1336    Basic,
1337    /// Includes all [Document][google.developers.knowledge.v1.Document] fields.
1338    ///
1339    /// [google.developers.knowledge.v1.Document]: crate::model::Document
1340    Full,
1341    /// Includes the `DOCUMENT_VIEW_BASIC` fields and the `content` field.
1342    ///
1343    /// This is the default of view for
1344    /// [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
1345    /// and
1346    /// [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
1347    ///
1348    /// [google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]: crate::client::DeveloperKnowledge::batch_get_documents
1349    /// [google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]: crate::client::DeveloperKnowledge::get_document
1350    Content,
1351    /// If set, the enum was initialized with an unknown value.
1352    ///
1353    /// Applications can examine the value using [DocumentView::value] or
1354    /// [DocumentView::name].
1355    UnknownValue(document_view::UnknownValue),
1356}
1357
1358#[doc(hidden)]
1359pub mod document_view {
1360    #[allow(unused_imports)]
1361    use super::*;
1362    #[derive(Clone, Debug, PartialEq)]
1363    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1364}
1365
1366impl DocumentView {
1367    /// Gets the enum value.
1368    ///
1369    /// Returns `None` if the enum contains an unknown value deserialized from
1370    /// the string representation of enums.
1371    pub fn value(&self) -> std::option::Option<i32> {
1372        match self {
1373            Self::Unspecified => std::option::Option::Some(0),
1374            Self::Basic => std::option::Option::Some(1),
1375            Self::Full => std::option::Option::Some(2),
1376            Self::Content => std::option::Option::Some(3),
1377            Self::UnknownValue(u) => u.0.value(),
1378        }
1379    }
1380
1381    /// Gets the enum value as a string.
1382    ///
1383    /// Returns `None` if the enum contains an unknown value deserialized from
1384    /// the integer representation of enums.
1385    pub fn name(&self) -> std::option::Option<&str> {
1386        match self {
1387            Self::Unspecified => std::option::Option::Some("DOCUMENT_VIEW_UNSPECIFIED"),
1388            Self::Basic => std::option::Option::Some("DOCUMENT_VIEW_BASIC"),
1389            Self::Full => std::option::Option::Some("DOCUMENT_VIEW_FULL"),
1390            Self::Content => std::option::Option::Some("DOCUMENT_VIEW_CONTENT"),
1391            Self::UnknownValue(u) => u.0.name(),
1392        }
1393    }
1394}
1395
1396impl std::default::Default for DocumentView {
1397    fn default() -> Self {
1398        use std::convert::From;
1399        Self::from(0)
1400    }
1401}
1402
1403impl std::fmt::Display for DocumentView {
1404    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1405        wkt::internal::display_enum(f, self.name(), self.value())
1406    }
1407}
1408
1409impl std::convert::From<i32> for DocumentView {
1410    fn from(value: i32) -> Self {
1411        match value {
1412            0 => Self::Unspecified,
1413            1 => Self::Basic,
1414            2 => Self::Full,
1415            3 => Self::Content,
1416            _ => Self::UnknownValue(document_view::UnknownValue(
1417                wkt::internal::UnknownEnumValue::Integer(value),
1418            )),
1419        }
1420    }
1421}
1422
1423impl std::convert::From<&str> for DocumentView {
1424    fn from(value: &str) -> Self {
1425        use std::string::ToString;
1426        match value {
1427            "DOCUMENT_VIEW_UNSPECIFIED" => Self::Unspecified,
1428            "DOCUMENT_VIEW_BASIC" => Self::Basic,
1429            "DOCUMENT_VIEW_FULL" => Self::Full,
1430            "DOCUMENT_VIEW_CONTENT" => Self::Content,
1431            _ => Self::UnknownValue(document_view::UnknownValue(
1432                wkt::internal::UnknownEnumValue::String(value.to_string()),
1433            )),
1434        }
1435    }
1436}
1437
1438impl serde::ser::Serialize for DocumentView {
1439    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1440    where
1441        S: serde::Serializer,
1442    {
1443        match self {
1444            Self::Unspecified => serializer.serialize_i32(0),
1445            Self::Basic => serializer.serialize_i32(1),
1446            Self::Full => serializer.serialize_i32(2),
1447            Self::Content => serializer.serialize_i32(3),
1448            Self::UnknownValue(u) => u.0.serialize(serializer),
1449        }
1450    }
1451}
1452
1453impl<'de> serde::de::Deserialize<'de> for DocumentView {
1454    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1455    where
1456        D: serde::Deserializer<'de>,
1457    {
1458        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DocumentView>::new(
1459            ".google.developers.knowledge.v1.DocumentView",
1460        ))
1461    }
1462}