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() -> 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 =
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    /// ```
78    /// # use google_cloud_devicestreaming_v1::builder::direct_access_service::CreateDeviceSession;
79    /// # async fn sample() -> gax::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<gax::options::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(gax::response::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 gax::options::internal::RequestBuilder for CreateDeviceSession {
162        fn request_options(&mut self) -> &mut gax::options::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() -> gax::Result<()> {
173    /// use 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<gax::options::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(gax::response::Response::into_body)
218        }
219
220        /// Streams each page in the collection.
221        pub fn by_page(
222            self,
223        ) -> impl gax::paginator::Paginator<crate::model::ListDeviceSessionsResponse, gax::error::Error>
224        {
225            use std::clone::Clone;
226            let token = self.0.request.page_token.clone();
227            let execute = move |token: String| {
228                let mut builder = self.clone();
229                builder.0.request = builder.0.request.set_page_token(token);
230                builder.send()
231            };
232            gax::paginator::internal::new_paginator(token, execute)
233        }
234
235        /// Streams each item in the collection.
236        pub fn by_item(
237            self,
238        ) -> impl gax::paginator::ItemPaginator<
239            crate::model::ListDeviceSessionsResponse,
240            gax::error::Error,
241        > {
242            use gax::paginator::Paginator;
243            self.by_page().items()
244        }
245
246        /// Sets the value of [parent][crate::model::ListDeviceSessionsRequest::parent].
247        ///
248        /// This is a **required** field for requests.
249        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
250            self.0.request.parent = v.into();
251            self
252        }
253
254        /// Sets the value of [page_size][crate::model::ListDeviceSessionsRequest::page_size].
255        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
256            self.0.request.page_size = v.into();
257            self
258        }
259
260        /// Sets the value of [page_token][crate::model::ListDeviceSessionsRequest::page_token].
261        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
262            self.0.request.page_token = v.into();
263            self
264        }
265
266        /// Sets the value of [filter][crate::model::ListDeviceSessionsRequest::filter].
267        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
268            self.0.request.filter = v.into();
269            self
270        }
271    }
272
273    #[doc(hidden)]
274    impl gax::options::internal::RequestBuilder for ListDeviceSessions {
275        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
276            &mut self.0.options
277        }
278    }
279
280    /// The request builder for [DirectAccessService::get_device_session][crate::client::DirectAccessService::get_device_session] calls.
281    ///
282    /// # Example
283    /// ```
284    /// # use google_cloud_devicestreaming_v1::builder::direct_access_service::GetDeviceSession;
285    /// # async fn sample() -> gax::Result<()> {
286    ///
287    /// let builder = prepare_request_builder();
288    /// let response = builder.send().await?;
289    /// # Ok(()) }
290    ///
291    /// fn prepare_request_builder() -> GetDeviceSession {
292    ///   # panic!();
293    ///   // ... details omitted ...
294    /// }
295    /// ```
296    #[derive(Clone, Debug)]
297    pub struct GetDeviceSession(RequestBuilder<crate::model::GetDeviceSessionRequest>);
298
299    impl GetDeviceSession {
300        pub(crate) fn new(
301            stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
302        ) -> Self {
303            Self(RequestBuilder::new(stub))
304        }
305
306        /// Sets the full request, replacing any prior values.
307        pub fn with_request<V: Into<crate::model::GetDeviceSessionRequest>>(
308            mut self,
309            v: V,
310        ) -> Self {
311            self.0.request = v.into();
312            self
313        }
314
315        /// Sets all the options, replacing any prior values.
316        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
317            self.0.options = v.into();
318            self
319        }
320
321        /// Sends the request.
322        pub async fn send(self) -> Result<crate::model::DeviceSession> {
323            (*self.0.stub)
324                .get_device_session(self.0.request, self.0.options)
325                .await
326                .map(gax::response::Response::into_body)
327        }
328
329        /// Sets the value of [name][crate::model::GetDeviceSessionRequest::name].
330        ///
331        /// This is a **required** field for requests.
332        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
333            self.0.request.name = v.into();
334            self
335        }
336    }
337
338    #[doc(hidden)]
339    impl gax::options::internal::RequestBuilder for GetDeviceSession {
340        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
341            &mut self.0.options
342        }
343    }
344
345    /// The request builder for [DirectAccessService::cancel_device_session][crate::client::DirectAccessService::cancel_device_session] calls.
346    ///
347    /// # Example
348    /// ```
349    /// # use google_cloud_devicestreaming_v1::builder::direct_access_service::CancelDeviceSession;
350    /// # async fn sample() -> gax::Result<()> {
351    ///
352    /// let builder = prepare_request_builder();
353    /// let response = builder.send().await?;
354    /// # Ok(()) }
355    ///
356    /// fn prepare_request_builder() -> CancelDeviceSession {
357    ///   # panic!();
358    ///   // ... details omitted ...
359    /// }
360    /// ```
361    #[derive(Clone, Debug)]
362    pub struct CancelDeviceSession(RequestBuilder<crate::model::CancelDeviceSessionRequest>);
363
364    impl CancelDeviceSession {
365        pub(crate) fn new(
366            stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
367        ) -> Self {
368            Self(RequestBuilder::new(stub))
369        }
370
371        /// Sets the full request, replacing any prior values.
372        pub fn with_request<V: Into<crate::model::CancelDeviceSessionRequest>>(
373            mut self,
374            v: V,
375        ) -> Self {
376            self.0.request = v.into();
377            self
378        }
379
380        /// Sets all the options, replacing any prior values.
381        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
382            self.0.options = v.into();
383            self
384        }
385
386        /// Sends the request.
387        pub async fn send(self) -> Result<()> {
388            (*self.0.stub)
389                .cancel_device_session(self.0.request, self.0.options)
390                .await
391                .map(gax::response::Response::into_body)
392        }
393
394        /// Sets the value of [name][crate::model::CancelDeviceSessionRequest::name].
395        ///
396        /// This is a **required** field for requests.
397        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
398            self.0.request.name = v.into();
399            self
400        }
401    }
402
403    #[doc(hidden)]
404    impl gax::options::internal::RequestBuilder for CancelDeviceSession {
405        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
406            &mut self.0.options
407        }
408    }
409
410    /// The request builder for [DirectAccessService::update_device_session][crate::client::DirectAccessService::update_device_session] calls.
411    ///
412    /// # Example
413    /// ```
414    /// # use google_cloud_devicestreaming_v1::builder::direct_access_service::UpdateDeviceSession;
415    /// # async fn sample() -> gax::Result<()> {
416    ///
417    /// let builder = prepare_request_builder();
418    /// let response = builder.send().await?;
419    /// # Ok(()) }
420    ///
421    /// fn prepare_request_builder() -> UpdateDeviceSession {
422    ///   # panic!();
423    ///   // ... details omitted ...
424    /// }
425    /// ```
426    #[derive(Clone, Debug)]
427    pub struct UpdateDeviceSession(RequestBuilder<crate::model::UpdateDeviceSessionRequest>);
428
429    impl UpdateDeviceSession {
430        pub(crate) fn new(
431            stub: std::sync::Arc<dyn super::super::stub::dynamic::DirectAccessService>,
432        ) -> Self {
433            Self(RequestBuilder::new(stub))
434        }
435
436        /// Sets the full request, replacing any prior values.
437        pub fn with_request<V: Into<crate::model::UpdateDeviceSessionRequest>>(
438            mut self,
439            v: V,
440        ) -> Self {
441            self.0.request = v.into();
442            self
443        }
444
445        /// Sets all the options, replacing any prior values.
446        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
447            self.0.options = v.into();
448            self
449        }
450
451        /// Sends the request.
452        pub async fn send(self) -> Result<crate::model::DeviceSession> {
453            (*self.0.stub)
454                .update_device_session(self.0.request, self.0.options)
455                .await
456                .map(gax::response::Response::into_body)
457        }
458
459        /// Sets the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
460        ///
461        /// This is a **required** field for requests.
462        pub fn set_device_session<T>(mut self, v: T) -> Self
463        where
464            T: std::convert::Into<crate::model::DeviceSession>,
465        {
466            self.0.request.device_session = std::option::Option::Some(v.into());
467            self
468        }
469
470        /// Sets or clears the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
471        ///
472        /// This is a **required** field for requests.
473        pub fn set_or_clear_device_session<T>(mut self, v: std::option::Option<T>) -> Self
474        where
475            T: std::convert::Into<crate::model::DeviceSession>,
476        {
477            self.0.request.device_session = v.map(|x| x.into());
478            self
479        }
480
481        /// Sets the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
482        pub fn set_update_mask<T>(mut self, v: T) -> Self
483        where
484            T: std::convert::Into<wkt::FieldMask>,
485        {
486            self.0.request.update_mask = std::option::Option::Some(v.into());
487            self
488        }
489
490        /// Sets or clears the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
491        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
492        where
493            T: std::convert::Into<wkt::FieldMask>,
494        {
495            self.0.request.update_mask = v.map(|x| x.into());
496            self
497        }
498    }
499
500    #[doc(hidden)]
501    impl gax::options::internal::RequestBuilder for UpdateDeviceSession {
502        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
503            &mut self.0.options
504        }
505    }
506}