google_developers_knowledge_v1/builder.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/// Request and client builders for [DeveloperKnowledge][crate::client::DeveloperKnowledge].
18pub mod developer_knowledge {
19 use crate::Result;
20
21 /// A builder for [DeveloperKnowledge][crate::client::DeveloperKnowledge].
22 ///
23 /// ```
24 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25 /// # use google_developers_knowledge_v1::*;
26 /// # use builder::developer_knowledge::ClientBuilder;
27 /// # use client::DeveloperKnowledge;
28 /// let builder : ClientBuilder = DeveloperKnowledge::builder();
29 /// let client = builder
30 /// .with_endpoint("https://developerknowledge.googleapis.com")
31 /// .build().await?;
32 /// # Ok(()) }
33 /// ```
34 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::DeveloperKnowledge;
38 pub struct Factory;
39 impl crate::ClientFactory for Factory {
40 type Client = DeveloperKnowledge;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> crate::ClientBuilderResult<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 /// Common implementation for [crate::client::DeveloperKnowledge] request builders.
52 #[derive(Clone, Debug)]
53 pub(crate) struct RequestBuilder<R: std::default::Default> {
54 stub: std::sync::Arc<dyn super::super::stub::dynamic::DeveloperKnowledge>,
55 request: R,
56 options: crate::RequestOptions,
57 }
58
59 impl<R> RequestBuilder<R>
60 where
61 R: std::default::Default,
62 {
63 pub(crate) fn new(
64 stub: std::sync::Arc<dyn super::super::stub::dynamic::DeveloperKnowledge>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: crate::RequestOptions::default(),
70 }
71 }
72 }
73
74 /// The request builder for [DeveloperKnowledge::search_document_chunks][crate::client::DeveloperKnowledge::search_document_chunks] calls.
75 ///
76 /// # Example
77 /// ```
78 /// # use google_developers_knowledge_v1::builder::developer_knowledge::SearchDocumentChunks;
79 /// # async fn sample() -> google_developers_knowledge_v1::Result<()> {
80 /// use google_cloud_gax::paginator::ItemPaginator;
81 ///
82 /// let builder = prepare_request_builder();
83 /// let mut items = builder.by_item();
84 /// while let Some(result) = items.next().await {
85 /// let item = result?;
86 /// }
87 /// # Ok(()) }
88 ///
89 /// fn prepare_request_builder() -> SearchDocumentChunks {
90 /// # panic!();
91 /// // ... details omitted ...
92 /// }
93 /// ```
94 #[derive(Clone, Debug)]
95 pub struct SearchDocumentChunks(RequestBuilder<crate::model::SearchDocumentChunksRequest>);
96
97 impl SearchDocumentChunks {
98 pub(crate) fn new(
99 stub: std::sync::Arc<dyn super::super::stub::dynamic::DeveloperKnowledge>,
100 ) -> Self {
101 Self(RequestBuilder::new(stub))
102 }
103
104 /// Sets the full request, replacing any prior values.
105 pub fn with_request<V: Into<crate::model::SearchDocumentChunksRequest>>(
106 mut self,
107 v: V,
108 ) -> Self {
109 self.0.request = v.into();
110 self
111 }
112
113 /// Sets all the options, replacing any prior values.
114 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
115 self.0.options = v.into();
116 self
117 }
118
119 /// Sends the request.
120 pub async fn send(self) -> Result<crate::model::SearchDocumentChunksResponse> {
121 (*self.0.stub)
122 .search_document_chunks(self.0.request, self.0.options)
123 .await
124 .map(crate::Response::into_body)
125 }
126
127 /// Streams each page in the collection.
128 pub fn by_page(
129 self,
130 ) -> impl google_cloud_gax::paginator::Paginator<
131 crate::model::SearchDocumentChunksResponse,
132 crate::Error,
133 > {
134 use std::clone::Clone;
135 let token = self.0.request.page_token.clone();
136 let execute = move |token: String| {
137 let mut builder = self.clone();
138 builder.0.request = builder.0.request.set_page_token(token);
139 builder.send()
140 };
141 google_cloud_gax::paginator::internal::new_paginator(token, execute)
142 }
143
144 /// Streams each item in the collection.
145 pub fn by_item(
146 self,
147 ) -> impl google_cloud_gax::paginator::ItemPaginator<
148 crate::model::SearchDocumentChunksResponse,
149 crate::Error,
150 > {
151 use google_cloud_gax::paginator::Paginator;
152 self.by_page().items()
153 }
154
155 /// Sets the value of [query][crate::model::SearchDocumentChunksRequest::query].
156 ///
157 /// This is a **required** field for requests.
158 pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
159 self.0.request.query = v.into();
160 self
161 }
162
163 /// Sets the value of [page_size][crate::model::SearchDocumentChunksRequest::page_size].
164 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
165 self.0.request.page_size = v.into();
166 self
167 }
168
169 /// Sets the value of [page_token][crate::model::SearchDocumentChunksRequest::page_token].
170 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
171 self.0.request.page_token = v.into();
172 self
173 }
174
175 /// Sets the value of [filter][crate::model::SearchDocumentChunksRequest::filter].
176 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
177 self.0.request.filter = v.into();
178 self
179 }
180 }
181
182 #[doc(hidden)]
183 impl crate::RequestBuilder for SearchDocumentChunks {
184 fn request_options(&mut self) -> &mut crate::RequestOptions {
185 &mut self.0.options
186 }
187 }
188
189 /// The request builder for [DeveloperKnowledge::get_document][crate::client::DeveloperKnowledge::get_document] calls.
190 ///
191 /// # Example
192 /// ```
193 /// # use google_developers_knowledge_v1::builder::developer_knowledge::GetDocument;
194 /// # async fn sample() -> google_developers_knowledge_v1::Result<()> {
195 ///
196 /// let builder = prepare_request_builder();
197 /// let response = builder.send().await?;
198 /// # Ok(()) }
199 ///
200 /// fn prepare_request_builder() -> GetDocument {
201 /// # panic!();
202 /// // ... details omitted ...
203 /// }
204 /// ```
205 #[derive(Clone, Debug)]
206 pub struct GetDocument(RequestBuilder<crate::model::GetDocumentRequest>);
207
208 impl GetDocument {
209 pub(crate) fn new(
210 stub: std::sync::Arc<dyn super::super::stub::dynamic::DeveloperKnowledge>,
211 ) -> Self {
212 Self(RequestBuilder::new(stub))
213 }
214
215 /// Sets the full request, replacing any prior values.
216 pub fn with_request<V: Into<crate::model::GetDocumentRequest>>(mut self, v: V) -> Self {
217 self.0.request = v.into();
218 self
219 }
220
221 /// Sets all the options, replacing any prior values.
222 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
223 self.0.options = v.into();
224 self
225 }
226
227 /// Sends the request.
228 pub async fn send(self) -> Result<crate::model::Document> {
229 (*self.0.stub)
230 .get_document(self.0.request, self.0.options)
231 .await
232 .map(crate::Response::into_body)
233 }
234
235 /// Sets the value of [name][crate::model::GetDocumentRequest::name].
236 ///
237 /// This is a **required** field for requests.
238 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
239 self.0.request.name = v.into();
240 self
241 }
242
243 /// Sets the value of [view][crate::model::GetDocumentRequest::view].
244 pub fn set_view<T: Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
245 self.0.request.view = v.into();
246 self
247 }
248 }
249
250 #[doc(hidden)]
251 impl crate::RequestBuilder for GetDocument {
252 fn request_options(&mut self) -> &mut crate::RequestOptions {
253 &mut self.0.options
254 }
255 }
256
257 /// The request builder for [DeveloperKnowledge::batch_get_documents][crate::client::DeveloperKnowledge::batch_get_documents] calls.
258 ///
259 /// # Example
260 /// ```
261 /// # use google_developers_knowledge_v1::builder::developer_knowledge::BatchGetDocuments;
262 /// # async fn sample() -> google_developers_knowledge_v1::Result<()> {
263 ///
264 /// let builder = prepare_request_builder();
265 /// let response = builder.send().await?;
266 /// # Ok(()) }
267 ///
268 /// fn prepare_request_builder() -> BatchGetDocuments {
269 /// # panic!();
270 /// // ... details omitted ...
271 /// }
272 /// ```
273 #[derive(Clone, Debug)]
274 pub struct BatchGetDocuments(RequestBuilder<crate::model::BatchGetDocumentsRequest>);
275
276 impl BatchGetDocuments {
277 pub(crate) fn new(
278 stub: std::sync::Arc<dyn super::super::stub::dynamic::DeveloperKnowledge>,
279 ) -> Self {
280 Self(RequestBuilder::new(stub))
281 }
282
283 /// Sets the full request, replacing any prior values.
284 pub fn with_request<V: Into<crate::model::BatchGetDocumentsRequest>>(
285 mut self,
286 v: V,
287 ) -> Self {
288 self.0.request = v.into();
289 self
290 }
291
292 /// Sets all the options, replacing any prior values.
293 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
294 self.0.options = v.into();
295 self
296 }
297
298 /// Sends the request.
299 pub async fn send(self) -> Result<crate::model::BatchGetDocumentsResponse> {
300 (*self.0.stub)
301 .batch_get_documents(self.0.request, self.0.options)
302 .await
303 .map(crate::Response::into_body)
304 }
305
306 /// Sets the value of [names][crate::model::BatchGetDocumentsRequest::names].
307 ///
308 /// This is a **required** field for requests.
309 pub fn set_names<T, V>(mut self, v: T) -> Self
310 where
311 T: std::iter::IntoIterator<Item = V>,
312 V: std::convert::Into<std::string::String>,
313 {
314 use std::iter::Iterator;
315 self.0.request.names = v.into_iter().map(|i| i.into()).collect();
316 self
317 }
318
319 /// Sets the value of [view][crate::model::BatchGetDocumentsRequest::view].
320 pub fn set_view<T: Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
321 self.0.request.view = v.into();
322 self
323 }
324 }
325
326 #[doc(hidden)]
327 impl crate::RequestBuilder for BatchGetDocuments {
328 fn request_options(&mut self) -> &mut crate::RequestOptions {
329 &mut self.0.options
330 }
331 }
332
333 /// The request builder for [DeveloperKnowledge::answer_query][crate::client::DeveloperKnowledge::answer_query] calls.
334 ///
335 /// # Example
336 /// ```
337 /// # use google_developers_knowledge_v1::builder::developer_knowledge::AnswerQuery;
338 /// # async fn sample() -> google_developers_knowledge_v1::Result<()> {
339 ///
340 /// let builder = prepare_request_builder();
341 /// let response = builder.send().await?;
342 /// # Ok(()) }
343 ///
344 /// fn prepare_request_builder() -> AnswerQuery {
345 /// # panic!();
346 /// // ... details omitted ...
347 /// }
348 /// ```
349 #[derive(Clone, Debug)]
350 pub struct AnswerQuery(RequestBuilder<crate::model::AnswerQueryRequest>);
351
352 impl AnswerQuery {
353 pub(crate) fn new(
354 stub: std::sync::Arc<dyn super::super::stub::dynamic::DeveloperKnowledge>,
355 ) -> Self {
356 Self(RequestBuilder::new(stub))
357 }
358
359 /// Sets the full request, replacing any prior values.
360 pub fn with_request<V: Into<crate::model::AnswerQueryRequest>>(mut self, v: V) -> Self {
361 self.0.request = v.into();
362 self
363 }
364
365 /// Sets all the options, replacing any prior values.
366 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
367 self.0.options = v.into();
368 self
369 }
370
371 /// Sends the request.
372 pub async fn send(self) -> Result<crate::model::AnswerQueryResponse> {
373 (*self.0.stub)
374 .answer_query(self.0.request, self.0.options)
375 .await
376 .map(crate::Response::into_body)
377 }
378
379 /// Sets the value of [query][crate::model::AnswerQueryRequest::query].
380 ///
381 /// This is a **required** field for requests.
382 pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
383 self.0.request.query = v.into();
384 self
385 }
386 }
387
388 #[doc(hidden)]
389 impl crate::RequestBuilder for AnswerQuery {
390 fn request_options(&mut self) -> &mut crate::RequestOptions {
391 &mut self.0.options
392 }
393 }
394}