Skip to main content

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