google_smartdevicemanagement1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See and/or control the devices that you selected
17    SdmService,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::SdmService => "https://www.googleapis.com/auth/sdm.service",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::SdmService
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all SmartDeviceManagement related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
49/// use smartdevicemanagement1::{Result, Error};
50/// # async fn dox() {
51/// use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace  `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62///     .with_native_roots()
63///     .unwrap()
64///     .https_only()
65///     .enable_http2()
66///     .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70///     secret,
71///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72///     yup_oauth2::client::CustomHyperClientBuilder::from(
73///         hyper_util::client::legacy::Client::builder(executor).build(connector),
74///     ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78///     hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81///     hyper_rustls::HttpsConnectorBuilder::new()
82///         .with_native_roots()
83///         .unwrap()
84///         .https_or_http()
85///         .enable_http2()
86///         .build()
87/// );
88/// let mut hub = SmartDeviceManagement::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.enterprises().devices_get("name")
93///              .doit().await;
94///
95/// match result {
96///     Err(e) => match e {
97///         // The Error enum provides details about what exactly happened.
98///         // You can also just use its `Debug`, `Display` or `Error` traits
99///          Error::HttpError(_)
100///         |Error::Io(_)
101///         |Error::MissingAPIKey
102///         |Error::MissingToken(_)
103///         |Error::Cancelled
104///         |Error::UploadSizeLimitExceeded(_, _)
105///         |Error::Failure(_)
106///         |Error::BadRequest(_)
107///         |Error::FieldClash(_)
108///         |Error::JsonDecodeError(_, _) => println!("{}", e),
109///     },
110///     Ok(res) => println!("Success: {:?}", res),
111/// }
112/// # }
113/// ```
114#[derive(Clone)]
115pub struct SmartDeviceManagement<C> {
116    pub client: common::Client<C>,
117    pub auth: Box<dyn common::GetToken>,
118    _user_agent: String,
119    _base_url: String,
120    _root_url: String,
121}
122
123impl<C> common::Hub for SmartDeviceManagement<C> {}
124
125impl<'a, C> SmartDeviceManagement<C> {
126    pub fn new<A: 'static + common::GetToken>(
127        client: common::Client<C>,
128        auth: A,
129    ) -> SmartDeviceManagement<C> {
130        SmartDeviceManagement {
131            client,
132            auth: Box::new(auth),
133            _user_agent: "google-api-rust-client/7.0.0".to_string(),
134            _base_url: "https://smartdevicemanagement.googleapis.com/".to_string(),
135            _root_url: "https://smartdevicemanagement.googleapis.com/".to_string(),
136        }
137    }
138
139    pub fn enterprises(&'a self) -> EnterpriseMethods<'a, C> {
140        EnterpriseMethods { hub: self }
141    }
142
143    /// Set the user-agent header field to use in all requests to the server.
144    /// It defaults to `google-api-rust-client/7.0.0`.
145    ///
146    /// Returns the previously set user-agent.
147    pub fn user_agent(&mut self, agent_name: String) -> String {
148        std::mem::replace(&mut self._user_agent, agent_name)
149    }
150
151    /// Set the base url to use in all requests to the server.
152    /// It defaults to `https://smartdevicemanagement.googleapis.com/`.
153    ///
154    /// Returns the previously set base url.
155    pub fn base_url(&mut self, new_base_url: String) -> String {
156        std::mem::replace(&mut self._base_url, new_base_url)
157    }
158
159    /// Set the root url to use in all requests to the server.
160    /// It defaults to `https://smartdevicemanagement.googleapis.com/`.
161    ///
162    /// Returns the previously set root url.
163    pub fn root_url(&mut self, new_root_url: String) -> String {
164        std::mem::replace(&mut self._root_url, new_root_url)
165    }
166}
167
168// ############
169// SCHEMAS ###
170// ##########
171/// Device resource represents an instance of enterprise managed device in the property.
172///
173/// # Activities
174///
175/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
176/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
177///
178/// * [devices get enterprises](EnterpriseDeviceGetCall) (response)
179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
180#[serde_with::serde_as]
181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
182pub struct GoogleHomeEnterpriseSdmV1Device {
183    /// Required. The resource name of the device. For example: "enterprises/XYZ/devices/123".
184    pub name: Option<String>,
185    /// Assignee details of the device.
186    #[serde(rename = "parentRelations")]
187    pub parent_relations: Option<Vec<GoogleHomeEnterpriseSdmV1ParentRelation>>,
188    /// Output only. Device traits.
189    pub traits: Option<HashMap<String, serde_json::Value>>,
190    /// Output only. Type of the device for general display purposes. For example: "THERMOSTAT". The device type should not be used to deduce or infer functionality of the actual device it is assigned to. Instead, use the returned traits for the device.
191    #[serde(rename = "type")]
192    pub type_: Option<String>,
193}
194
195impl common::ResponseResult for GoogleHomeEnterpriseSdmV1Device {}
196
197/// Request message for SmartDeviceManagementService.ExecuteDeviceCommand
198///
199/// # Activities
200///
201/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
202/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
203///
204/// * [devices execute command enterprises](EnterpriseDeviceExecuteCommandCall) (request)
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandRequest {
209    /// The command name to execute, represented by the fully qualified protobuf message name.
210    pub command: Option<String>,
211    /// The command message to execute, represented as a Struct.
212    pub params: Option<HashMap<String, serde_json::Value>>,
213}
214
215impl common::RequestValue for GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandRequest {}
216
217/// Response message for SmartDeviceManagementService.ExecuteDeviceCommand
218///
219/// # Activities
220///
221/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
222/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
223///
224/// * [devices execute command enterprises](EnterpriseDeviceExecuteCommandCall) (response)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandResponse {
229    /// The results of executing the command.
230    pub results: Option<HashMap<String, serde_json::Value>>,
231}
232
233impl common::ResponseResult for GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandResponse {}
234
235/// Response message for SmartDeviceManagementService.ListDevices
236///
237/// # Activities
238///
239/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
240/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
241///
242/// * [devices list enterprises](EnterpriseDeviceListCall) (response)
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct GoogleHomeEnterpriseSdmV1ListDevicesResponse {
247    /// The list of devices.
248    pub devices: Option<Vec<GoogleHomeEnterpriseSdmV1Device>>,
249}
250
251impl common::ResponseResult for GoogleHomeEnterpriseSdmV1ListDevicesResponse {}
252
253/// Response message for SmartDeviceManagementService.ListRooms
254///
255/// # Activities
256///
257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
259///
260/// * [structures rooms list enterprises](EnterpriseStructureRoomListCall) (response)
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct GoogleHomeEnterpriseSdmV1ListRoomsResponse {
265    /// The list of rooms.
266    pub rooms: Option<Vec<GoogleHomeEnterpriseSdmV1Room>>,
267}
268
269impl common::ResponseResult for GoogleHomeEnterpriseSdmV1ListRoomsResponse {}
270
271/// Response message for SmartDeviceManagementService.ListStructures
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [structures list enterprises](EnterpriseStructureListCall) (response)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct GoogleHomeEnterpriseSdmV1ListStructuresResponse {
283    /// The list of structures.
284    pub structures: Option<Vec<GoogleHomeEnterpriseSdmV1Structure>>,
285}
286
287impl common::ResponseResult for GoogleHomeEnterpriseSdmV1ListStructuresResponse {}
288
289/// Represents device relationships, for instance, structure/room to which the device is assigned to.
290///
291/// This type is not used in any activity, and only used as *part* of another schema.
292///
293#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
294#[serde_with::serde_as]
295#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
296pub struct GoogleHomeEnterpriseSdmV1ParentRelation {
297    /// Output only. The custom name of the relation -- e.g., structure/room where the device is assigned to.
298    #[serde(rename = "displayName")]
299    pub display_name: Option<String>,
300    /// Output only. The name of the relation -- e.g., structure/room where the device is assigned to. For example: "enterprises/XYZ/structures/ABC" or "enterprises/XYZ/structures/ABC/rooms/123"
301    pub parent: Option<String>,
302}
303
304impl common::Part for GoogleHomeEnterpriseSdmV1ParentRelation {}
305
306/// Room resource represents an instance of sub-space within a structure such as rooms in a hotel suite or rental apartment.
307///
308/// # Activities
309///
310/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
311/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
312///
313/// * [structures rooms get enterprises](EnterpriseStructureRoomGetCall) (response)
314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
315#[serde_with::serde_as]
316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
317pub struct GoogleHomeEnterpriseSdmV1Room {
318    /// Output only. The resource name of the room. For example: "enterprises/XYZ/structures/ABC/rooms/123".
319    pub name: Option<String>,
320    /// Room traits.
321    pub traits: Option<HashMap<String, serde_json::Value>>,
322}
323
324impl common::ResponseResult for GoogleHomeEnterpriseSdmV1Room {}
325
326/// Structure resource represents an instance of enterprise managed home or hotel room.
327///
328/// # Activities
329///
330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
332///
333/// * [structures get enterprises](EnterpriseStructureGetCall) (response)
334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
335#[serde_with::serde_as]
336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
337pub struct GoogleHomeEnterpriseSdmV1Structure {
338    /// Output only. The resource name of the structure. For example: "enterprises/XYZ/structures/ABC".
339    pub name: Option<String>,
340    /// Structure traits.
341    pub traits: Option<HashMap<String, serde_json::Value>>,
342}
343
344impl common::ResponseResult for GoogleHomeEnterpriseSdmV1Structure {}
345
346// ###################
347// MethodBuilders ###
348// #################
349
350/// A builder providing access to all methods supported on *enterprise* resources.
351/// It is not used directly, but through the [`SmartDeviceManagement`] hub.
352///
353/// # Example
354///
355/// Instantiate a resource builder
356///
357/// ```test_harness,no_run
358/// extern crate hyper;
359/// extern crate hyper_rustls;
360/// extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
361///
362/// # async fn dox() {
363/// use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
364///
365/// let secret: yup_oauth2::ApplicationSecret = Default::default();
366/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
367///     .with_native_roots()
368///     .unwrap()
369///     .https_only()
370///     .enable_http2()
371///     .build();
372///
373/// let executor = hyper_util::rt::TokioExecutor::new();
374/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
375///     secret,
376///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
377///     yup_oauth2::client::CustomHyperClientBuilder::from(
378///         hyper_util::client::legacy::Client::builder(executor).build(connector),
379///     ),
380/// ).build().await.unwrap();
381///
382/// let client = hyper_util::client::legacy::Client::builder(
383///     hyper_util::rt::TokioExecutor::new()
384/// )
385/// .build(
386///     hyper_rustls::HttpsConnectorBuilder::new()
387///         .with_native_roots()
388///         .unwrap()
389///         .https_or_http()
390///         .enable_http2()
391///         .build()
392/// );
393/// let mut hub = SmartDeviceManagement::new(client, auth);
394/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
395/// // like `devices_execute_command(...)`, `devices_get(...)`, `devices_list(...)`, `structures_get(...)`, `structures_list(...)`, `structures_rooms_get(...)` and `structures_rooms_list(...)`
396/// // to build up your call.
397/// let rb = hub.enterprises();
398/// # }
399/// ```
400pub struct EnterpriseMethods<'a, C>
401where
402    C: 'a,
403{
404    hub: &'a SmartDeviceManagement<C>,
405}
406
407impl<'a, C> common::MethodsBuilder for EnterpriseMethods<'a, C> {}
408
409impl<'a, C> EnterpriseMethods<'a, C> {
410    /// Create a builder to help you perform the following task:
411    ///
412    /// Executes a command to device managed by the enterprise.
413    ///
414    /// # Arguments
415    ///
416    /// * `request` - No description provided.
417    /// * `name` - The name of the device requested. For example: "enterprises/XYZ/devices/123"
418    pub fn devices_execute_command(
419        &self,
420        request: GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandRequest,
421        name: &str,
422    ) -> EnterpriseDeviceExecuteCommandCall<'a, C> {
423        EnterpriseDeviceExecuteCommandCall {
424            hub: self.hub,
425            _request: request,
426            _name: name.to_string(),
427            _delegate: Default::default(),
428            _additional_params: Default::default(),
429            _scopes: Default::default(),
430        }
431    }
432
433    /// Create a builder to help you perform the following task:
434    ///
435    /// Gets a device managed by the enterprise.
436    ///
437    /// # Arguments
438    ///
439    /// * `name` - The name of the device requested. For example: "enterprises/XYZ/devices/123"
440    pub fn devices_get(&self, name: &str) -> EnterpriseDeviceGetCall<'a, C> {
441        EnterpriseDeviceGetCall {
442            hub: self.hub,
443            _name: name.to_string(),
444            _delegate: Default::default(),
445            _additional_params: Default::default(),
446            _scopes: Default::default(),
447        }
448    }
449
450    /// Create a builder to help you perform the following task:
451    ///
452    /// Lists devices managed by the enterprise.
453    ///
454    /// # Arguments
455    ///
456    /// * `parent` - The parent enterprise to list devices under. E.g. "enterprises/XYZ".
457    pub fn devices_list(&self, parent: &str) -> EnterpriseDeviceListCall<'a, C> {
458        EnterpriseDeviceListCall {
459            hub: self.hub,
460            _parent: parent.to_string(),
461            _filter: Default::default(),
462            _delegate: Default::default(),
463            _additional_params: Default::default(),
464            _scopes: Default::default(),
465        }
466    }
467
468    /// Create a builder to help you perform the following task:
469    ///
470    /// Gets a room managed by the enterprise.
471    ///
472    /// # Arguments
473    ///
474    /// * `name` - The name of the room requested. For example: "enterprises/XYZ/structures/ABC/rooms/123".
475    pub fn structures_rooms_get(&self, name: &str) -> EnterpriseStructureRoomGetCall<'a, C> {
476        EnterpriseStructureRoomGetCall {
477            hub: self.hub,
478            _name: name.to_string(),
479            _delegate: Default::default(),
480            _additional_params: Default::default(),
481            _scopes: Default::default(),
482        }
483    }
484
485    /// Create a builder to help you perform the following task:
486    ///
487    /// Lists rooms managed by the enterprise.
488    ///
489    /// # Arguments
490    ///
491    /// * `parent` - The parent resource name of the rooms requested. For example: "enterprises/XYZ/structures/ABC".
492    pub fn structures_rooms_list(&self, parent: &str) -> EnterpriseStructureRoomListCall<'a, C> {
493        EnterpriseStructureRoomListCall {
494            hub: self.hub,
495            _parent: parent.to_string(),
496            _delegate: Default::default(),
497            _additional_params: Default::default(),
498            _scopes: Default::default(),
499        }
500    }
501
502    /// Create a builder to help you perform the following task:
503    ///
504    /// Gets a structure managed by the enterprise.
505    ///
506    /// # Arguments
507    ///
508    /// * `name` - The name of the structure requested. For example: "enterprises/XYZ/structures/ABC".
509    pub fn structures_get(&self, name: &str) -> EnterpriseStructureGetCall<'a, C> {
510        EnterpriseStructureGetCall {
511            hub: self.hub,
512            _name: name.to_string(),
513            _delegate: Default::default(),
514            _additional_params: Default::default(),
515            _scopes: Default::default(),
516        }
517    }
518
519    /// Create a builder to help you perform the following task:
520    ///
521    /// Lists structures managed by the enterprise.
522    ///
523    /// # Arguments
524    ///
525    /// * `parent` - The parent enterprise to list structures under. E.g. "enterprises/XYZ".
526    pub fn structures_list(&self, parent: &str) -> EnterpriseStructureListCall<'a, C> {
527        EnterpriseStructureListCall {
528            hub: self.hub,
529            _parent: parent.to_string(),
530            _filter: Default::default(),
531            _delegate: Default::default(),
532            _additional_params: Default::default(),
533            _scopes: Default::default(),
534        }
535    }
536}
537
538// ###################
539// CallBuilders   ###
540// #################
541
542/// Executes a command to device managed by the enterprise.
543///
544/// A builder for the *devices.executeCommand* method supported by a *enterprise* resource.
545/// It is not used directly, but through a [`EnterpriseMethods`] instance.
546///
547/// # Example
548///
549/// Instantiate a resource method builder
550///
551/// ```test_harness,no_run
552/// # extern crate hyper;
553/// # extern crate hyper_rustls;
554/// # extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
555/// use smartdevicemanagement1::api::GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandRequest;
556/// # async fn dox() {
557/// # use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
558///
559/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
560/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
561/// #     .with_native_roots()
562/// #     .unwrap()
563/// #     .https_only()
564/// #     .enable_http2()
565/// #     .build();
566///
567/// # let executor = hyper_util::rt::TokioExecutor::new();
568/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
569/// #     secret,
570/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
571/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
572/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
573/// #     ),
574/// # ).build().await.unwrap();
575///
576/// # let client = hyper_util::client::legacy::Client::builder(
577/// #     hyper_util::rt::TokioExecutor::new()
578/// # )
579/// # .build(
580/// #     hyper_rustls::HttpsConnectorBuilder::new()
581/// #         .with_native_roots()
582/// #         .unwrap()
583/// #         .https_or_http()
584/// #         .enable_http2()
585/// #         .build()
586/// # );
587/// # let mut hub = SmartDeviceManagement::new(client, auth);
588/// // As the method needs a request, you would usually fill it with the desired information
589/// // into the respective structure. Some of the parts shown here might not be applicable !
590/// // Values shown here are possibly random and not representative !
591/// let mut req = GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandRequest::default();
592///
593/// // You can configure optional parameters by calling the respective setters at will, and
594/// // execute the final call using `doit()`.
595/// // Values shown here are possibly random and not representative !
596/// let result = hub.enterprises().devices_execute_command(req, "name")
597///              .doit().await;
598/// # }
599/// ```
600pub struct EnterpriseDeviceExecuteCommandCall<'a, C>
601where
602    C: 'a,
603{
604    hub: &'a SmartDeviceManagement<C>,
605    _request: GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandRequest,
606    _name: String,
607    _delegate: Option<&'a mut dyn common::Delegate>,
608    _additional_params: HashMap<String, String>,
609    _scopes: BTreeSet<String>,
610}
611
612impl<'a, C> common::CallBuilder for EnterpriseDeviceExecuteCommandCall<'a, C> {}
613
614impl<'a, C> EnterpriseDeviceExecuteCommandCall<'a, C>
615where
616    C: common::Connector,
617{
618    /// Perform the operation you have build so far.
619    pub async fn doit(
620        mut self,
621    ) -> common::Result<(
622        common::Response,
623        GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandResponse,
624    )> {
625        use std::borrow::Cow;
626        use std::io::{Read, Seek};
627
628        use common::{url::Params, ToParts};
629        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
630
631        let mut dd = common::DefaultDelegate;
632        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
633        dlg.begin(common::MethodInfo {
634            id: "smartdevicemanagement.enterprises.devices.executeCommand",
635            http_method: hyper::Method::POST,
636        });
637
638        for &field in ["alt", "name"].iter() {
639            if self._additional_params.contains_key(field) {
640                dlg.finished(false);
641                return Err(common::Error::FieldClash(field));
642            }
643        }
644
645        let mut params = Params::with_capacity(4 + self._additional_params.len());
646        params.push("name", self._name);
647
648        params.extend(self._additional_params.iter());
649
650        params.push("alt", "json");
651        let mut url = self.hub._base_url.clone() + "v1/{+name}:executeCommand";
652        if self._scopes.is_empty() {
653            self._scopes.insert(Scope::SdmService.as_ref().to_string());
654        }
655
656        #[allow(clippy::single_element_loop)]
657        for &(find_this, param_name) in [("{+name}", "name")].iter() {
658            url = params.uri_replacement(url, param_name, find_this, true);
659        }
660        {
661            let to_remove = ["name"];
662            params.remove_params(&to_remove);
663        }
664
665        let url = params.parse_with_url(&url);
666
667        let mut json_mime_type = mime::APPLICATION_JSON;
668        let mut request_value_reader = {
669            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
670            common::remove_json_null_values(&mut value);
671            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
672            serde_json::to_writer(&mut dst, &value).unwrap();
673            dst
674        };
675        let request_size = request_value_reader
676            .seek(std::io::SeekFrom::End(0))
677            .unwrap();
678        request_value_reader
679            .seek(std::io::SeekFrom::Start(0))
680            .unwrap();
681
682        loop {
683            let token = match self
684                .hub
685                .auth
686                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
687                .await
688            {
689                Ok(token) => token,
690                Err(e) => match dlg.token(e) {
691                    Ok(token) => token,
692                    Err(e) => {
693                        dlg.finished(false);
694                        return Err(common::Error::MissingToken(e));
695                    }
696                },
697            };
698            request_value_reader
699                .seek(std::io::SeekFrom::Start(0))
700                .unwrap();
701            let mut req_result = {
702                let client = &self.hub.client;
703                dlg.pre_request();
704                let mut req_builder = hyper::Request::builder()
705                    .method(hyper::Method::POST)
706                    .uri(url.as_str())
707                    .header(USER_AGENT, self.hub._user_agent.clone());
708
709                if let Some(token) = token.as_ref() {
710                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
711                }
712
713                let request = req_builder
714                    .header(CONTENT_TYPE, json_mime_type.to_string())
715                    .header(CONTENT_LENGTH, request_size as u64)
716                    .body(common::to_body(
717                        request_value_reader.get_ref().clone().into(),
718                    ));
719
720                client.request(request.unwrap()).await
721            };
722
723            match req_result {
724                Err(err) => {
725                    if let common::Retry::After(d) = dlg.http_error(&err) {
726                        sleep(d).await;
727                        continue;
728                    }
729                    dlg.finished(false);
730                    return Err(common::Error::HttpError(err));
731                }
732                Ok(res) => {
733                    let (mut parts, body) = res.into_parts();
734                    let mut body = common::Body::new(body);
735                    if !parts.status.is_success() {
736                        let bytes = common::to_bytes(body).await.unwrap_or_default();
737                        let error = serde_json::from_str(&common::to_string(&bytes));
738                        let response = common::to_response(parts, bytes.into());
739
740                        if let common::Retry::After(d) =
741                            dlg.http_failure(&response, error.as_ref().ok())
742                        {
743                            sleep(d).await;
744                            continue;
745                        }
746
747                        dlg.finished(false);
748
749                        return Err(match error {
750                            Ok(value) => common::Error::BadRequest(value),
751                            _ => common::Error::Failure(response),
752                        });
753                    }
754                    let response = {
755                        let bytes = common::to_bytes(body).await.unwrap_or_default();
756                        let encoded = common::to_string(&bytes);
757                        match serde_json::from_str(&encoded) {
758                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
759                            Err(error) => {
760                                dlg.response_json_decode_error(&encoded, &error);
761                                return Err(common::Error::JsonDecodeError(
762                                    encoded.to_string(),
763                                    error,
764                                ));
765                            }
766                        }
767                    };
768
769                    dlg.finished(true);
770                    return Ok(response);
771                }
772            }
773        }
774    }
775
776    ///
777    /// Sets the *request* property to the given value.
778    ///
779    /// Even though the property as already been set when instantiating this call,
780    /// we provide this method for API completeness.
781    pub fn request(
782        mut self,
783        new_value: GoogleHomeEnterpriseSdmV1ExecuteDeviceCommandRequest,
784    ) -> EnterpriseDeviceExecuteCommandCall<'a, C> {
785        self._request = new_value;
786        self
787    }
788    /// The name of the device requested. For example: "enterprises/XYZ/devices/123"
789    ///
790    /// Sets the *name* path property to the given value.
791    ///
792    /// Even though the property as already been set when instantiating this call,
793    /// we provide this method for API completeness.
794    pub fn name(mut self, new_value: &str) -> EnterpriseDeviceExecuteCommandCall<'a, C> {
795        self._name = new_value.to_string();
796        self
797    }
798    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
799    /// while executing the actual API request.
800    ///
801    /// ````text
802    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
803    /// ````
804    ///
805    /// Sets the *delegate* property to the given value.
806    pub fn delegate(
807        mut self,
808        new_value: &'a mut dyn common::Delegate,
809    ) -> EnterpriseDeviceExecuteCommandCall<'a, C> {
810        self._delegate = Some(new_value);
811        self
812    }
813
814    /// Set any additional parameter of the query string used in the request.
815    /// It should be used to set parameters which are not yet available through their own
816    /// setters.
817    ///
818    /// Please note that this method must not be used to set any of the known parameters
819    /// which have their own setter method. If done anyway, the request will fail.
820    ///
821    /// # Additional Parameters
822    ///
823    /// * *$.xgafv* (query-string) - V1 error format.
824    /// * *access_token* (query-string) - OAuth access token.
825    /// * *alt* (query-string) - Data format for response.
826    /// * *callback* (query-string) - JSONP
827    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
828    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
829    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
830    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
831    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
832    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
833    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
834    pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceExecuteCommandCall<'a, C>
835    where
836        T: AsRef<str>,
837    {
838        self._additional_params
839            .insert(name.as_ref().to_string(), value.as_ref().to_string());
840        self
841    }
842
843    /// Identifies the authorization scope for the method you are building.
844    ///
845    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
846    /// [`Scope::SdmService`].
847    ///
848    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
849    /// tokens for more than one scope.
850    ///
851    /// Usually there is more than one suitable scope to authorize an operation, some of which may
852    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
853    /// sufficient, a read-write scope will do as well.
854    pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceExecuteCommandCall<'a, C>
855    where
856        St: AsRef<str>,
857    {
858        self._scopes.insert(String::from(scope.as_ref()));
859        self
860    }
861    /// Identifies the authorization scope(s) for the method you are building.
862    ///
863    /// See [`Self::add_scope()`] for details.
864    pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceExecuteCommandCall<'a, C>
865    where
866        I: IntoIterator<Item = St>,
867        St: AsRef<str>,
868    {
869        self._scopes
870            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
871        self
872    }
873
874    /// Removes all scopes, and no default scope will be used either.
875    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
876    /// for details).
877    pub fn clear_scopes(mut self) -> EnterpriseDeviceExecuteCommandCall<'a, C> {
878        self._scopes.clear();
879        self
880    }
881}
882
883/// Gets a device managed by the enterprise.
884///
885/// A builder for the *devices.get* method supported by a *enterprise* resource.
886/// It is not used directly, but through a [`EnterpriseMethods`] instance.
887///
888/// # Example
889///
890/// Instantiate a resource method builder
891///
892/// ```test_harness,no_run
893/// # extern crate hyper;
894/// # extern crate hyper_rustls;
895/// # extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
896/// # async fn dox() {
897/// # use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
898///
899/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
900/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
901/// #     .with_native_roots()
902/// #     .unwrap()
903/// #     .https_only()
904/// #     .enable_http2()
905/// #     .build();
906///
907/// # let executor = hyper_util::rt::TokioExecutor::new();
908/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
909/// #     secret,
910/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
911/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
912/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
913/// #     ),
914/// # ).build().await.unwrap();
915///
916/// # let client = hyper_util::client::legacy::Client::builder(
917/// #     hyper_util::rt::TokioExecutor::new()
918/// # )
919/// # .build(
920/// #     hyper_rustls::HttpsConnectorBuilder::new()
921/// #         .with_native_roots()
922/// #         .unwrap()
923/// #         .https_or_http()
924/// #         .enable_http2()
925/// #         .build()
926/// # );
927/// # let mut hub = SmartDeviceManagement::new(client, auth);
928/// // You can configure optional parameters by calling the respective setters at will, and
929/// // execute the final call using `doit()`.
930/// // Values shown here are possibly random and not representative !
931/// let result = hub.enterprises().devices_get("name")
932///              .doit().await;
933/// # }
934/// ```
935pub struct EnterpriseDeviceGetCall<'a, C>
936where
937    C: 'a,
938{
939    hub: &'a SmartDeviceManagement<C>,
940    _name: String,
941    _delegate: Option<&'a mut dyn common::Delegate>,
942    _additional_params: HashMap<String, String>,
943    _scopes: BTreeSet<String>,
944}
945
946impl<'a, C> common::CallBuilder for EnterpriseDeviceGetCall<'a, C> {}
947
948impl<'a, C> EnterpriseDeviceGetCall<'a, C>
949where
950    C: common::Connector,
951{
952    /// Perform the operation you have build so far.
953    pub async fn doit(
954        mut self,
955    ) -> common::Result<(common::Response, GoogleHomeEnterpriseSdmV1Device)> {
956        use std::borrow::Cow;
957        use std::io::{Read, Seek};
958
959        use common::{url::Params, ToParts};
960        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
961
962        let mut dd = common::DefaultDelegate;
963        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
964        dlg.begin(common::MethodInfo {
965            id: "smartdevicemanagement.enterprises.devices.get",
966            http_method: hyper::Method::GET,
967        });
968
969        for &field in ["alt", "name"].iter() {
970            if self._additional_params.contains_key(field) {
971                dlg.finished(false);
972                return Err(common::Error::FieldClash(field));
973            }
974        }
975
976        let mut params = Params::with_capacity(3 + self._additional_params.len());
977        params.push("name", self._name);
978
979        params.extend(self._additional_params.iter());
980
981        params.push("alt", "json");
982        let mut url = self.hub._base_url.clone() + "v1/{+name}";
983        if self._scopes.is_empty() {
984            self._scopes.insert(Scope::SdmService.as_ref().to_string());
985        }
986
987        #[allow(clippy::single_element_loop)]
988        for &(find_this, param_name) in [("{+name}", "name")].iter() {
989            url = params.uri_replacement(url, param_name, find_this, true);
990        }
991        {
992            let to_remove = ["name"];
993            params.remove_params(&to_remove);
994        }
995
996        let url = params.parse_with_url(&url);
997
998        loop {
999            let token = match self
1000                .hub
1001                .auth
1002                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1003                .await
1004            {
1005                Ok(token) => token,
1006                Err(e) => match dlg.token(e) {
1007                    Ok(token) => token,
1008                    Err(e) => {
1009                        dlg.finished(false);
1010                        return Err(common::Error::MissingToken(e));
1011                    }
1012                },
1013            };
1014            let mut req_result = {
1015                let client = &self.hub.client;
1016                dlg.pre_request();
1017                let mut req_builder = hyper::Request::builder()
1018                    .method(hyper::Method::GET)
1019                    .uri(url.as_str())
1020                    .header(USER_AGENT, self.hub._user_agent.clone());
1021
1022                if let Some(token) = token.as_ref() {
1023                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1024                }
1025
1026                let request = req_builder
1027                    .header(CONTENT_LENGTH, 0_u64)
1028                    .body(common::to_body::<String>(None));
1029
1030                client.request(request.unwrap()).await
1031            };
1032
1033            match req_result {
1034                Err(err) => {
1035                    if let common::Retry::After(d) = dlg.http_error(&err) {
1036                        sleep(d).await;
1037                        continue;
1038                    }
1039                    dlg.finished(false);
1040                    return Err(common::Error::HttpError(err));
1041                }
1042                Ok(res) => {
1043                    let (mut parts, body) = res.into_parts();
1044                    let mut body = common::Body::new(body);
1045                    if !parts.status.is_success() {
1046                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1047                        let error = serde_json::from_str(&common::to_string(&bytes));
1048                        let response = common::to_response(parts, bytes.into());
1049
1050                        if let common::Retry::After(d) =
1051                            dlg.http_failure(&response, error.as_ref().ok())
1052                        {
1053                            sleep(d).await;
1054                            continue;
1055                        }
1056
1057                        dlg.finished(false);
1058
1059                        return Err(match error {
1060                            Ok(value) => common::Error::BadRequest(value),
1061                            _ => common::Error::Failure(response),
1062                        });
1063                    }
1064                    let response = {
1065                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1066                        let encoded = common::to_string(&bytes);
1067                        match serde_json::from_str(&encoded) {
1068                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1069                            Err(error) => {
1070                                dlg.response_json_decode_error(&encoded, &error);
1071                                return Err(common::Error::JsonDecodeError(
1072                                    encoded.to_string(),
1073                                    error,
1074                                ));
1075                            }
1076                        }
1077                    };
1078
1079                    dlg.finished(true);
1080                    return Ok(response);
1081                }
1082            }
1083        }
1084    }
1085
1086    /// The name of the device requested. For example: "enterprises/XYZ/devices/123"
1087    ///
1088    /// Sets the *name* path property to the given value.
1089    ///
1090    /// Even though the property as already been set when instantiating this call,
1091    /// we provide this method for API completeness.
1092    pub fn name(mut self, new_value: &str) -> EnterpriseDeviceGetCall<'a, C> {
1093        self._name = new_value.to_string();
1094        self
1095    }
1096    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1097    /// while executing the actual API request.
1098    ///
1099    /// ````text
1100    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1101    /// ````
1102    ///
1103    /// Sets the *delegate* property to the given value.
1104    pub fn delegate(
1105        mut self,
1106        new_value: &'a mut dyn common::Delegate,
1107    ) -> EnterpriseDeviceGetCall<'a, C> {
1108        self._delegate = Some(new_value);
1109        self
1110    }
1111
1112    /// Set any additional parameter of the query string used in the request.
1113    /// It should be used to set parameters which are not yet available through their own
1114    /// setters.
1115    ///
1116    /// Please note that this method must not be used to set any of the known parameters
1117    /// which have their own setter method. If done anyway, the request will fail.
1118    ///
1119    /// # Additional Parameters
1120    ///
1121    /// * *$.xgafv* (query-string) - V1 error format.
1122    /// * *access_token* (query-string) - OAuth access token.
1123    /// * *alt* (query-string) - Data format for response.
1124    /// * *callback* (query-string) - JSONP
1125    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1126    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1127    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1128    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1129    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1130    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1131    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1132    pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceGetCall<'a, C>
1133    where
1134        T: AsRef<str>,
1135    {
1136        self._additional_params
1137            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1138        self
1139    }
1140
1141    /// Identifies the authorization scope for the method you are building.
1142    ///
1143    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1144    /// [`Scope::SdmService`].
1145    ///
1146    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1147    /// tokens for more than one scope.
1148    ///
1149    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1150    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1151    /// sufficient, a read-write scope will do as well.
1152    pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceGetCall<'a, C>
1153    where
1154        St: AsRef<str>,
1155    {
1156        self._scopes.insert(String::from(scope.as_ref()));
1157        self
1158    }
1159    /// Identifies the authorization scope(s) for the method you are building.
1160    ///
1161    /// See [`Self::add_scope()`] for details.
1162    pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceGetCall<'a, C>
1163    where
1164        I: IntoIterator<Item = St>,
1165        St: AsRef<str>,
1166    {
1167        self._scopes
1168            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1169        self
1170    }
1171
1172    /// Removes all scopes, and no default scope will be used either.
1173    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1174    /// for details).
1175    pub fn clear_scopes(mut self) -> EnterpriseDeviceGetCall<'a, C> {
1176        self._scopes.clear();
1177        self
1178    }
1179}
1180
1181/// Lists devices managed by the enterprise.
1182///
1183/// A builder for the *devices.list* method supported by a *enterprise* resource.
1184/// It is not used directly, but through a [`EnterpriseMethods`] instance.
1185///
1186/// # Example
1187///
1188/// Instantiate a resource method builder
1189///
1190/// ```test_harness,no_run
1191/// # extern crate hyper;
1192/// # extern crate hyper_rustls;
1193/// # extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
1194/// # async fn dox() {
1195/// # use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1196///
1197/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1198/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1199/// #     .with_native_roots()
1200/// #     .unwrap()
1201/// #     .https_only()
1202/// #     .enable_http2()
1203/// #     .build();
1204///
1205/// # let executor = hyper_util::rt::TokioExecutor::new();
1206/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1207/// #     secret,
1208/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1209/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1210/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1211/// #     ),
1212/// # ).build().await.unwrap();
1213///
1214/// # let client = hyper_util::client::legacy::Client::builder(
1215/// #     hyper_util::rt::TokioExecutor::new()
1216/// # )
1217/// # .build(
1218/// #     hyper_rustls::HttpsConnectorBuilder::new()
1219/// #         .with_native_roots()
1220/// #         .unwrap()
1221/// #         .https_or_http()
1222/// #         .enable_http2()
1223/// #         .build()
1224/// # );
1225/// # let mut hub = SmartDeviceManagement::new(client, auth);
1226/// // You can configure optional parameters by calling the respective setters at will, and
1227/// // execute the final call using `doit()`.
1228/// // Values shown here are possibly random and not representative !
1229/// let result = hub.enterprises().devices_list("parent")
1230///              .filter("sanctus")
1231///              .doit().await;
1232/// # }
1233/// ```
1234pub struct EnterpriseDeviceListCall<'a, C>
1235where
1236    C: 'a,
1237{
1238    hub: &'a SmartDeviceManagement<C>,
1239    _parent: String,
1240    _filter: Option<String>,
1241    _delegate: Option<&'a mut dyn common::Delegate>,
1242    _additional_params: HashMap<String, String>,
1243    _scopes: BTreeSet<String>,
1244}
1245
1246impl<'a, C> common::CallBuilder for EnterpriseDeviceListCall<'a, C> {}
1247
1248impl<'a, C> EnterpriseDeviceListCall<'a, C>
1249where
1250    C: common::Connector,
1251{
1252    /// Perform the operation you have build so far.
1253    pub async fn doit(
1254        mut self,
1255    ) -> common::Result<(
1256        common::Response,
1257        GoogleHomeEnterpriseSdmV1ListDevicesResponse,
1258    )> {
1259        use std::borrow::Cow;
1260        use std::io::{Read, Seek};
1261
1262        use common::{url::Params, ToParts};
1263        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1264
1265        let mut dd = common::DefaultDelegate;
1266        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1267        dlg.begin(common::MethodInfo {
1268            id: "smartdevicemanagement.enterprises.devices.list",
1269            http_method: hyper::Method::GET,
1270        });
1271
1272        for &field in ["alt", "parent", "filter"].iter() {
1273            if self._additional_params.contains_key(field) {
1274                dlg.finished(false);
1275                return Err(common::Error::FieldClash(field));
1276            }
1277        }
1278
1279        let mut params = Params::with_capacity(4 + self._additional_params.len());
1280        params.push("parent", self._parent);
1281        if let Some(value) = self._filter.as_ref() {
1282            params.push("filter", value);
1283        }
1284
1285        params.extend(self._additional_params.iter());
1286
1287        params.push("alt", "json");
1288        let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
1289        if self._scopes.is_empty() {
1290            self._scopes.insert(Scope::SdmService.as_ref().to_string());
1291        }
1292
1293        #[allow(clippy::single_element_loop)]
1294        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1295            url = params.uri_replacement(url, param_name, find_this, true);
1296        }
1297        {
1298            let to_remove = ["parent"];
1299            params.remove_params(&to_remove);
1300        }
1301
1302        let url = params.parse_with_url(&url);
1303
1304        loop {
1305            let token = match self
1306                .hub
1307                .auth
1308                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1309                .await
1310            {
1311                Ok(token) => token,
1312                Err(e) => match dlg.token(e) {
1313                    Ok(token) => token,
1314                    Err(e) => {
1315                        dlg.finished(false);
1316                        return Err(common::Error::MissingToken(e));
1317                    }
1318                },
1319            };
1320            let mut req_result = {
1321                let client = &self.hub.client;
1322                dlg.pre_request();
1323                let mut req_builder = hyper::Request::builder()
1324                    .method(hyper::Method::GET)
1325                    .uri(url.as_str())
1326                    .header(USER_AGENT, self.hub._user_agent.clone());
1327
1328                if let Some(token) = token.as_ref() {
1329                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1330                }
1331
1332                let request = req_builder
1333                    .header(CONTENT_LENGTH, 0_u64)
1334                    .body(common::to_body::<String>(None));
1335
1336                client.request(request.unwrap()).await
1337            };
1338
1339            match req_result {
1340                Err(err) => {
1341                    if let common::Retry::After(d) = dlg.http_error(&err) {
1342                        sleep(d).await;
1343                        continue;
1344                    }
1345                    dlg.finished(false);
1346                    return Err(common::Error::HttpError(err));
1347                }
1348                Ok(res) => {
1349                    let (mut parts, body) = res.into_parts();
1350                    let mut body = common::Body::new(body);
1351                    if !parts.status.is_success() {
1352                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1353                        let error = serde_json::from_str(&common::to_string(&bytes));
1354                        let response = common::to_response(parts, bytes.into());
1355
1356                        if let common::Retry::After(d) =
1357                            dlg.http_failure(&response, error.as_ref().ok())
1358                        {
1359                            sleep(d).await;
1360                            continue;
1361                        }
1362
1363                        dlg.finished(false);
1364
1365                        return Err(match error {
1366                            Ok(value) => common::Error::BadRequest(value),
1367                            _ => common::Error::Failure(response),
1368                        });
1369                    }
1370                    let response = {
1371                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1372                        let encoded = common::to_string(&bytes);
1373                        match serde_json::from_str(&encoded) {
1374                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1375                            Err(error) => {
1376                                dlg.response_json_decode_error(&encoded, &error);
1377                                return Err(common::Error::JsonDecodeError(
1378                                    encoded.to_string(),
1379                                    error,
1380                                ));
1381                            }
1382                        }
1383                    };
1384
1385                    dlg.finished(true);
1386                    return Ok(response);
1387                }
1388            }
1389        }
1390    }
1391
1392    /// The parent enterprise to list devices under. E.g. "enterprises/XYZ".
1393    ///
1394    /// Sets the *parent* path property to the given value.
1395    ///
1396    /// Even though the property as already been set when instantiating this call,
1397    /// we provide this method for API completeness.
1398    pub fn parent(mut self, new_value: &str) -> EnterpriseDeviceListCall<'a, C> {
1399        self._parent = new_value.to_string();
1400        self
1401    }
1402    /// Optional filter to list devices. Filters can be done on: Device custom name (substring match): 'customName=wing'
1403    ///
1404    /// Sets the *filter* query property to the given value.
1405    pub fn filter(mut self, new_value: &str) -> EnterpriseDeviceListCall<'a, C> {
1406        self._filter = Some(new_value.to_string());
1407        self
1408    }
1409    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1410    /// while executing the actual API request.
1411    ///
1412    /// ````text
1413    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1414    /// ````
1415    ///
1416    /// Sets the *delegate* property to the given value.
1417    pub fn delegate(
1418        mut self,
1419        new_value: &'a mut dyn common::Delegate,
1420    ) -> EnterpriseDeviceListCall<'a, C> {
1421        self._delegate = Some(new_value);
1422        self
1423    }
1424
1425    /// Set any additional parameter of the query string used in the request.
1426    /// It should be used to set parameters which are not yet available through their own
1427    /// setters.
1428    ///
1429    /// Please note that this method must not be used to set any of the known parameters
1430    /// which have their own setter method. If done anyway, the request will fail.
1431    ///
1432    /// # Additional Parameters
1433    ///
1434    /// * *$.xgafv* (query-string) - V1 error format.
1435    /// * *access_token* (query-string) - OAuth access token.
1436    /// * *alt* (query-string) - Data format for response.
1437    /// * *callback* (query-string) - JSONP
1438    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1439    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1440    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1441    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1442    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1443    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1444    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1445    pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceListCall<'a, C>
1446    where
1447        T: AsRef<str>,
1448    {
1449        self._additional_params
1450            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1451        self
1452    }
1453
1454    /// Identifies the authorization scope for the method you are building.
1455    ///
1456    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1457    /// [`Scope::SdmService`].
1458    ///
1459    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1460    /// tokens for more than one scope.
1461    ///
1462    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1463    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1464    /// sufficient, a read-write scope will do as well.
1465    pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceListCall<'a, C>
1466    where
1467        St: AsRef<str>,
1468    {
1469        self._scopes.insert(String::from(scope.as_ref()));
1470        self
1471    }
1472    /// Identifies the authorization scope(s) for the method you are building.
1473    ///
1474    /// See [`Self::add_scope()`] for details.
1475    pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceListCall<'a, C>
1476    where
1477        I: IntoIterator<Item = St>,
1478        St: AsRef<str>,
1479    {
1480        self._scopes
1481            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1482        self
1483    }
1484
1485    /// Removes all scopes, and no default scope will be used either.
1486    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1487    /// for details).
1488    pub fn clear_scopes(mut self) -> EnterpriseDeviceListCall<'a, C> {
1489        self._scopes.clear();
1490        self
1491    }
1492}
1493
1494/// Gets a room managed by the enterprise.
1495///
1496/// A builder for the *structures.rooms.get* method supported by a *enterprise* resource.
1497/// It is not used directly, but through a [`EnterpriseMethods`] instance.
1498///
1499/// # Example
1500///
1501/// Instantiate a resource method builder
1502///
1503/// ```test_harness,no_run
1504/// # extern crate hyper;
1505/// # extern crate hyper_rustls;
1506/// # extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
1507/// # async fn dox() {
1508/// # use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1509///
1510/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1511/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1512/// #     .with_native_roots()
1513/// #     .unwrap()
1514/// #     .https_only()
1515/// #     .enable_http2()
1516/// #     .build();
1517///
1518/// # let executor = hyper_util::rt::TokioExecutor::new();
1519/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1520/// #     secret,
1521/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1522/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1523/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1524/// #     ),
1525/// # ).build().await.unwrap();
1526///
1527/// # let client = hyper_util::client::legacy::Client::builder(
1528/// #     hyper_util::rt::TokioExecutor::new()
1529/// # )
1530/// # .build(
1531/// #     hyper_rustls::HttpsConnectorBuilder::new()
1532/// #         .with_native_roots()
1533/// #         .unwrap()
1534/// #         .https_or_http()
1535/// #         .enable_http2()
1536/// #         .build()
1537/// # );
1538/// # let mut hub = SmartDeviceManagement::new(client, auth);
1539/// // You can configure optional parameters by calling the respective setters at will, and
1540/// // execute the final call using `doit()`.
1541/// // Values shown here are possibly random and not representative !
1542/// let result = hub.enterprises().structures_rooms_get("name")
1543///              .doit().await;
1544/// # }
1545/// ```
1546pub struct EnterpriseStructureRoomGetCall<'a, C>
1547where
1548    C: 'a,
1549{
1550    hub: &'a SmartDeviceManagement<C>,
1551    _name: String,
1552    _delegate: Option<&'a mut dyn common::Delegate>,
1553    _additional_params: HashMap<String, String>,
1554    _scopes: BTreeSet<String>,
1555}
1556
1557impl<'a, C> common::CallBuilder for EnterpriseStructureRoomGetCall<'a, C> {}
1558
1559impl<'a, C> EnterpriseStructureRoomGetCall<'a, C>
1560where
1561    C: common::Connector,
1562{
1563    /// Perform the operation you have build so far.
1564    pub async fn doit(
1565        mut self,
1566    ) -> common::Result<(common::Response, GoogleHomeEnterpriseSdmV1Room)> {
1567        use std::borrow::Cow;
1568        use std::io::{Read, Seek};
1569
1570        use common::{url::Params, ToParts};
1571        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1572
1573        let mut dd = common::DefaultDelegate;
1574        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1575        dlg.begin(common::MethodInfo {
1576            id: "smartdevicemanagement.enterprises.structures.rooms.get",
1577            http_method: hyper::Method::GET,
1578        });
1579
1580        for &field in ["alt", "name"].iter() {
1581            if self._additional_params.contains_key(field) {
1582                dlg.finished(false);
1583                return Err(common::Error::FieldClash(field));
1584            }
1585        }
1586
1587        let mut params = Params::with_capacity(3 + self._additional_params.len());
1588        params.push("name", self._name);
1589
1590        params.extend(self._additional_params.iter());
1591
1592        params.push("alt", "json");
1593        let mut url = self.hub._base_url.clone() + "v1/{+name}";
1594        if self._scopes.is_empty() {
1595            self._scopes.insert(Scope::SdmService.as_ref().to_string());
1596        }
1597
1598        #[allow(clippy::single_element_loop)]
1599        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1600            url = params.uri_replacement(url, param_name, find_this, true);
1601        }
1602        {
1603            let to_remove = ["name"];
1604            params.remove_params(&to_remove);
1605        }
1606
1607        let url = params.parse_with_url(&url);
1608
1609        loop {
1610            let token = match self
1611                .hub
1612                .auth
1613                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1614                .await
1615            {
1616                Ok(token) => token,
1617                Err(e) => match dlg.token(e) {
1618                    Ok(token) => token,
1619                    Err(e) => {
1620                        dlg.finished(false);
1621                        return Err(common::Error::MissingToken(e));
1622                    }
1623                },
1624            };
1625            let mut req_result = {
1626                let client = &self.hub.client;
1627                dlg.pre_request();
1628                let mut req_builder = hyper::Request::builder()
1629                    .method(hyper::Method::GET)
1630                    .uri(url.as_str())
1631                    .header(USER_AGENT, self.hub._user_agent.clone());
1632
1633                if let Some(token) = token.as_ref() {
1634                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1635                }
1636
1637                let request = req_builder
1638                    .header(CONTENT_LENGTH, 0_u64)
1639                    .body(common::to_body::<String>(None));
1640
1641                client.request(request.unwrap()).await
1642            };
1643
1644            match req_result {
1645                Err(err) => {
1646                    if let common::Retry::After(d) = dlg.http_error(&err) {
1647                        sleep(d).await;
1648                        continue;
1649                    }
1650                    dlg.finished(false);
1651                    return Err(common::Error::HttpError(err));
1652                }
1653                Ok(res) => {
1654                    let (mut parts, body) = res.into_parts();
1655                    let mut body = common::Body::new(body);
1656                    if !parts.status.is_success() {
1657                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1658                        let error = serde_json::from_str(&common::to_string(&bytes));
1659                        let response = common::to_response(parts, bytes.into());
1660
1661                        if let common::Retry::After(d) =
1662                            dlg.http_failure(&response, error.as_ref().ok())
1663                        {
1664                            sleep(d).await;
1665                            continue;
1666                        }
1667
1668                        dlg.finished(false);
1669
1670                        return Err(match error {
1671                            Ok(value) => common::Error::BadRequest(value),
1672                            _ => common::Error::Failure(response),
1673                        });
1674                    }
1675                    let response = {
1676                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1677                        let encoded = common::to_string(&bytes);
1678                        match serde_json::from_str(&encoded) {
1679                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1680                            Err(error) => {
1681                                dlg.response_json_decode_error(&encoded, &error);
1682                                return Err(common::Error::JsonDecodeError(
1683                                    encoded.to_string(),
1684                                    error,
1685                                ));
1686                            }
1687                        }
1688                    };
1689
1690                    dlg.finished(true);
1691                    return Ok(response);
1692                }
1693            }
1694        }
1695    }
1696
1697    /// The name of the room requested. For example: "enterprises/XYZ/structures/ABC/rooms/123".
1698    ///
1699    /// Sets the *name* path property to the given value.
1700    ///
1701    /// Even though the property as already been set when instantiating this call,
1702    /// we provide this method for API completeness.
1703    pub fn name(mut self, new_value: &str) -> EnterpriseStructureRoomGetCall<'a, C> {
1704        self._name = new_value.to_string();
1705        self
1706    }
1707    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1708    /// while executing the actual API request.
1709    ///
1710    /// ````text
1711    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1712    /// ````
1713    ///
1714    /// Sets the *delegate* property to the given value.
1715    pub fn delegate(
1716        mut self,
1717        new_value: &'a mut dyn common::Delegate,
1718    ) -> EnterpriseStructureRoomGetCall<'a, C> {
1719        self._delegate = Some(new_value);
1720        self
1721    }
1722
1723    /// Set any additional parameter of the query string used in the request.
1724    /// It should be used to set parameters which are not yet available through their own
1725    /// setters.
1726    ///
1727    /// Please note that this method must not be used to set any of the known parameters
1728    /// which have their own setter method. If done anyway, the request will fail.
1729    ///
1730    /// # Additional Parameters
1731    ///
1732    /// * *$.xgafv* (query-string) - V1 error format.
1733    /// * *access_token* (query-string) - OAuth access token.
1734    /// * *alt* (query-string) - Data format for response.
1735    /// * *callback* (query-string) - JSONP
1736    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1737    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1738    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1739    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1740    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1741    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1742    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1743    pub fn param<T>(mut self, name: T, value: T) -> EnterpriseStructureRoomGetCall<'a, C>
1744    where
1745        T: AsRef<str>,
1746    {
1747        self._additional_params
1748            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1749        self
1750    }
1751
1752    /// Identifies the authorization scope for the method you are building.
1753    ///
1754    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1755    /// [`Scope::SdmService`].
1756    ///
1757    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1758    /// tokens for more than one scope.
1759    ///
1760    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1761    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1762    /// sufficient, a read-write scope will do as well.
1763    pub fn add_scope<St>(mut self, scope: St) -> EnterpriseStructureRoomGetCall<'a, C>
1764    where
1765        St: AsRef<str>,
1766    {
1767        self._scopes.insert(String::from(scope.as_ref()));
1768        self
1769    }
1770    /// Identifies the authorization scope(s) for the method you are building.
1771    ///
1772    /// See [`Self::add_scope()`] for details.
1773    pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseStructureRoomGetCall<'a, C>
1774    where
1775        I: IntoIterator<Item = St>,
1776        St: AsRef<str>,
1777    {
1778        self._scopes
1779            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1780        self
1781    }
1782
1783    /// Removes all scopes, and no default scope will be used either.
1784    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1785    /// for details).
1786    pub fn clear_scopes(mut self) -> EnterpriseStructureRoomGetCall<'a, C> {
1787        self._scopes.clear();
1788        self
1789    }
1790}
1791
1792/// Lists rooms managed by the enterprise.
1793///
1794/// A builder for the *structures.rooms.list* method supported by a *enterprise* resource.
1795/// It is not used directly, but through a [`EnterpriseMethods`] instance.
1796///
1797/// # Example
1798///
1799/// Instantiate a resource method builder
1800///
1801/// ```test_harness,no_run
1802/// # extern crate hyper;
1803/// # extern crate hyper_rustls;
1804/// # extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
1805/// # async fn dox() {
1806/// # use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1807///
1808/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1809/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1810/// #     .with_native_roots()
1811/// #     .unwrap()
1812/// #     .https_only()
1813/// #     .enable_http2()
1814/// #     .build();
1815///
1816/// # let executor = hyper_util::rt::TokioExecutor::new();
1817/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1818/// #     secret,
1819/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1820/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1821/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1822/// #     ),
1823/// # ).build().await.unwrap();
1824///
1825/// # let client = hyper_util::client::legacy::Client::builder(
1826/// #     hyper_util::rt::TokioExecutor::new()
1827/// # )
1828/// # .build(
1829/// #     hyper_rustls::HttpsConnectorBuilder::new()
1830/// #         .with_native_roots()
1831/// #         .unwrap()
1832/// #         .https_or_http()
1833/// #         .enable_http2()
1834/// #         .build()
1835/// # );
1836/// # let mut hub = SmartDeviceManagement::new(client, auth);
1837/// // You can configure optional parameters by calling the respective setters at will, and
1838/// // execute the final call using `doit()`.
1839/// // Values shown here are possibly random and not representative !
1840/// let result = hub.enterprises().structures_rooms_list("parent")
1841///              .doit().await;
1842/// # }
1843/// ```
1844pub struct EnterpriseStructureRoomListCall<'a, C>
1845where
1846    C: 'a,
1847{
1848    hub: &'a SmartDeviceManagement<C>,
1849    _parent: String,
1850    _delegate: Option<&'a mut dyn common::Delegate>,
1851    _additional_params: HashMap<String, String>,
1852    _scopes: BTreeSet<String>,
1853}
1854
1855impl<'a, C> common::CallBuilder for EnterpriseStructureRoomListCall<'a, C> {}
1856
1857impl<'a, C> EnterpriseStructureRoomListCall<'a, C>
1858where
1859    C: common::Connector,
1860{
1861    /// Perform the operation you have build so far.
1862    pub async fn doit(
1863        mut self,
1864    ) -> common::Result<(common::Response, GoogleHomeEnterpriseSdmV1ListRoomsResponse)> {
1865        use std::borrow::Cow;
1866        use std::io::{Read, Seek};
1867
1868        use common::{url::Params, ToParts};
1869        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1870
1871        let mut dd = common::DefaultDelegate;
1872        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1873        dlg.begin(common::MethodInfo {
1874            id: "smartdevicemanagement.enterprises.structures.rooms.list",
1875            http_method: hyper::Method::GET,
1876        });
1877
1878        for &field in ["alt", "parent"].iter() {
1879            if self._additional_params.contains_key(field) {
1880                dlg.finished(false);
1881                return Err(common::Error::FieldClash(field));
1882            }
1883        }
1884
1885        let mut params = Params::with_capacity(3 + self._additional_params.len());
1886        params.push("parent", self._parent);
1887
1888        params.extend(self._additional_params.iter());
1889
1890        params.push("alt", "json");
1891        let mut url = self.hub._base_url.clone() + "v1/{+parent}/rooms";
1892        if self._scopes.is_empty() {
1893            self._scopes.insert(Scope::SdmService.as_ref().to_string());
1894        }
1895
1896        #[allow(clippy::single_element_loop)]
1897        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1898            url = params.uri_replacement(url, param_name, find_this, true);
1899        }
1900        {
1901            let to_remove = ["parent"];
1902            params.remove_params(&to_remove);
1903        }
1904
1905        let url = params.parse_with_url(&url);
1906
1907        loop {
1908            let token = match self
1909                .hub
1910                .auth
1911                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1912                .await
1913            {
1914                Ok(token) => token,
1915                Err(e) => match dlg.token(e) {
1916                    Ok(token) => token,
1917                    Err(e) => {
1918                        dlg.finished(false);
1919                        return Err(common::Error::MissingToken(e));
1920                    }
1921                },
1922            };
1923            let mut req_result = {
1924                let client = &self.hub.client;
1925                dlg.pre_request();
1926                let mut req_builder = hyper::Request::builder()
1927                    .method(hyper::Method::GET)
1928                    .uri(url.as_str())
1929                    .header(USER_AGENT, self.hub._user_agent.clone());
1930
1931                if let Some(token) = token.as_ref() {
1932                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1933                }
1934
1935                let request = req_builder
1936                    .header(CONTENT_LENGTH, 0_u64)
1937                    .body(common::to_body::<String>(None));
1938
1939                client.request(request.unwrap()).await
1940            };
1941
1942            match req_result {
1943                Err(err) => {
1944                    if let common::Retry::After(d) = dlg.http_error(&err) {
1945                        sleep(d).await;
1946                        continue;
1947                    }
1948                    dlg.finished(false);
1949                    return Err(common::Error::HttpError(err));
1950                }
1951                Ok(res) => {
1952                    let (mut parts, body) = res.into_parts();
1953                    let mut body = common::Body::new(body);
1954                    if !parts.status.is_success() {
1955                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1956                        let error = serde_json::from_str(&common::to_string(&bytes));
1957                        let response = common::to_response(parts, bytes.into());
1958
1959                        if let common::Retry::After(d) =
1960                            dlg.http_failure(&response, error.as_ref().ok())
1961                        {
1962                            sleep(d).await;
1963                            continue;
1964                        }
1965
1966                        dlg.finished(false);
1967
1968                        return Err(match error {
1969                            Ok(value) => common::Error::BadRequest(value),
1970                            _ => common::Error::Failure(response),
1971                        });
1972                    }
1973                    let response = {
1974                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1975                        let encoded = common::to_string(&bytes);
1976                        match serde_json::from_str(&encoded) {
1977                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1978                            Err(error) => {
1979                                dlg.response_json_decode_error(&encoded, &error);
1980                                return Err(common::Error::JsonDecodeError(
1981                                    encoded.to_string(),
1982                                    error,
1983                                ));
1984                            }
1985                        }
1986                    };
1987
1988                    dlg.finished(true);
1989                    return Ok(response);
1990                }
1991            }
1992        }
1993    }
1994
1995    /// The parent resource name of the rooms requested. For example: "enterprises/XYZ/structures/ABC".
1996    ///
1997    /// Sets the *parent* path property to the given value.
1998    ///
1999    /// Even though the property as already been set when instantiating this call,
2000    /// we provide this method for API completeness.
2001    pub fn parent(mut self, new_value: &str) -> EnterpriseStructureRoomListCall<'a, C> {
2002        self._parent = new_value.to_string();
2003        self
2004    }
2005    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2006    /// while executing the actual API request.
2007    ///
2008    /// ````text
2009    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2010    /// ````
2011    ///
2012    /// Sets the *delegate* property to the given value.
2013    pub fn delegate(
2014        mut self,
2015        new_value: &'a mut dyn common::Delegate,
2016    ) -> EnterpriseStructureRoomListCall<'a, C> {
2017        self._delegate = Some(new_value);
2018        self
2019    }
2020
2021    /// Set any additional parameter of the query string used in the request.
2022    /// It should be used to set parameters which are not yet available through their own
2023    /// setters.
2024    ///
2025    /// Please note that this method must not be used to set any of the known parameters
2026    /// which have their own setter method. If done anyway, the request will fail.
2027    ///
2028    /// # Additional Parameters
2029    ///
2030    /// * *$.xgafv* (query-string) - V1 error format.
2031    /// * *access_token* (query-string) - OAuth access token.
2032    /// * *alt* (query-string) - Data format for response.
2033    /// * *callback* (query-string) - JSONP
2034    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2035    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2036    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2037    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2038    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2039    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2040    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2041    pub fn param<T>(mut self, name: T, value: T) -> EnterpriseStructureRoomListCall<'a, C>
2042    where
2043        T: AsRef<str>,
2044    {
2045        self._additional_params
2046            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2047        self
2048    }
2049
2050    /// Identifies the authorization scope for the method you are building.
2051    ///
2052    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2053    /// [`Scope::SdmService`].
2054    ///
2055    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2056    /// tokens for more than one scope.
2057    ///
2058    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2059    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2060    /// sufficient, a read-write scope will do as well.
2061    pub fn add_scope<St>(mut self, scope: St) -> EnterpriseStructureRoomListCall<'a, C>
2062    where
2063        St: AsRef<str>,
2064    {
2065        self._scopes.insert(String::from(scope.as_ref()));
2066        self
2067    }
2068    /// Identifies the authorization scope(s) for the method you are building.
2069    ///
2070    /// See [`Self::add_scope()`] for details.
2071    pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseStructureRoomListCall<'a, C>
2072    where
2073        I: IntoIterator<Item = St>,
2074        St: AsRef<str>,
2075    {
2076        self._scopes
2077            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2078        self
2079    }
2080
2081    /// Removes all scopes, and no default scope will be used either.
2082    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2083    /// for details).
2084    pub fn clear_scopes(mut self) -> EnterpriseStructureRoomListCall<'a, C> {
2085        self._scopes.clear();
2086        self
2087    }
2088}
2089
2090/// Gets a structure managed by the enterprise.
2091///
2092/// A builder for the *structures.get* method supported by a *enterprise* resource.
2093/// It is not used directly, but through a [`EnterpriseMethods`] instance.
2094///
2095/// # Example
2096///
2097/// Instantiate a resource method builder
2098///
2099/// ```test_harness,no_run
2100/// # extern crate hyper;
2101/// # extern crate hyper_rustls;
2102/// # extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
2103/// # async fn dox() {
2104/// # use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2105///
2106/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2107/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2108/// #     .with_native_roots()
2109/// #     .unwrap()
2110/// #     .https_only()
2111/// #     .enable_http2()
2112/// #     .build();
2113///
2114/// # let executor = hyper_util::rt::TokioExecutor::new();
2115/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2116/// #     secret,
2117/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2118/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2119/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2120/// #     ),
2121/// # ).build().await.unwrap();
2122///
2123/// # let client = hyper_util::client::legacy::Client::builder(
2124/// #     hyper_util::rt::TokioExecutor::new()
2125/// # )
2126/// # .build(
2127/// #     hyper_rustls::HttpsConnectorBuilder::new()
2128/// #         .with_native_roots()
2129/// #         .unwrap()
2130/// #         .https_or_http()
2131/// #         .enable_http2()
2132/// #         .build()
2133/// # );
2134/// # let mut hub = SmartDeviceManagement::new(client, auth);
2135/// // You can configure optional parameters by calling the respective setters at will, and
2136/// // execute the final call using `doit()`.
2137/// // Values shown here are possibly random and not representative !
2138/// let result = hub.enterprises().structures_get("name")
2139///              .doit().await;
2140/// # }
2141/// ```
2142pub struct EnterpriseStructureGetCall<'a, C>
2143where
2144    C: 'a,
2145{
2146    hub: &'a SmartDeviceManagement<C>,
2147    _name: String,
2148    _delegate: Option<&'a mut dyn common::Delegate>,
2149    _additional_params: HashMap<String, String>,
2150    _scopes: BTreeSet<String>,
2151}
2152
2153impl<'a, C> common::CallBuilder for EnterpriseStructureGetCall<'a, C> {}
2154
2155impl<'a, C> EnterpriseStructureGetCall<'a, C>
2156where
2157    C: common::Connector,
2158{
2159    /// Perform the operation you have build so far.
2160    pub async fn doit(
2161        mut self,
2162    ) -> common::Result<(common::Response, GoogleHomeEnterpriseSdmV1Structure)> {
2163        use std::borrow::Cow;
2164        use std::io::{Read, Seek};
2165
2166        use common::{url::Params, ToParts};
2167        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2168
2169        let mut dd = common::DefaultDelegate;
2170        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2171        dlg.begin(common::MethodInfo {
2172            id: "smartdevicemanagement.enterprises.structures.get",
2173            http_method: hyper::Method::GET,
2174        });
2175
2176        for &field in ["alt", "name"].iter() {
2177            if self._additional_params.contains_key(field) {
2178                dlg.finished(false);
2179                return Err(common::Error::FieldClash(field));
2180            }
2181        }
2182
2183        let mut params = Params::with_capacity(3 + self._additional_params.len());
2184        params.push("name", self._name);
2185
2186        params.extend(self._additional_params.iter());
2187
2188        params.push("alt", "json");
2189        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2190        if self._scopes.is_empty() {
2191            self._scopes.insert(Scope::SdmService.as_ref().to_string());
2192        }
2193
2194        #[allow(clippy::single_element_loop)]
2195        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2196            url = params.uri_replacement(url, param_name, find_this, true);
2197        }
2198        {
2199            let to_remove = ["name"];
2200            params.remove_params(&to_remove);
2201        }
2202
2203        let url = params.parse_with_url(&url);
2204
2205        loop {
2206            let token = match self
2207                .hub
2208                .auth
2209                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2210                .await
2211            {
2212                Ok(token) => token,
2213                Err(e) => match dlg.token(e) {
2214                    Ok(token) => token,
2215                    Err(e) => {
2216                        dlg.finished(false);
2217                        return Err(common::Error::MissingToken(e));
2218                    }
2219                },
2220            };
2221            let mut req_result = {
2222                let client = &self.hub.client;
2223                dlg.pre_request();
2224                let mut req_builder = hyper::Request::builder()
2225                    .method(hyper::Method::GET)
2226                    .uri(url.as_str())
2227                    .header(USER_AGENT, self.hub._user_agent.clone());
2228
2229                if let Some(token) = token.as_ref() {
2230                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2231                }
2232
2233                let request = req_builder
2234                    .header(CONTENT_LENGTH, 0_u64)
2235                    .body(common::to_body::<String>(None));
2236
2237                client.request(request.unwrap()).await
2238            };
2239
2240            match req_result {
2241                Err(err) => {
2242                    if let common::Retry::After(d) = dlg.http_error(&err) {
2243                        sleep(d).await;
2244                        continue;
2245                    }
2246                    dlg.finished(false);
2247                    return Err(common::Error::HttpError(err));
2248                }
2249                Ok(res) => {
2250                    let (mut parts, body) = res.into_parts();
2251                    let mut body = common::Body::new(body);
2252                    if !parts.status.is_success() {
2253                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2254                        let error = serde_json::from_str(&common::to_string(&bytes));
2255                        let response = common::to_response(parts, bytes.into());
2256
2257                        if let common::Retry::After(d) =
2258                            dlg.http_failure(&response, error.as_ref().ok())
2259                        {
2260                            sleep(d).await;
2261                            continue;
2262                        }
2263
2264                        dlg.finished(false);
2265
2266                        return Err(match error {
2267                            Ok(value) => common::Error::BadRequest(value),
2268                            _ => common::Error::Failure(response),
2269                        });
2270                    }
2271                    let response = {
2272                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2273                        let encoded = common::to_string(&bytes);
2274                        match serde_json::from_str(&encoded) {
2275                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2276                            Err(error) => {
2277                                dlg.response_json_decode_error(&encoded, &error);
2278                                return Err(common::Error::JsonDecodeError(
2279                                    encoded.to_string(),
2280                                    error,
2281                                ));
2282                            }
2283                        }
2284                    };
2285
2286                    dlg.finished(true);
2287                    return Ok(response);
2288                }
2289            }
2290        }
2291    }
2292
2293    /// The name of the structure requested. For example: "enterprises/XYZ/structures/ABC".
2294    ///
2295    /// Sets the *name* path property to the given value.
2296    ///
2297    /// Even though the property as already been set when instantiating this call,
2298    /// we provide this method for API completeness.
2299    pub fn name(mut self, new_value: &str) -> EnterpriseStructureGetCall<'a, C> {
2300        self._name = new_value.to_string();
2301        self
2302    }
2303    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2304    /// while executing the actual API request.
2305    ///
2306    /// ````text
2307    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2308    /// ````
2309    ///
2310    /// Sets the *delegate* property to the given value.
2311    pub fn delegate(
2312        mut self,
2313        new_value: &'a mut dyn common::Delegate,
2314    ) -> EnterpriseStructureGetCall<'a, C> {
2315        self._delegate = Some(new_value);
2316        self
2317    }
2318
2319    /// Set any additional parameter of the query string used in the request.
2320    /// It should be used to set parameters which are not yet available through their own
2321    /// setters.
2322    ///
2323    /// Please note that this method must not be used to set any of the known parameters
2324    /// which have their own setter method. If done anyway, the request will fail.
2325    ///
2326    /// # Additional Parameters
2327    ///
2328    /// * *$.xgafv* (query-string) - V1 error format.
2329    /// * *access_token* (query-string) - OAuth access token.
2330    /// * *alt* (query-string) - Data format for response.
2331    /// * *callback* (query-string) - JSONP
2332    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2333    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2334    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2335    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2336    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2337    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2338    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2339    pub fn param<T>(mut self, name: T, value: T) -> EnterpriseStructureGetCall<'a, C>
2340    where
2341        T: AsRef<str>,
2342    {
2343        self._additional_params
2344            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2345        self
2346    }
2347
2348    /// Identifies the authorization scope for the method you are building.
2349    ///
2350    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2351    /// [`Scope::SdmService`].
2352    ///
2353    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2354    /// tokens for more than one scope.
2355    ///
2356    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2357    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2358    /// sufficient, a read-write scope will do as well.
2359    pub fn add_scope<St>(mut self, scope: St) -> EnterpriseStructureGetCall<'a, C>
2360    where
2361        St: AsRef<str>,
2362    {
2363        self._scopes.insert(String::from(scope.as_ref()));
2364        self
2365    }
2366    /// Identifies the authorization scope(s) for the method you are building.
2367    ///
2368    /// See [`Self::add_scope()`] for details.
2369    pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseStructureGetCall<'a, C>
2370    where
2371        I: IntoIterator<Item = St>,
2372        St: AsRef<str>,
2373    {
2374        self._scopes
2375            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2376        self
2377    }
2378
2379    /// Removes all scopes, and no default scope will be used either.
2380    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2381    /// for details).
2382    pub fn clear_scopes(mut self) -> EnterpriseStructureGetCall<'a, C> {
2383        self._scopes.clear();
2384        self
2385    }
2386}
2387
2388/// Lists structures managed by the enterprise.
2389///
2390/// A builder for the *structures.list* method supported by a *enterprise* resource.
2391/// It is not used directly, but through a [`EnterpriseMethods`] instance.
2392///
2393/// # Example
2394///
2395/// Instantiate a resource method builder
2396///
2397/// ```test_harness,no_run
2398/// # extern crate hyper;
2399/// # extern crate hyper_rustls;
2400/// # extern crate google_smartdevicemanagement1 as smartdevicemanagement1;
2401/// # async fn dox() {
2402/// # use smartdevicemanagement1::{SmartDeviceManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2403///
2404/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2405/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2406/// #     .with_native_roots()
2407/// #     .unwrap()
2408/// #     .https_only()
2409/// #     .enable_http2()
2410/// #     .build();
2411///
2412/// # let executor = hyper_util::rt::TokioExecutor::new();
2413/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2414/// #     secret,
2415/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2416/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2417/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2418/// #     ),
2419/// # ).build().await.unwrap();
2420///
2421/// # let client = hyper_util::client::legacy::Client::builder(
2422/// #     hyper_util::rt::TokioExecutor::new()
2423/// # )
2424/// # .build(
2425/// #     hyper_rustls::HttpsConnectorBuilder::new()
2426/// #         .with_native_roots()
2427/// #         .unwrap()
2428/// #         .https_or_http()
2429/// #         .enable_http2()
2430/// #         .build()
2431/// # );
2432/// # let mut hub = SmartDeviceManagement::new(client, auth);
2433/// // You can configure optional parameters by calling the respective setters at will, and
2434/// // execute the final call using `doit()`.
2435/// // Values shown here are possibly random and not representative !
2436/// let result = hub.enterprises().structures_list("parent")
2437///              .filter("duo")
2438///              .doit().await;
2439/// # }
2440/// ```
2441pub struct EnterpriseStructureListCall<'a, C>
2442where
2443    C: 'a,
2444{
2445    hub: &'a SmartDeviceManagement<C>,
2446    _parent: String,
2447    _filter: Option<String>,
2448    _delegate: Option<&'a mut dyn common::Delegate>,
2449    _additional_params: HashMap<String, String>,
2450    _scopes: BTreeSet<String>,
2451}
2452
2453impl<'a, C> common::CallBuilder for EnterpriseStructureListCall<'a, C> {}
2454
2455impl<'a, C> EnterpriseStructureListCall<'a, C>
2456where
2457    C: common::Connector,
2458{
2459    /// Perform the operation you have build so far.
2460    pub async fn doit(
2461        mut self,
2462    ) -> common::Result<(
2463        common::Response,
2464        GoogleHomeEnterpriseSdmV1ListStructuresResponse,
2465    )> {
2466        use std::borrow::Cow;
2467        use std::io::{Read, Seek};
2468
2469        use common::{url::Params, ToParts};
2470        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2471
2472        let mut dd = common::DefaultDelegate;
2473        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2474        dlg.begin(common::MethodInfo {
2475            id: "smartdevicemanagement.enterprises.structures.list",
2476            http_method: hyper::Method::GET,
2477        });
2478
2479        for &field in ["alt", "parent", "filter"].iter() {
2480            if self._additional_params.contains_key(field) {
2481                dlg.finished(false);
2482                return Err(common::Error::FieldClash(field));
2483            }
2484        }
2485
2486        let mut params = Params::with_capacity(4 + self._additional_params.len());
2487        params.push("parent", self._parent);
2488        if let Some(value) = self._filter.as_ref() {
2489            params.push("filter", value);
2490        }
2491
2492        params.extend(self._additional_params.iter());
2493
2494        params.push("alt", "json");
2495        let mut url = self.hub._base_url.clone() + "v1/{+parent}/structures";
2496        if self._scopes.is_empty() {
2497            self._scopes.insert(Scope::SdmService.as_ref().to_string());
2498        }
2499
2500        #[allow(clippy::single_element_loop)]
2501        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2502            url = params.uri_replacement(url, param_name, find_this, true);
2503        }
2504        {
2505            let to_remove = ["parent"];
2506            params.remove_params(&to_remove);
2507        }
2508
2509        let url = params.parse_with_url(&url);
2510
2511        loop {
2512            let token = match self
2513                .hub
2514                .auth
2515                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2516                .await
2517            {
2518                Ok(token) => token,
2519                Err(e) => match dlg.token(e) {
2520                    Ok(token) => token,
2521                    Err(e) => {
2522                        dlg.finished(false);
2523                        return Err(common::Error::MissingToken(e));
2524                    }
2525                },
2526            };
2527            let mut req_result = {
2528                let client = &self.hub.client;
2529                dlg.pre_request();
2530                let mut req_builder = hyper::Request::builder()
2531                    .method(hyper::Method::GET)
2532                    .uri(url.as_str())
2533                    .header(USER_AGENT, self.hub._user_agent.clone());
2534
2535                if let Some(token) = token.as_ref() {
2536                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2537                }
2538
2539                let request = req_builder
2540                    .header(CONTENT_LENGTH, 0_u64)
2541                    .body(common::to_body::<String>(None));
2542
2543                client.request(request.unwrap()).await
2544            };
2545
2546            match req_result {
2547                Err(err) => {
2548                    if let common::Retry::After(d) = dlg.http_error(&err) {
2549                        sleep(d).await;
2550                        continue;
2551                    }
2552                    dlg.finished(false);
2553                    return Err(common::Error::HttpError(err));
2554                }
2555                Ok(res) => {
2556                    let (mut parts, body) = res.into_parts();
2557                    let mut body = common::Body::new(body);
2558                    if !parts.status.is_success() {
2559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2560                        let error = serde_json::from_str(&common::to_string(&bytes));
2561                        let response = common::to_response(parts, bytes.into());
2562
2563                        if let common::Retry::After(d) =
2564                            dlg.http_failure(&response, error.as_ref().ok())
2565                        {
2566                            sleep(d).await;
2567                            continue;
2568                        }
2569
2570                        dlg.finished(false);
2571
2572                        return Err(match error {
2573                            Ok(value) => common::Error::BadRequest(value),
2574                            _ => common::Error::Failure(response),
2575                        });
2576                    }
2577                    let response = {
2578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2579                        let encoded = common::to_string(&bytes);
2580                        match serde_json::from_str(&encoded) {
2581                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2582                            Err(error) => {
2583                                dlg.response_json_decode_error(&encoded, &error);
2584                                return Err(common::Error::JsonDecodeError(
2585                                    encoded.to_string(),
2586                                    error,
2587                                ));
2588                            }
2589                        }
2590                    };
2591
2592                    dlg.finished(true);
2593                    return Ok(response);
2594                }
2595            }
2596        }
2597    }
2598
2599    /// The parent enterprise to list structures under. E.g. "enterprises/XYZ".
2600    ///
2601    /// Sets the *parent* path property to the given value.
2602    ///
2603    /// Even though the property as already been set when instantiating this call,
2604    /// we provide this method for API completeness.
2605    pub fn parent(mut self, new_value: &str) -> EnterpriseStructureListCall<'a, C> {
2606        self._parent = new_value.to_string();
2607        self
2608    }
2609    /// Optional filter to list structures.
2610    ///
2611    /// Sets the *filter* query property to the given value.
2612    pub fn filter(mut self, new_value: &str) -> EnterpriseStructureListCall<'a, C> {
2613        self._filter = Some(new_value.to_string());
2614        self
2615    }
2616    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2617    /// while executing the actual API request.
2618    ///
2619    /// ````text
2620    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2621    /// ````
2622    ///
2623    /// Sets the *delegate* property to the given value.
2624    pub fn delegate(
2625        mut self,
2626        new_value: &'a mut dyn common::Delegate,
2627    ) -> EnterpriseStructureListCall<'a, C> {
2628        self._delegate = Some(new_value);
2629        self
2630    }
2631
2632    /// Set any additional parameter of the query string used in the request.
2633    /// It should be used to set parameters which are not yet available through their own
2634    /// setters.
2635    ///
2636    /// Please note that this method must not be used to set any of the known parameters
2637    /// which have their own setter method. If done anyway, the request will fail.
2638    ///
2639    /// # Additional Parameters
2640    ///
2641    /// * *$.xgafv* (query-string) - V1 error format.
2642    /// * *access_token* (query-string) - OAuth access token.
2643    /// * *alt* (query-string) - Data format for response.
2644    /// * *callback* (query-string) - JSONP
2645    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2646    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2647    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2648    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2649    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2650    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2651    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2652    pub fn param<T>(mut self, name: T, value: T) -> EnterpriseStructureListCall<'a, C>
2653    where
2654        T: AsRef<str>,
2655    {
2656        self._additional_params
2657            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2658        self
2659    }
2660
2661    /// Identifies the authorization scope for the method you are building.
2662    ///
2663    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2664    /// [`Scope::SdmService`].
2665    ///
2666    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2667    /// tokens for more than one scope.
2668    ///
2669    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2670    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2671    /// sufficient, a read-write scope will do as well.
2672    pub fn add_scope<St>(mut self, scope: St) -> EnterpriseStructureListCall<'a, C>
2673    where
2674        St: AsRef<str>,
2675    {
2676        self._scopes.insert(String::from(scope.as_ref()));
2677        self
2678    }
2679    /// Identifies the authorization scope(s) for the method you are building.
2680    ///
2681    /// See [`Self::add_scope()`] for details.
2682    pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseStructureListCall<'a, C>
2683    where
2684        I: IntoIterator<Item = St>,
2685        St: AsRef<str>,
2686    {
2687        self._scopes
2688            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2689        self
2690    }
2691
2692    /// Removes all scopes, and no default scope will be used either.
2693    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2694    /// for details).
2695    pub fn clear_scopes(mut self) -> EnterpriseStructureListCall<'a, C> {
2696        self._scopes.clear();
2697        self
2698    }
2699}