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