google_cloud_devicestreaming_v1/builder.rs
1// Copyright 2025 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
17pub mod direct_access_service {
18 use crate::Result;
19
20 /// A builder for [DirectAccessService][crate::client::DirectAccessService].
21 ///
22 /// ```
23 /// # tokio_test::block_on(async {
24 /// # use google_cloud_devicestreaming_v1::*;
25 /// # use builder::direct_access_service::ClientBuilder;
26 /// # use client::DirectAccessService;
27 /// let builder : ClientBuilder = DirectAccessService::builder();
28 /// let client = builder
29 /// .with_endpoint("https://devicestreaming.googleapis.com")
30 /// .build().await?;
31 /// # gax::client_builder::Result::<()>::Ok(()) });
32 /// ```
33 pub type ClientBuilder =
34 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::DirectAccessService;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = DirectAccessService;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> gax::client_builder::Result<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 /// Common implementation for [crate::client::DirectAccessService] 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::DirectAccessService>,
55 request: R,
56 options: gax::options::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::DirectAccessService>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: gax::options::RequestOptions::default(),
70 }
71 }
72 }
73
74 /// The request builder for [DirectAccessService::create_device_session][crate::client::DirectAccessService::create_device_session] calls.
75 ///
76 /// # Example
77 /// ```no_run
78 /// # use google_cloud_devicestreaming_v1::builder;
79 /// use builder::direct_access_service::CreateDeviceSession;
80 /// # tokio_test::block_on(async {
81 ///
82 /// let builder = prepare_request_builder();
83 /// let response = builder.send().await?;
84 /// # gax::Result::<()>::Ok(()) });
85 ///
86 /// fn prepare_request_builder() -> CreateDeviceSession {
87 /// # panic!();
88 /// // ... details omitted ...
89 /// }
90 /// ```
91 #[derive(Clone, Debug)]
92 pub struct CreateDeviceSession(RequestBuilder<crate::model::CreateDeviceSessionRequest>);
93
94 impl CreateDeviceSession {
95 pub(crate) fn new(
96 stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
97 ) -> Self {
98 Self(RequestBuilder::new(stub))
99 }
100
101 /// Sets the full request, replacing any prior values.
102 pub fn with_request<V: Into<crate::model::CreateDeviceSessionRequest>>(
103 mut self,
104 v: V,
105 ) -> Self {
106 self.0.request = v.into();
107 self
108 }
109
110 /// Sets all the options, replacing any prior values.
111 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
112 self.0.options = v.into();
113 self
114 }
115
116 /// Sends the request.
117 pub async fn send(self) -> Result<crate::model::DeviceSession> {
118 (*self.0.stub)
119 .create_device_session(self.0.request, self.0.options)
120 .await
121 .map(gax::response::Response::into_body)
122 }
123
124 /// Sets the value of [parent][crate::model::CreateDeviceSessionRequest::parent].
125 ///
126 /// This is a **required** field for requests.
127 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
128 self.0.request.parent = v.into();
129 self
130 }
131
132 /// Sets the value of [device_session][crate::model::CreateDeviceSessionRequest::device_session].
133 ///
134 /// This is a **required** field for requests.
135 pub fn set_device_session<T>(mut self, v: T) -> Self
136 where
137 T: std::convert::Into<crate::model::DeviceSession>,
138 {
139 self.0.request.device_session = std::option::Option::Some(v.into());
140 self
141 }
142
143 /// Sets or clears the value of [device_session][crate::model::CreateDeviceSessionRequest::device_session].
144 ///
145 /// This is a **required** field for requests.
146 pub fn set_or_clear_device_session<T>(mut self, v: std::option::Option<T>) -> Self
147 where
148 T: std::convert::Into<crate::model::DeviceSession>,
149 {
150 self.0.request.device_session = v.map(|x| x.into());
151 self
152 }
153
154 /// Sets the value of [device_session_id][crate::model::CreateDeviceSessionRequest::device_session_id].
155 pub fn set_device_session_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
156 self.0.request.device_session_id = v.into();
157 self
158 }
159 }
160
161 #[doc(hidden)]
162 impl gax::options::internal::RequestBuilder for CreateDeviceSession {
163 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
164 &mut self.0.options
165 }
166 }
167
168 /// The request builder for [DirectAccessService::list_device_sessions][crate::client::DirectAccessService::list_device_sessions] calls.
169 ///
170 /// # Example
171 /// ```no_run
172 /// # use google_cloud_devicestreaming_v1::builder;
173 /// use builder::direct_access_service::ListDeviceSessions;
174 /// # tokio_test::block_on(async {
175 /// use gax::paginator::ItemPaginator;
176 ///
177 /// let builder = prepare_request_builder();
178 /// let mut items = builder.by_item();
179 /// while let Some(result) = items.next().await {
180 /// let item = result?;
181 /// }
182 /// # gax::Result::<()>::Ok(()) });
183 ///
184 /// fn prepare_request_builder() -> ListDeviceSessions {
185 /// # panic!();
186 /// // ... details omitted ...
187 /// }
188 /// ```
189 #[derive(Clone, Debug)]
190 pub struct ListDeviceSessions(RequestBuilder<crate::model::ListDeviceSessionsRequest>);
191
192 impl ListDeviceSessions {
193 pub(crate) fn new(
194 stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
195 ) -> Self {
196 Self(RequestBuilder::new(stub))
197 }
198
199 /// Sets the full request, replacing any prior values.
200 pub fn with_request<V: Into<crate::model::ListDeviceSessionsRequest>>(
201 mut self,
202 v: V,
203 ) -> Self {
204 self.0.request = v.into();
205 self
206 }
207
208 /// Sets all the options, replacing any prior values.
209 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
210 self.0.options = v.into();
211 self
212 }
213
214 /// Sends the request.
215 pub async fn send(self) -> Result<crate::model::ListDeviceSessionsResponse> {
216 (*self.0.stub)
217 .list_device_sessions(self.0.request, self.0.options)
218 .await
219 .map(gax::response::Response::into_body)
220 }
221
222 /// Streams each page in the collection.
223 pub fn by_page(
224 self,
225 ) -> impl gax::paginator::Paginator<crate::model::ListDeviceSessionsResponse, gax::error::Error>
226 {
227 use std::clone::Clone;
228 let token = self.0.request.page_token.clone();
229 let execute = move |token: String| {
230 let mut builder = self.clone();
231 builder.0.request = builder.0.request.set_page_token(token);
232 builder.send()
233 };
234 gax::paginator::internal::new_paginator(token, execute)
235 }
236
237 /// Streams each item in the collection.
238 pub fn by_item(
239 self,
240 ) -> impl gax::paginator::ItemPaginator<
241 crate::model::ListDeviceSessionsResponse,
242 gax::error::Error,
243 > {
244 use gax::paginator::Paginator;
245 self.by_page().items()
246 }
247
248 /// Sets the value of [parent][crate::model::ListDeviceSessionsRequest::parent].
249 ///
250 /// This is a **required** field for requests.
251 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
252 self.0.request.parent = v.into();
253 self
254 }
255
256 /// Sets the value of [page_size][crate::model::ListDeviceSessionsRequest::page_size].
257 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
258 self.0.request.page_size = v.into();
259 self
260 }
261
262 /// Sets the value of [page_token][crate::model::ListDeviceSessionsRequest::page_token].
263 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
264 self.0.request.page_token = v.into();
265 self
266 }
267
268 /// Sets the value of [filter][crate::model::ListDeviceSessionsRequest::filter].
269 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
270 self.0.request.filter = v.into();
271 self
272 }
273 }
274
275 #[doc(hidden)]
276 impl gax::options::internal::RequestBuilder for ListDeviceSessions {
277 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
278 &mut self.0.options
279 }
280 }
281
282 /// The request builder for [DirectAccessService::get_device_session][crate::client::DirectAccessService::get_device_session] calls.
283 ///
284 /// # Example
285 /// ```no_run
286 /// # use google_cloud_devicestreaming_v1::builder;
287 /// use builder::direct_access_service::GetDeviceSession;
288 /// # tokio_test::block_on(async {
289 ///
290 /// let builder = prepare_request_builder();
291 /// let response = builder.send().await?;
292 /// # gax::Result::<()>::Ok(()) });
293 ///
294 /// fn prepare_request_builder() -> GetDeviceSession {
295 /// # panic!();
296 /// // ... details omitted ...
297 /// }
298 /// ```
299 #[derive(Clone, Debug)]
300 pub struct GetDeviceSession(RequestBuilder<crate::model::GetDeviceSessionRequest>);
301
302 impl GetDeviceSession {
303 pub(crate) fn new(
304 stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
305 ) -> Self {
306 Self(RequestBuilder::new(stub))
307 }
308
309 /// Sets the full request, replacing any prior values.
310 pub fn with_request<V: Into<crate::model::GetDeviceSessionRequest>>(
311 mut self,
312 v: V,
313 ) -> Self {
314 self.0.request = v.into();
315 self
316 }
317
318 /// Sets all the options, replacing any prior values.
319 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
320 self.0.options = v.into();
321 self
322 }
323
324 /// Sends the request.
325 pub async fn send(self) -> Result<crate::model::DeviceSession> {
326 (*self.0.stub)
327 .get_device_session(self.0.request, self.0.options)
328 .await
329 .map(gax::response::Response::into_body)
330 }
331
332 /// Sets the value of [name][crate::model::GetDeviceSessionRequest::name].
333 ///
334 /// This is a **required** field for requests.
335 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
336 self.0.request.name = v.into();
337 self
338 }
339 }
340
341 #[doc(hidden)]
342 impl gax::options::internal::RequestBuilder for GetDeviceSession {
343 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
344 &mut self.0.options
345 }
346 }
347
348 /// The request builder for [DirectAccessService::cancel_device_session][crate::client::DirectAccessService::cancel_device_session] calls.
349 ///
350 /// # Example
351 /// ```no_run
352 /// # use google_cloud_devicestreaming_v1::builder;
353 /// use builder::direct_access_service::CancelDeviceSession;
354 /// # tokio_test::block_on(async {
355 ///
356 /// let builder = prepare_request_builder();
357 /// let response = builder.send().await?;
358 /// # gax::Result::<()>::Ok(()) });
359 ///
360 /// fn prepare_request_builder() -> CancelDeviceSession {
361 /// # panic!();
362 /// // ... details omitted ...
363 /// }
364 /// ```
365 #[derive(Clone, Debug)]
366 pub struct CancelDeviceSession(RequestBuilder<crate::model::CancelDeviceSessionRequest>);
367
368 impl CancelDeviceSession {
369 pub(crate) fn new(
370 stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
371 ) -> Self {
372 Self(RequestBuilder::new(stub))
373 }
374
375 /// Sets the full request, replacing any prior values.
376 pub fn with_request<V: Into<crate::model::CancelDeviceSessionRequest>>(
377 mut self,
378 v: V,
379 ) -> Self {
380 self.0.request = v.into();
381 self
382 }
383
384 /// Sets all the options, replacing any prior values.
385 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
386 self.0.options = v.into();
387 self
388 }
389
390 /// Sends the request.
391 pub async fn send(self) -> Result<()> {
392 (*self.0.stub)
393 .cancel_device_session(self.0.request, self.0.options)
394 .await
395 .map(gax::response::Response::into_body)
396 }
397
398 /// Sets the value of [name][crate::model::CancelDeviceSessionRequest::name].
399 ///
400 /// This is a **required** field for requests.
401 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
402 self.0.request.name = v.into();
403 self
404 }
405 }
406
407 #[doc(hidden)]
408 impl gax::options::internal::RequestBuilder for CancelDeviceSession {
409 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
410 &mut self.0.options
411 }
412 }
413
414 /// The request builder for [DirectAccessService::update_device_session][crate::client::DirectAccessService::update_device_session] calls.
415 ///
416 /// # Example
417 /// ```no_run
418 /// # use google_cloud_devicestreaming_v1::builder;
419 /// use builder::direct_access_service::UpdateDeviceSession;
420 /// # tokio_test::block_on(async {
421 ///
422 /// let builder = prepare_request_builder();
423 /// let response = builder.send().await?;
424 /// # gax::Result::<()>::Ok(()) });
425 ///
426 /// fn prepare_request_builder() -> UpdateDeviceSession {
427 /// # panic!();
428 /// // ... details omitted ...
429 /// }
430 /// ```
431 #[derive(Clone, Debug)]
432 pub struct UpdateDeviceSession(RequestBuilder<crate::model::UpdateDeviceSessionRequest>);
433
434 impl UpdateDeviceSession {
435 pub(crate) fn new(
436 stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
437 ) -> Self {
438 Self(RequestBuilder::new(stub))
439 }
440
441 /// Sets the full request, replacing any prior values.
442 pub fn with_request<V: Into<crate::model::UpdateDeviceSessionRequest>>(
443 mut self,
444 v: V,
445 ) -> Self {
446 self.0.request = v.into();
447 self
448 }
449
450 /// Sets all the options, replacing any prior values.
451 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
452 self.0.options = v.into();
453 self
454 }
455
456 /// Sends the request.
457 pub async fn send(self) -> Result<crate::model::DeviceSession> {
458 (*self.0.stub)
459 .update_device_session(self.0.request, self.0.options)
460 .await
461 .map(gax::response::Response::into_body)
462 }
463
464 /// Sets the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
465 ///
466 /// This is a **required** field for requests.
467 pub fn set_device_session<T>(mut self, v: T) -> Self
468 where
469 T: std::convert::Into<crate::model::DeviceSession>,
470 {
471 self.0.request.device_session = std::option::Option::Some(v.into());
472 self
473 }
474
475 /// Sets or clears the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
476 ///
477 /// This is a **required** field for requests.
478 pub fn set_or_clear_device_session<T>(mut self, v: std::option::Option<T>) -> Self
479 where
480 T: std::convert::Into<crate::model::DeviceSession>,
481 {
482 self.0.request.device_session = v.map(|x| x.into());
483 self
484 }
485
486 /// Sets the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
487 pub fn set_update_mask<T>(mut self, v: T) -> Self
488 where
489 T: std::convert::Into<wkt::FieldMask>,
490 {
491 self.0.request.update_mask = std::option::Option::Some(v.into());
492 self
493 }
494
495 /// Sets or clears the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
496 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
497 where
498 T: std::convert::Into<wkt::FieldMask>,
499 {
500 self.0.request.update_mask = v.map(|x| x.into());
501 self
502 }
503 }
504
505 #[doc(hidden)]
506 impl gax::options::internal::RequestBuilder for UpdateDeviceSession {
507 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
508 &mut self.0.options
509 }
510 }
511}