google_cloudiot1/
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, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18
19    /// Register and manage devices in the Google Cloud IoT service
20    Full,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::Full => "https://www.googleapis.com/auth/cloudiot",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::Full
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all CloudIot related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_cloudiot1 as cloudiot1;
53/// use cloudiot1::api::GetIamPolicyRequest;
54/// use cloudiot1::{Result, Error};
55/// # async fn dox() {
56/// use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67///     .with_native_roots()
68///     .unwrap()
69///     .https_only()
70///     .enable_http2()
71///     .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75///     secret,
76///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77///     yup_oauth2::client::CustomHyperClientBuilder::from(
78///         hyper_util::client::legacy::Client::builder(executor).build(connector),
79///     ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83///     hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86///     hyper_rustls::HttpsConnectorBuilder::new()
87///         .with_native_roots()
88///         .unwrap()
89///         .https_or_http()
90///         .enable_http2()
91///         .build()
92/// );
93/// let mut hub = CloudIot::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = GetIamPolicyRequest::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.projects().locations_registries_groups_get_iam_policy(req, "resource")
103///              .doit().await;
104///
105/// match result {
106///     Err(e) => match e {
107///         // The Error enum provides details about what exactly happened.
108///         // You can also just use its `Debug`, `Display` or `Error` traits
109///          Error::HttpError(_)
110///         |Error::Io(_)
111///         |Error::MissingAPIKey
112///         |Error::MissingToken(_)
113///         |Error::Cancelled
114///         |Error::UploadSizeLimitExceeded(_, _)
115///         |Error::Failure(_)
116///         |Error::BadRequest(_)
117///         |Error::FieldClash(_)
118///         |Error::JsonDecodeError(_, _) => println!("{}", e),
119///     },
120///     Ok(res) => println!("Success: {:?}", res),
121/// }
122/// # }
123/// ```
124#[derive(Clone)]
125pub struct CloudIot<C> {
126    pub client: common::Client<C>,
127    pub auth: Box<dyn common::GetToken>,
128    _user_agent: String,
129    _base_url: String,
130    _root_url: String,
131}
132
133impl<C> common::Hub for CloudIot<C> {}
134
135impl<'a, C> CloudIot<C> {
136    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudIot<C> {
137        CloudIot {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://cloudiot.googleapis.com/".to_string(),
142            _root_url: "https://cloudiot.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147        ProjectMethods { hub: self }
148    }
149
150    /// Set the user-agent header field to use in all requests to the server.
151    /// It defaults to `google-api-rust-client/7.0.0`.
152    ///
153    /// Returns the previously set user-agent.
154    pub fn user_agent(&mut self, agent_name: String) -> String {
155        std::mem::replace(&mut self._user_agent, agent_name)
156    }
157
158    /// Set the base url to use in all requests to the server.
159    /// It defaults to `https://cloudiot.googleapis.com/`.
160    ///
161    /// Returns the previously set base url.
162    pub fn base_url(&mut self, new_base_url: String) -> String {
163        std::mem::replace(&mut self._base_url, new_base_url)
164    }
165
166    /// Set the root url to use in all requests to the server.
167    /// It defaults to `https://cloudiot.googleapis.com/`.
168    ///
169    /// Returns the previously set root url.
170    pub fn root_url(&mut self, new_root_url: String) -> String {
171        std::mem::replace(&mut self._root_url, new_root_url)
172    }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Request for `BindDeviceToGateway`.
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [locations registries bind device to gateway projects](ProjectLocationRegistryBindDeviceToGatewayCall) (request)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct BindDeviceToGatewayRequest {
190    /// Required. The device to associate with the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.
191    #[serde(rename = "deviceId")]
192    pub device_id: Option<String>,
193    /// Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.
194    #[serde(rename = "gatewayId")]
195    pub gateway_id: Option<String>,
196}
197
198impl common::RequestValue for BindDeviceToGatewayRequest {}
199
200/// Response for `BindDeviceToGateway`.
201///
202/// # Activities
203///
204/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
205/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
206///
207/// * [locations registries bind device to gateway projects](ProjectLocationRegistryBindDeviceToGatewayCall) (response)
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as]
210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
211pub struct BindDeviceToGatewayResponse {
212    _never_set: Option<bool>,
213}
214
215impl common::ResponseResult for BindDeviceToGatewayResponse {}
216
217/// Associates `members`, or principals, with a `role`.
218///
219/// This type is not used in any activity, and only used as *part* of another schema.
220///
221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
222#[serde_with::serde_as]
223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
224pub struct Binding {
225    /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
226    pub condition: Option<Expr>,
227    /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
228    pub members: Option<Vec<String>>,
229    /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
230    pub role: Option<String>,
231}
232
233impl common::Part for Binding {}
234
235/// The device resource.
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/// * [locations registries devices create projects](ProjectLocationRegistryDeviceCreateCall) (request|response)
243/// * [locations registries devices get projects](ProjectLocationRegistryDeviceGetCall) (response)
244/// * [locations registries devices patch projects](ProjectLocationRegistryDevicePatchCall) (request|response)
245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
246#[serde_with::serde_as]
247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
248pub struct Device {
249    /// If a device is blocked, connections or requests from this device will fail. Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.
250    pub blocked: Option<bool>,
251    /// The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of `1`. To update this field after creation, use the `DeviceManager.ModifyCloudToDeviceConfig` method.
252    pub config: Option<DeviceConfig>,
253    /// The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the `DeviceRegistry.credentials` field.
254    pub credentials: Option<Vec<DeviceCredential>>,
255    /// Gateway-related configuration and state.
256    #[serde(rename = "gatewayConfig")]
257    pub gateway_config: Option<GatewayConfig>,
258    /// The user-defined device identifier. The device ID must be unique within a device registry.
259    pub id: Option<String>,
260    /// [Output only] The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.
261    #[serde(rename = "lastConfigAckTime")]
262    pub last_config_ack_time: Option<chrono::DateTime<chrono::offset::Utc>>,
263    /// [Output only] The last time a cloud-to-device config version was sent to the device.
264    #[serde(rename = "lastConfigSendTime")]
265    pub last_config_send_time: Option<chrono::DateTime<chrono::offset::Utc>>,
266    /// [Output only] The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.
267    #[serde(rename = "lastErrorStatus")]
268    pub last_error_status: Option<Status>,
269    /// [Output only] The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.
270    #[serde(rename = "lastErrorTime")]
271    pub last_error_time: Option<chrono::DateTime<chrono::offset::Utc>>,
272    /// [Output only] The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
273    #[serde(rename = "lastEventTime")]
274    pub last_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
275    /// [Output only] The last time an MQTT `PINGREQ` was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send `PINGREQ` messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
276    #[serde(rename = "lastHeartbeatTime")]
277    pub last_heartbeat_time: Option<chrono::DateTime<chrono::offset::Utc>>,
278    /// [Output only] The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
279    #[serde(rename = "lastStateTime")]
280    pub last_state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
281    /// **Beta Feature** The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.
282    #[serde(rename = "logLevel")]
283    pub log_level: Option<String>,
284    /// The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device. Keys must conform to the regular expression a-zA-Z+ and be less than 128 bytes in length. Values are free-form strings. Each value must be less than or equal to 32 KB in size. The total size of all keys and values must be less than 256 KB, and the maximum number of key-value pairs is 500.
285    pub metadata: Option<HashMap<String, String>>,
286    /// The resource path name. For example, `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. When `name` is populated as a response from the service, it always ends in the device numeric ID.
287    pub name: Option<String>,
288    /// [Output only] A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.
289    #[serde(rename = "numId")]
290    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
291    pub num_id: Option<u64>,
292    /// [Output only] The state most recently received from the device. If no state has been reported, this field is not present.
293    pub state: Option<DeviceState>,
294}
295
296impl common::RequestValue for Device {}
297impl common::ResponseResult for Device {}
298
299/// The device configuration. Eventually delivered to devices.
300///
301/// # Activities
302///
303/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
304/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
305///
306/// * [locations registries devices modify cloud to device config projects](ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall) (response)
307#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
308#[serde_with::serde_as]
309#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
310pub struct DeviceConfig {
311    /// The device configuration data.
312    #[serde(rename = "binaryData")]
313    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
314    pub binary_data: Option<Vec<u8>>,
315    /// [Output only] The time at which this configuration version was updated in Cloud IoT Core. This timestamp is set by the server.
316    #[serde(rename = "cloudUpdateTime")]
317    pub cloud_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
318    /// [Output only] The time at which Cloud IoT Core received the acknowledgment from the device, indicating that the device has received this configuration version. If this field is not present, the device has not yet acknowledged that it received this version. Note that when the config was sent to the device, many config versions may have been available in Cloud IoT Core while the device was disconnected, and on connection, only the latest version is sent to the device. Some versions may never be sent to the device, and therefore are never acknowledged. This timestamp is set by Cloud IoT Core.
319    #[serde(rename = "deviceAckTime")]
320    pub device_ack_time: Option<chrono::DateTime<chrono::offset::Utc>>,
321    /// [Output only] The version of this update. The version number is assigned by the server, and is always greater than 0 after device creation. The version must be 0 on the `CreateDevice` request if a `config` is specified; the response of `CreateDevice` will always have a value of 1.
322    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
323    pub version: Option<i64>,
324}
325
326impl common::ResponseResult for DeviceConfig {}
327
328/// A server-stored device credential used for authentication.
329///
330/// This type is not used in any activity, and only used as *part* of another schema.
331///
332#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
333#[serde_with::serde_as]
334#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
335pub struct DeviceCredential {
336    /// [Optional] The time at which this credential becomes invalid. This credential will be ignored for new client authentication requests after this timestamp; however, it will not be automatically deleted.
337    #[serde(rename = "expirationTime")]
338    pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
339    /// A public key used to verify the signature of JSON Web Tokens (JWTs). When adding a new device credential, either via device creation or via modifications, this public key credential may be required to be signed by one of the registry level certificates. More specifically, if the registry contains at least one certificate, any new device credential must be signed by one of the registry certificates. As a result, when the registry contains certificates, only X.509 certificates are accepted as device credentials. However, if the registry does not contain a certificate, self-signed certificates and public keys will be accepted. New device credentials must be different from every registry-level certificate.
340    #[serde(rename = "publicKey")]
341    pub public_key: Option<PublicKeyCredential>,
342}
343
344impl common::Part for DeviceCredential {}
345
346/// A container for a group of devices.
347///
348/// # Activities
349///
350/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
351/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
352///
353/// * [locations registries create projects](ProjectLocationRegistryCreateCall) (request|response)
354/// * [locations registries get projects](ProjectLocationRegistryGetCall) (response)
355/// * [locations registries patch projects](ProjectLocationRegistryPatchCall) (request|response)
356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
357#[serde_with::serde_as]
358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
359pub struct DeviceRegistry {
360    /// The credentials used to verify the device credentials. No more than 10 credentials can be bound to a single registry at a time. The verification process occurs at the time of device creation or update. If this field is empty, no verification is performed. Otherwise, the credentials of a newly created device or added credentials of an updated device should be signed with one of these registry credentials. Note, however, that existing devices will never be affected by modifications to this list of credentials: after a device has been successfully created in a registry, it should be able to connect even if its registry credentials are revoked, deleted, or modified.
361    pub credentials: Option<Vec<RegistryCredential>>,
362    /// The configuration for notification of telemetry events received from the device. All telemetry events that were successfully published by the device and acknowledged by Cloud IoT Core are guaranteed to be delivered to Cloud Pub/Sub. If multiple configurations match a message, only the first matching configuration is used. If you try to publish a device telemetry event using MQTT without specifying a Cloud Pub/Sub topic for the device's registry, the connection closes automatically. If you try to do so using an HTTP connection, an error is returned. Up to 10 configurations may be provided.
363    #[serde(rename = "eventNotificationConfigs")]
364    pub event_notification_configs: Option<Vec<EventNotificationConfig>>,
365    /// The DeviceService (HTTP) configuration for this device registry.
366    #[serde(rename = "httpConfig")]
367    pub http_config: Option<HttpConfig>,
368    /// The identifier of this device registry. For example, `myRegistry`.
369    pub id: Option<String>,
370    /// **Beta Feature** The default logging verbosity for activity from devices in this registry. The verbosity level can be overridden by Device.log_level.
371    #[serde(rename = "logLevel")]
372    pub log_level: Option<String>,
373    /// The MQTT configuration for this device registry.
374    #[serde(rename = "mqttConfig")]
375    pub mqtt_config: Option<MqttConfig>,
376    /// The resource path name. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
377    pub name: Option<String>,
378    /// The configuration for notification of new states received from the device. State updates are guaranteed to be stored in the state history, but notifications to Cloud Pub/Sub are not guaranteed. For example, if permissions are misconfigured or the specified topic doesn't exist, no notification will be published but the state will still be stored in Cloud IoT Core.
379    #[serde(rename = "stateNotificationConfig")]
380    pub state_notification_config: Option<StateNotificationConfig>,
381}
382
383impl common::RequestValue for DeviceRegistry {}
384impl common::ResponseResult for DeviceRegistry {}
385
386/// The device state, as reported by the device.
387///
388/// This type is not used in any activity, and only used as *part* of another schema.
389///
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct DeviceState {
394    /// The device state data.
395    #[serde(rename = "binaryData")]
396    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
397    pub binary_data: Option<Vec<u8>>,
398    /// [Output only] The time at which this state version was updated in Cloud IoT Core.
399    #[serde(rename = "updateTime")]
400    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
401}
402
403impl common::Part for DeviceState {}
404
405/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
406///
407/// # Activities
408///
409/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
410/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
411///
412/// * [locations registries devices delete projects](ProjectLocationRegistryDeviceDeleteCall) (response)
413/// * [locations registries delete projects](ProjectLocationRegistryDeleteCall) (response)
414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
415#[serde_with::serde_as]
416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
417pub struct Empty {
418    _never_set: Option<bool>,
419}
420
421impl common::ResponseResult for Empty {}
422
423/// The configuration for forwarding telemetry events.
424///
425/// This type is not used in any activity, and only used as *part* of another schema.
426///
427#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
428#[serde_with::serde_as]
429#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
430pub struct EventNotificationConfig {
431    /// A Cloud Pub/Sub topic name. For example, `projects/myProject/topics/deviceEvents`.
432    #[serde(rename = "pubsubTopicName")]
433    pub pubsub_topic_name: Option<String>,
434    /// If the subfolder name matches this string exactly, this configuration will be used. The string must not include the leading '/' character. If empty, all strings are matched. This field is used only for telemetry events; subfolders are not supported for state changes.
435    #[serde(rename = "subfolderMatches")]
436    pub subfolder_matches: Option<String>,
437}
438
439impl common::Part for EventNotificationConfig {}
440
441/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
442///
443/// This type is not used in any activity, and only used as *part* of another schema.
444///
445#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
446#[serde_with::serde_as]
447#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
448pub struct Expr {
449    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
450    pub description: Option<String>,
451    /// Textual representation of an expression in Common Expression Language syntax.
452    pub expression: Option<String>,
453    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
454    pub location: Option<String>,
455    /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
456    pub title: Option<String>,
457}
458
459impl common::Part for Expr {}
460
461/// Gateway-related configuration and state.
462///
463/// This type is not used in any activity, and only used as *part* of another schema.
464///
465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
466#[serde_with::serde_as]
467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
468pub struct GatewayConfig {
469    /// Indicates how to authorize and/or authenticate devices to access the gateway.
470    #[serde(rename = "gatewayAuthMethod")]
471    pub gateway_auth_method: Option<String>,
472    /// Indicates whether the device is a gateway.
473    #[serde(rename = "gatewayType")]
474    pub gateway_type: Option<String>,
475    /// [Output only] The ID of the gateway the device accessed most recently.
476    #[serde(rename = "lastAccessedGatewayId")]
477    pub last_accessed_gateway_id: Option<String>,
478    /// [Output only] The most recent time at which the device accessed the gateway specified in `last_accessed_gateway`.
479    #[serde(rename = "lastAccessedGatewayTime")]
480    pub last_accessed_gateway_time: Option<chrono::DateTime<chrono::offset::Utc>>,
481}
482
483impl common::Part for GatewayConfig {}
484
485/// Request message for `GetIamPolicy` method.
486///
487/// # Activities
488///
489/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
490/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
491///
492/// * [locations registries groups get iam policy projects](ProjectLocationRegistryGroupGetIamPolicyCall) (request)
493/// * [locations registries get iam policy projects](ProjectLocationRegistryGetIamPolicyCall) (request)
494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
495#[serde_with::serde_as]
496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
497pub struct GetIamPolicyRequest {
498    /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
499    pub options: Option<GetPolicyOptions>,
500}
501
502impl common::RequestValue for GetIamPolicyRequest {}
503
504/// Encapsulates settings provided to GetIamPolicy.
505///
506/// This type is not used in any activity, and only used as *part* of another schema.
507///
508#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
509#[serde_with::serde_as]
510#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
511pub struct GetPolicyOptions {
512    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
513    #[serde(rename = "requestedPolicyVersion")]
514    pub requested_policy_version: Option<i32>,
515}
516
517impl common::Part for GetPolicyOptions {}
518
519/// The configuration of the HTTP bridge for a device registry.
520///
521/// This type is not used in any activity, and only used as *part* of another schema.
522///
523#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
524#[serde_with::serde_as]
525#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
526pub struct HttpConfig {
527    /// If enabled, allows devices to use DeviceService via the HTTP protocol. Otherwise, any requests to DeviceService will fail for this registry.
528    #[serde(rename = "httpEnabledState")]
529    pub http_enabled_state: Option<String>,
530}
531
532impl common::Part for HttpConfig {}
533
534/// Response for `ListDeviceConfigVersions`.
535///
536/// # Activities
537///
538/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
539/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
540///
541/// * [locations registries devices config versions list projects](ProjectLocationRegistryDeviceConfigVersionListCall) (response)
542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
543#[serde_with::serde_as]
544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
545pub struct ListDeviceConfigVersionsResponse {
546    /// The device configuration for the last few versions. Versions are listed in decreasing order, starting from the most recent one.
547    #[serde(rename = "deviceConfigs")]
548    pub device_configs: Option<Vec<DeviceConfig>>,
549}
550
551impl common::ResponseResult for ListDeviceConfigVersionsResponse {}
552
553/// Response for `ListDeviceRegistries`.
554///
555/// # Activities
556///
557/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
558/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
559///
560/// * [locations registries list projects](ProjectLocationRegistryListCall) (response)
561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
562#[serde_with::serde_as]
563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
564pub struct ListDeviceRegistriesResponse {
565    /// The registries that matched the query.
566    #[serde(rename = "deviceRegistries")]
567    pub device_registries: Option<Vec<DeviceRegistry>>,
568    /// If not empty, indicates that there may be more registries that match the request; this value should be passed in a new `ListDeviceRegistriesRequest`.
569    #[serde(rename = "nextPageToken")]
570    pub next_page_token: Option<String>,
571}
572
573impl common::ResponseResult for ListDeviceRegistriesResponse {}
574
575/// Response for `ListDeviceStates`.
576///
577/// # Activities
578///
579/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
580/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
581///
582/// * [locations registries devices states list projects](ProjectLocationRegistryDeviceStateListCall) (response)
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as]
585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
586pub struct ListDeviceStatesResponse {
587    /// The last few device states. States are listed in descending order of server update time, starting from the most recent one.
588    #[serde(rename = "deviceStates")]
589    pub device_states: Option<Vec<DeviceState>>,
590}
591
592impl common::ResponseResult for ListDeviceStatesResponse {}
593
594/// Response for `ListDevices`.
595///
596/// # Activities
597///
598/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
599/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
600///
601/// * [locations registries devices list projects](ProjectLocationRegistryDeviceListCall) (response)
602/// * [locations registries groups devices list projects](ProjectLocationRegistryGroupDeviceListCall) (response)
603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
604#[serde_with::serde_as]
605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
606pub struct ListDevicesResponse {
607    /// The devices that match the request.
608    pub devices: Option<Vec<Device>>,
609    /// If not empty, indicates that there may be more devices that match the request; this value should be passed in a new `ListDevicesRequest`.
610    #[serde(rename = "nextPageToken")]
611    pub next_page_token: Option<String>,
612}
613
614impl common::ResponseResult for ListDevicesResponse {}
615
616/// Request for `ModifyCloudToDeviceConfig`.
617///
618/// # Activities
619///
620/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
621/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
622///
623/// * [locations registries devices modify cloud to device config projects](ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall) (request)
624#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
625#[serde_with::serde_as]
626#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
627pub struct ModifyCloudToDeviceConfigRequest {
628    /// Required. The configuration data for the device.
629    #[serde(rename = "binaryData")]
630    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
631    pub binary_data: Option<Vec<u8>>,
632    /// The version number to update. If this value is zero, it will not check the version number of the server and will always update the current version; otherwise, this update will fail if the version number found on the server does not match this version number. This is used to support multiple simultaneous updates without losing data.
633    #[serde(rename = "versionToUpdate")]
634    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
635    pub version_to_update: Option<i64>,
636}
637
638impl common::RequestValue for ModifyCloudToDeviceConfigRequest {}
639
640/// The configuration of MQTT for a device registry.
641///
642/// This type is not used in any activity, and only used as *part* of another schema.
643///
644#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
645#[serde_with::serde_as]
646#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
647pub struct MqttConfig {
648    /// If enabled, allows connections using the MQTT protocol. Otherwise, MQTT connections to this registry will fail.
649    #[serde(rename = "mqttEnabledState")]
650    pub mqtt_enabled_state: Option<String>,
651}
652
653impl common::Part for MqttConfig {}
654
655/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
656///
657/// # Activities
658///
659/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
660/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
661///
662/// * [locations registries groups get iam policy projects](ProjectLocationRegistryGroupGetIamPolicyCall) (response)
663/// * [locations registries groups set iam policy projects](ProjectLocationRegistryGroupSetIamPolicyCall) (response)
664/// * [locations registries get iam policy projects](ProjectLocationRegistryGetIamPolicyCall) (response)
665/// * [locations registries set iam policy projects](ProjectLocationRegistrySetIamPolicyCall) (response)
666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
667#[serde_with::serde_as]
668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
669pub struct Policy {
670    /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
671    pub bindings: Option<Vec<Binding>>,
672    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
673    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
674    pub etag: Option<Vec<u8>>,
675    /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
676    pub version: Option<i32>,
677}
678
679impl common::ResponseResult for Policy {}
680
681/// A public key certificate format and data.
682///
683/// This type is not used in any activity, and only used as *part* of another schema.
684///
685#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
686#[serde_with::serde_as]
687#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
688pub struct PublicKeyCertificate {
689    /// The certificate data.
690    pub certificate: Option<String>,
691    /// The certificate format.
692    pub format: Option<String>,
693    /// [Output only] The certificate details. Used only for X.509 certificates.
694    #[serde(rename = "x509Details")]
695    pub x509_details: Option<X509CertificateDetails>,
696}
697
698impl common::Part for PublicKeyCertificate {}
699
700/// A public key format and data.
701///
702/// This type is not used in any activity, and only used as *part* of another schema.
703///
704#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
705#[serde_with::serde_as]
706#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
707pub struct PublicKeyCredential {
708    /// The format of the key.
709    pub format: Option<String>,
710    /// The key data.
711    pub key: Option<String>,
712}
713
714impl common::Part for PublicKeyCredential {}
715
716/// A server-stored registry credential used to validate device credentials.
717///
718/// This type is not used in any activity, and only used as *part* of another schema.
719///
720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
721#[serde_with::serde_as]
722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
723pub struct RegistryCredential {
724    /// A public key certificate used to verify the device credentials.
725    #[serde(rename = "publicKeyCertificate")]
726    pub public_key_certificate: Option<PublicKeyCertificate>,
727}
728
729impl common::Part for RegistryCredential {}
730
731/// Request for `SendCommandToDevice`.
732///
733/// # Activities
734///
735/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
736/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
737///
738/// * [locations registries devices send command to device projects](ProjectLocationRegistryDeviceSendCommandToDeviceCall) (request)
739#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
740#[serde_with::serde_as]
741#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
742pub struct SendCommandToDeviceRequest {
743    /// Required. The command data to send to the device.
744    #[serde(rename = "binaryData")]
745    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
746    pub binary_data: Option<Vec<u8>>,
747    /// Optional subfolder for the command. If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise it will be delivered to the /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" or "#") or null characters.
748    pub subfolder: Option<String>,
749}
750
751impl common::RequestValue for SendCommandToDeviceRequest {}
752
753/// Response for `SendCommandToDevice`.
754///
755/// # Activities
756///
757/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
758/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
759///
760/// * [locations registries devices send command to device projects](ProjectLocationRegistryDeviceSendCommandToDeviceCall) (response)
761#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
762#[serde_with::serde_as]
763#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
764pub struct SendCommandToDeviceResponse {
765    _never_set: Option<bool>,
766}
767
768impl common::ResponseResult for SendCommandToDeviceResponse {}
769
770/// Request message for `SetIamPolicy` method.
771///
772/// # Activities
773///
774/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
775/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
776///
777/// * [locations registries groups set iam policy projects](ProjectLocationRegistryGroupSetIamPolicyCall) (request)
778/// * [locations registries set iam policy projects](ProjectLocationRegistrySetIamPolicyCall) (request)
779#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
780#[serde_with::serde_as]
781#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
782pub struct SetIamPolicyRequest {
783    /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
784    pub policy: Option<Policy>,
785}
786
787impl common::RequestValue for SetIamPolicyRequest {}
788
789/// The configuration for notification of new states received from the device.
790///
791/// This type is not used in any activity, and only used as *part* of another schema.
792///
793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
794#[serde_with::serde_as]
795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
796pub struct StateNotificationConfig {
797    /// A Cloud Pub/Sub topic name. For example, `projects/myProject/topics/deviceEvents`.
798    #[serde(rename = "pubsubTopicName")]
799    pub pubsub_topic_name: Option<String>,
800}
801
802impl common::Part for StateNotificationConfig {}
803
804/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
805///
806/// This type is not used in any activity, and only used as *part* of another schema.
807///
808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
809#[serde_with::serde_as]
810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
811pub struct Status {
812    /// The status code, which should be an enum value of google.rpc.Code.
813    pub code: Option<i32>,
814    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
815    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
816    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
817    pub message: Option<String>,
818}
819
820impl common::Part for Status {}
821
822/// Request message for `TestIamPermissions` method.
823///
824/// # Activities
825///
826/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
827/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
828///
829/// * [locations registries groups test iam permissions projects](ProjectLocationRegistryGroupTestIamPermissionCall) (request)
830/// * [locations registries test iam permissions projects](ProjectLocationRegistryTestIamPermissionCall) (request)
831#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
832#[serde_with::serde_as]
833#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
834pub struct TestIamPermissionsRequest {
835    /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
836    pub permissions: Option<Vec<String>>,
837}
838
839impl common::RequestValue for TestIamPermissionsRequest {}
840
841/// Response message for `TestIamPermissions` method.
842///
843/// # Activities
844///
845/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
846/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
847///
848/// * [locations registries groups test iam permissions projects](ProjectLocationRegistryGroupTestIamPermissionCall) (response)
849/// * [locations registries test iam permissions projects](ProjectLocationRegistryTestIamPermissionCall) (response)
850#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
851#[serde_with::serde_as]
852#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
853pub struct TestIamPermissionsResponse {
854    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
855    pub permissions: Option<Vec<String>>,
856}
857
858impl common::ResponseResult for TestIamPermissionsResponse {}
859
860/// Request for `UnbindDeviceFromGateway`.
861///
862/// # Activities
863///
864/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
865/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
866///
867/// * [locations registries unbind device from gateway projects](ProjectLocationRegistryUnbindDeviceFromGatewayCall) (request)
868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
869#[serde_with::serde_as]
870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
871pub struct UnbindDeviceFromGatewayRequest {
872    /// Required. The device to disassociate from the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.
873    #[serde(rename = "deviceId")]
874    pub device_id: Option<String>,
875    /// Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.
876    #[serde(rename = "gatewayId")]
877    pub gateway_id: Option<String>,
878}
879
880impl common::RequestValue for UnbindDeviceFromGatewayRequest {}
881
882/// Response for `UnbindDeviceFromGateway`.
883///
884/// # Activities
885///
886/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
887/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
888///
889/// * [locations registries unbind device from gateway projects](ProjectLocationRegistryUnbindDeviceFromGatewayCall) (response)
890#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
891#[serde_with::serde_as]
892#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
893pub struct UnbindDeviceFromGatewayResponse {
894    _never_set: Option<bool>,
895}
896
897impl common::ResponseResult for UnbindDeviceFromGatewayResponse {}
898
899/// Details of an X.509 certificate. For informational purposes only.
900///
901/// This type is not used in any activity, and only used as *part* of another schema.
902///
903#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
904#[serde_with::serde_as]
905#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
906pub struct X509CertificateDetails {
907    /// The time the certificate becomes invalid.
908    #[serde(rename = "expiryTime")]
909    pub expiry_time: Option<chrono::DateTime<chrono::offset::Utc>>,
910    /// The entity that signed the certificate.
911    pub issuer: Option<String>,
912    /// The type of public key in the certificate.
913    #[serde(rename = "publicKeyType")]
914    pub public_key_type: Option<String>,
915    /// The algorithm used to sign the certificate.
916    #[serde(rename = "signatureAlgorithm")]
917    pub signature_algorithm: Option<String>,
918    /// The time the certificate becomes valid.
919    #[serde(rename = "startTime")]
920    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
921    /// The entity the certificate and public key belong to.
922    pub subject: Option<String>,
923}
924
925impl common::Part for X509CertificateDetails {}
926
927// ###################
928// MethodBuilders ###
929// #################
930
931/// A builder providing access to all methods supported on *project* resources.
932/// It is not used directly, but through the [`CloudIot`] hub.
933///
934/// # Example
935///
936/// Instantiate a resource builder
937///
938/// ```test_harness,no_run
939/// extern crate hyper;
940/// extern crate hyper_rustls;
941/// extern crate google_cloudiot1 as cloudiot1;
942///
943/// # async fn dox() {
944/// use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
945///
946/// let secret: yup_oauth2::ApplicationSecret = Default::default();
947/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
948///     .with_native_roots()
949///     .unwrap()
950///     .https_only()
951///     .enable_http2()
952///     .build();
953///
954/// let executor = hyper_util::rt::TokioExecutor::new();
955/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
956///     secret,
957///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
958///     yup_oauth2::client::CustomHyperClientBuilder::from(
959///         hyper_util::client::legacy::Client::builder(executor).build(connector),
960///     ),
961/// ).build().await.unwrap();
962///
963/// let client = hyper_util::client::legacy::Client::builder(
964///     hyper_util::rt::TokioExecutor::new()
965/// )
966/// .build(
967///     hyper_rustls::HttpsConnectorBuilder::new()
968///         .with_native_roots()
969///         .unwrap()
970///         .https_or_http()
971///         .enable_http2()
972///         .build()
973/// );
974/// let mut hub = CloudIot::new(client, auth);
975/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
976/// // like `locations_registries_bind_device_to_gateway(...)`, `locations_registries_create(...)`, `locations_registries_delete(...)`, `locations_registries_devices_config_versions_list(...)`, `locations_registries_devices_create(...)`, `locations_registries_devices_delete(...)`, `locations_registries_devices_get(...)`, `locations_registries_devices_list(...)`, `locations_registries_devices_modify_cloud_to_device_config(...)`, `locations_registries_devices_patch(...)`, `locations_registries_devices_send_command_to_device(...)`, `locations_registries_devices_states_list(...)`, `locations_registries_get(...)`, `locations_registries_get_iam_policy(...)`, `locations_registries_groups_devices_list(...)`, `locations_registries_groups_get_iam_policy(...)`, `locations_registries_groups_set_iam_policy(...)`, `locations_registries_groups_test_iam_permissions(...)`, `locations_registries_list(...)`, `locations_registries_patch(...)`, `locations_registries_set_iam_policy(...)`, `locations_registries_test_iam_permissions(...)` and `locations_registries_unbind_device_from_gateway(...)`
977/// // to build up your call.
978/// let rb = hub.projects();
979/// # }
980/// ```
981pub struct ProjectMethods<'a, C>
982where
983    C: 'a,
984{
985    hub: &'a CloudIot<C>,
986}
987
988impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
989
990impl<'a, C> ProjectMethods<'a, C> {
991    /// Create a builder to help you perform the following task:
992    ///
993    /// Lists the last few versions of the device configuration in descending order (i.e.: newest first).
994    ///
995    /// # Arguments
996    ///
997    /// * `name` - Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
998    pub fn locations_registries_devices_config_versions_list(
999        &self,
1000        name: &str,
1001    ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1002        ProjectLocationRegistryDeviceConfigVersionListCall {
1003            hub: self.hub,
1004            _name: name.to_string(),
1005            _num_versions: Default::default(),
1006            _delegate: Default::default(),
1007            _additional_params: Default::default(),
1008            _scopes: Default::default(),
1009        }
1010    }
1011
1012    /// Create a builder to help you perform the following task:
1013    ///
1014    /// Lists the last few versions of the device state in descending order (i.e.: newest first).
1015    ///
1016    /// # Arguments
1017    ///
1018    /// * `name` - Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1019    pub fn locations_registries_devices_states_list(
1020        &self,
1021        name: &str,
1022    ) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
1023        ProjectLocationRegistryDeviceStateListCall {
1024            hub: self.hub,
1025            _name: name.to_string(),
1026            _num_states: Default::default(),
1027            _delegate: Default::default(),
1028            _additional_params: Default::default(),
1029            _scopes: Default::default(),
1030        }
1031    }
1032
1033    /// Create a builder to help you perform the following task:
1034    ///
1035    /// Creates a device in a device registry.
1036    ///
1037    /// # Arguments
1038    ///
1039    /// * `request` - No description provided.
1040    /// * `parent` - Required. The name of the device registry where this device should be created. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1041    pub fn locations_registries_devices_create(
1042        &self,
1043        request: Device,
1044        parent: &str,
1045    ) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
1046        ProjectLocationRegistryDeviceCreateCall {
1047            hub: self.hub,
1048            _request: request,
1049            _parent: parent.to_string(),
1050            _delegate: Default::default(),
1051            _additional_params: Default::default(),
1052            _scopes: Default::default(),
1053        }
1054    }
1055
1056    /// Create a builder to help you perform the following task:
1057    ///
1058    /// Deletes a device.
1059    ///
1060    /// # Arguments
1061    ///
1062    /// * `name` - Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1063    pub fn locations_registries_devices_delete(
1064        &self,
1065        name: &str,
1066    ) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
1067        ProjectLocationRegistryDeviceDeleteCall {
1068            hub: self.hub,
1069            _name: name.to_string(),
1070            _delegate: Default::default(),
1071            _additional_params: Default::default(),
1072            _scopes: Default::default(),
1073        }
1074    }
1075
1076    /// Create a builder to help you perform the following task:
1077    ///
1078    /// Gets details about a device.
1079    ///
1080    /// # Arguments
1081    ///
1082    /// * `name` - Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1083    pub fn locations_registries_devices_get(
1084        &self,
1085        name: &str,
1086    ) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
1087        ProjectLocationRegistryDeviceGetCall {
1088            hub: self.hub,
1089            _name: name.to_string(),
1090            _field_mask: Default::default(),
1091            _delegate: Default::default(),
1092            _additional_params: Default::default(),
1093            _scopes: Default::default(),
1094        }
1095    }
1096
1097    /// Create a builder to help you perform the following task:
1098    ///
1099    /// List devices in a device registry.
1100    ///
1101    /// # Arguments
1102    ///
1103    /// * `parent` - Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
1104    pub fn locations_registries_devices_list(
1105        &self,
1106        parent: &str,
1107    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
1108        ProjectLocationRegistryDeviceListCall {
1109            hub: self.hub,
1110            _parent: parent.to_string(),
1111            _page_token: Default::default(),
1112            _page_size: Default::default(),
1113            _gateway_list_options_gateway_type: Default::default(),
1114            _gateway_list_options_associations_gateway_id: Default::default(),
1115            _gateway_list_options_associations_device_id: Default::default(),
1116            _field_mask: Default::default(),
1117            _device_num_ids: Default::default(),
1118            _device_ids: Default::default(),
1119            _delegate: Default::default(),
1120            _additional_params: Default::default(),
1121            _scopes: Default::default(),
1122        }
1123    }
1124
1125    /// Create a builder to help you perform the following task:
1126    ///
1127    /// Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.
1128    ///
1129    /// # Arguments
1130    ///
1131    /// * `request` - No description provided.
1132    /// * `name` - Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1133    pub fn locations_registries_devices_modify_cloud_to_device_config(
1134        &self,
1135        request: ModifyCloudToDeviceConfigRequest,
1136        name: &str,
1137    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
1138        ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall {
1139            hub: self.hub,
1140            _request: request,
1141            _name: name.to_string(),
1142            _delegate: Default::default(),
1143            _additional_params: Default::default(),
1144            _scopes: Default::default(),
1145        }
1146    }
1147
1148    /// Create a builder to help you perform the following task:
1149    ///
1150    /// Updates a device.
1151    ///
1152    /// # Arguments
1153    ///
1154    /// * `request` - No description provided.
1155    /// * `name` - The resource path name. For example, `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. When `name` is populated as a response from the service, it always ends in the device numeric ID.
1156    pub fn locations_registries_devices_patch(
1157        &self,
1158        request: Device,
1159        name: &str,
1160    ) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
1161        ProjectLocationRegistryDevicePatchCall {
1162            hub: self.hub,
1163            _request: request,
1164            _name: name.to_string(),
1165            _update_mask: Default::default(),
1166            _delegate: Default::default(),
1167            _additional_params: Default::default(),
1168            _scopes: Default::default(),
1169        }
1170    }
1171
1172    /// Create a builder to help you perform the following task:
1173    ///
1174    /// Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.
1175    ///
1176    /// # Arguments
1177    ///
1178    /// * `request` - No description provided.
1179    /// * `name` - Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1180    pub fn locations_registries_devices_send_command_to_device(
1181        &self,
1182        request: SendCommandToDeviceRequest,
1183        name: &str,
1184    ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
1185        ProjectLocationRegistryDeviceSendCommandToDeviceCall {
1186            hub: self.hub,
1187            _request: request,
1188            _name: name.to_string(),
1189            _delegate: Default::default(),
1190            _additional_params: Default::default(),
1191            _scopes: Default::default(),
1192        }
1193    }
1194
1195    /// Create a builder to help you perform the following task:
1196    ///
1197    /// List devices in a device registry.
1198    ///
1199    /// # Arguments
1200    ///
1201    /// * `parent` - Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
1202    pub fn locations_registries_groups_devices_list(
1203        &self,
1204        parent: &str,
1205    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
1206        ProjectLocationRegistryGroupDeviceListCall {
1207            hub: self.hub,
1208            _parent: parent.to_string(),
1209            _page_token: Default::default(),
1210            _page_size: Default::default(),
1211            _gateway_list_options_gateway_type: Default::default(),
1212            _gateway_list_options_associations_gateway_id: Default::default(),
1213            _gateway_list_options_associations_device_id: Default::default(),
1214            _field_mask: Default::default(),
1215            _device_num_ids: Default::default(),
1216            _device_ids: Default::default(),
1217            _delegate: Default::default(),
1218            _additional_params: Default::default(),
1219            _scopes: Default::default(),
1220        }
1221    }
1222
1223    /// Create a builder to help you perform the following task:
1224    ///
1225    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1226    ///
1227    /// # Arguments
1228    ///
1229    /// * `request` - No description provided.
1230    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1231    pub fn locations_registries_groups_get_iam_policy(
1232        &self,
1233        request: GetIamPolicyRequest,
1234        resource: &str,
1235    ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
1236        ProjectLocationRegistryGroupGetIamPolicyCall {
1237            hub: self.hub,
1238            _request: request,
1239            _resource: resource.to_string(),
1240            _delegate: Default::default(),
1241            _additional_params: Default::default(),
1242            _scopes: Default::default(),
1243        }
1244    }
1245
1246    /// Create a builder to help you perform the following task:
1247    ///
1248    /// Sets the access control policy on the specified resource. Replaces any existing policy.
1249    ///
1250    /// # Arguments
1251    ///
1252    /// * `request` - No description provided.
1253    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1254    pub fn locations_registries_groups_set_iam_policy(
1255        &self,
1256        request: SetIamPolicyRequest,
1257        resource: &str,
1258    ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
1259        ProjectLocationRegistryGroupSetIamPolicyCall {
1260            hub: self.hub,
1261            _request: request,
1262            _resource: resource.to_string(),
1263            _delegate: Default::default(),
1264            _additional_params: Default::default(),
1265            _scopes: Default::default(),
1266        }
1267    }
1268
1269    /// Create a builder to help you perform the following task:
1270    ///
1271    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
1272    ///
1273    /// # Arguments
1274    ///
1275    /// * `request` - No description provided.
1276    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1277    pub fn locations_registries_groups_test_iam_permissions(
1278        &self,
1279        request: TestIamPermissionsRequest,
1280        resource: &str,
1281    ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
1282        ProjectLocationRegistryGroupTestIamPermissionCall {
1283            hub: self.hub,
1284            _request: request,
1285            _resource: resource.to_string(),
1286            _delegate: Default::default(),
1287            _additional_params: Default::default(),
1288            _scopes: Default::default(),
1289        }
1290    }
1291
1292    /// Create a builder to help you perform the following task:
1293    ///
1294    /// Associates the device with the gateway.
1295    ///
1296    /// # Arguments
1297    ///
1298    /// * `request` - No description provided.
1299    /// * `parent` - Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1300    pub fn locations_registries_bind_device_to_gateway(
1301        &self,
1302        request: BindDeviceToGatewayRequest,
1303        parent: &str,
1304    ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
1305        ProjectLocationRegistryBindDeviceToGatewayCall {
1306            hub: self.hub,
1307            _request: request,
1308            _parent: parent.to_string(),
1309            _delegate: Default::default(),
1310            _additional_params: Default::default(),
1311            _scopes: Default::default(),
1312        }
1313    }
1314
1315    /// Create a builder to help you perform the following task:
1316    ///
1317    /// Creates a device registry that contains devices.
1318    ///
1319    /// # Arguments
1320    ///
1321    /// * `request` - No description provided.
1322    /// * `parent` - Required. The project and cloud region where this device registry must be created. For example, `projects/example-project/locations/us-central1`.
1323    pub fn locations_registries_create(
1324        &self,
1325        request: DeviceRegistry,
1326        parent: &str,
1327    ) -> ProjectLocationRegistryCreateCall<'a, C> {
1328        ProjectLocationRegistryCreateCall {
1329            hub: self.hub,
1330            _request: request,
1331            _parent: parent.to_string(),
1332            _delegate: Default::default(),
1333            _additional_params: Default::default(),
1334            _scopes: Default::default(),
1335        }
1336    }
1337
1338    /// Create a builder to help you perform the following task:
1339    ///
1340    /// Deletes a device registry configuration.
1341    ///
1342    /// # Arguments
1343    ///
1344    /// * `name` - Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1345    pub fn locations_registries_delete(
1346        &self,
1347        name: &str,
1348    ) -> ProjectLocationRegistryDeleteCall<'a, C> {
1349        ProjectLocationRegistryDeleteCall {
1350            hub: self.hub,
1351            _name: name.to_string(),
1352            _delegate: Default::default(),
1353            _additional_params: Default::default(),
1354            _scopes: Default::default(),
1355        }
1356    }
1357
1358    /// Create a builder to help you perform the following task:
1359    ///
1360    /// Gets a device registry configuration.
1361    ///
1362    /// # Arguments
1363    ///
1364    /// * `name` - Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1365    pub fn locations_registries_get(&self, name: &str) -> ProjectLocationRegistryGetCall<'a, C> {
1366        ProjectLocationRegistryGetCall {
1367            hub: self.hub,
1368            _name: name.to_string(),
1369            _delegate: Default::default(),
1370            _additional_params: Default::default(),
1371            _scopes: Default::default(),
1372        }
1373    }
1374
1375    /// Create a builder to help you perform the following task:
1376    ///
1377    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1378    ///
1379    /// # Arguments
1380    ///
1381    /// * `request` - No description provided.
1382    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1383    pub fn locations_registries_get_iam_policy(
1384        &self,
1385        request: GetIamPolicyRequest,
1386        resource: &str,
1387    ) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
1388        ProjectLocationRegistryGetIamPolicyCall {
1389            hub: self.hub,
1390            _request: request,
1391            _resource: resource.to_string(),
1392            _delegate: Default::default(),
1393            _additional_params: Default::default(),
1394            _scopes: Default::default(),
1395        }
1396    }
1397
1398    /// Create a builder to help you perform the following task:
1399    ///
1400    /// Lists device registries.
1401    ///
1402    /// # Arguments
1403    ///
1404    /// * `parent` - Required. The project and cloud region path. For example, `projects/example-project/locations/us-central1`.
1405    pub fn locations_registries_list(
1406        &self,
1407        parent: &str,
1408    ) -> ProjectLocationRegistryListCall<'a, C> {
1409        ProjectLocationRegistryListCall {
1410            hub: self.hub,
1411            _parent: parent.to_string(),
1412            _page_token: Default::default(),
1413            _page_size: Default::default(),
1414            _delegate: Default::default(),
1415            _additional_params: Default::default(),
1416            _scopes: Default::default(),
1417        }
1418    }
1419
1420    /// Create a builder to help you perform the following task:
1421    ///
1422    /// Updates a device registry configuration.
1423    ///
1424    /// # Arguments
1425    ///
1426    /// * `request` - No description provided.
1427    /// * `name` - The resource path name. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1428    pub fn locations_registries_patch(
1429        &self,
1430        request: DeviceRegistry,
1431        name: &str,
1432    ) -> ProjectLocationRegistryPatchCall<'a, C> {
1433        ProjectLocationRegistryPatchCall {
1434            hub: self.hub,
1435            _request: request,
1436            _name: name.to_string(),
1437            _update_mask: Default::default(),
1438            _delegate: Default::default(),
1439            _additional_params: Default::default(),
1440            _scopes: Default::default(),
1441        }
1442    }
1443
1444    /// Create a builder to help you perform the following task:
1445    ///
1446    /// Sets the access control policy on the specified resource. Replaces any existing policy.
1447    ///
1448    /// # Arguments
1449    ///
1450    /// * `request` - No description provided.
1451    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1452    pub fn locations_registries_set_iam_policy(
1453        &self,
1454        request: SetIamPolicyRequest,
1455        resource: &str,
1456    ) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
1457        ProjectLocationRegistrySetIamPolicyCall {
1458            hub: self.hub,
1459            _request: request,
1460            _resource: resource.to_string(),
1461            _delegate: Default::default(),
1462            _additional_params: Default::default(),
1463            _scopes: Default::default(),
1464        }
1465    }
1466
1467    /// Create a builder to help you perform the following task:
1468    ///
1469    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
1470    ///
1471    /// # Arguments
1472    ///
1473    /// * `request` - No description provided.
1474    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1475    pub fn locations_registries_test_iam_permissions(
1476        &self,
1477        request: TestIamPermissionsRequest,
1478        resource: &str,
1479    ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
1480        ProjectLocationRegistryTestIamPermissionCall {
1481            hub: self.hub,
1482            _request: request,
1483            _resource: resource.to_string(),
1484            _delegate: Default::default(),
1485            _additional_params: Default::default(),
1486            _scopes: Default::default(),
1487        }
1488    }
1489
1490    /// Create a builder to help you perform the following task:
1491    ///
1492    /// Deletes the association between the device and the gateway.
1493    ///
1494    /// # Arguments
1495    ///
1496    /// * `request` - No description provided.
1497    /// * `parent` - Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1498    pub fn locations_registries_unbind_device_from_gateway(
1499        &self,
1500        request: UnbindDeviceFromGatewayRequest,
1501        parent: &str,
1502    ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
1503        ProjectLocationRegistryUnbindDeviceFromGatewayCall {
1504            hub: self.hub,
1505            _request: request,
1506            _parent: parent.to_string(),
1507            _delegate: Default::default(),
1508            _additional_params: Default::default(),
1509            _scopes: Default::default(),
1510        }
1511    }
1512}
1513
1514// ###################
1515// CallBuilders   ###
1516// #################
1517
1518/// Lists the last few versions of the device configuration in descending order (i.e.: newest first).
1519///
1520/// A builder for the *locations.registries.devices.configVersions.list* method supported by a *project* resource.
1521/// It is not used directly, but through a [`ProjectMethods`] instance.
1522///
1523/// # Example
1524///
1525/// Instantiate a resource method builder
1526///
1527/// ```test_harness,no_run
1528/// # extern crate hyper;
1529/// # extern crate hyper_rustls;
1530/// # extern crate google_cloudiot1 as cloudiot1;
1531/// # async fn dox() {
1532/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1533///
1534/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1535/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1536/// #     .with_native_roots()
1537/// #     .unwrap()
1538/// #     .https_only()
1539/// #     .enable_http2()
1540/// #     .build();
1541///
1542/// # let executor = hyper_util::rt::TokioExecutor::new();
1543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1544/// #     secret,
1545/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1546/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1547/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1548/// #     ),
1549/// # ).build().await.unwrap();
1550///
1551/// # let client = hyper_util::client::legacy::Client::builder(
1552/// #     hyper_util::rt::TokioExecutor::new()
1553/// # )
1554/// # .build(
1555/// #     hyper_rustls::HttpsConnectorBuilder::new()
1556/// #         .with_native_roots()
1557/// #         .unwrap()
1558/// #         .https_or_http()
1559/// #         .enable_http2()
1560/// #         .build()
1561/// # );
1562/// # let mut hub = CloudIot::new(client, auth);
1563/// // You can configure optional parameters by calling the respective setters at will, and
1564/// // execute the final call using `doit()`.
1565/// // Values shown here are possibly random and not representative !
1566/// let result = hub.projects().locations_registries_devices_config_versions_list("name")
1567///              .num_versions(-28)
1568///              .doit().await;
1569/// # }
1570/// ```
1571pub struct ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1572where
1573    C: 'a,
1574{
1575    hub: &'a CloudIot<C>,
1576    _name: String,
1577    _num_versions: Option<i32>,
1578    _delegate: Option<&'a mut dyn common::Delegate>,
1579    _additional_params: HashMap<String, String>,
1580    _scopes: BTreeSet<String>,
1581}
1582
1583impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {}
1584
1585impl<'a, C> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1586where
1587    C: common::Connector,
1588{
1589    /// Perform the operation you have build so far.
1590    pub async fn doit(
1591        mut self,
1592    ) -> common::Result<(common::Response, ListDeviceConfigVersionsResponse)> {
1593        use std::borrow::Cow;
1594        use std::io::{Read, Seek};
1595
1596        use common::{url::Params, ToParts};
1597        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1598
1599        let mut dd = common::DefaultDelegate;
1600        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1601        dlg.begin(common::MethodInfo {
1602            id: "cloudiot.projects.locations.registries.devices.configVersions.list",
1603            http_method: hyper::Method::GET,
1604        });
1605
1606        for &field in ["alt", "name", "numVersions"].iter() {
1607            if self._additional_params.contains_key(field) {
1608                dlg.finished(false);
1609                return Err(common::Error::FieldClash(field));
1610            }
1611        }
1612
1613        let mut params = Params::with_capacity(4 + self._additional_params.len());
1614        params.push("name", self._name);
1615        if let Some(value) = self._num_versions.as_ref() {
1616            params.push("numVersions", value.to_string());
1617        }
1618
1619        params.extend(self._additional_params.iter());
1620
1621        params.push("alt", "json");
1622        let mut url = self.hub._base_url.clone() + "v1/{+name}/configVersions";
1623        if self._scopes.is_empty() {
1624            self._scopes
1625                .insert(Scope::CloudPlatform.as_ref().to_string());
1626        }
1627
1628        #[allow(clippy::single_element_loop)]
1629        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1630            url = params.uri_replacement(url, param_name, find_this, true);
1631        }
1632        {
1633            let to_remove = ["name"];
1634            params.remove_params(&to_remove);
1635        }
1636
1637        let url = params.parse_with_url(&url);
1638
1639        loop {
1640            let token = match self
1641                .hub
1642                .auth
1643                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1644                .await
1645            {
1646                Ok(token) => token,
1647                Err(e) => match dlg.token(e) {
1648                    Ok(token) => token,
1649                    Err(e) => {
1650                        dlg.finished(false);
1651                        return Err(common::Error::MissingToken(e));
1652                    }
1653                },
1654            };
1655            let mut req_result = {
1656                let client = &self.hub.client;
1657                dlg.pre_request();
1658                let mut req_builder = hyper::Request::builder()
1659                    .method(hyper::Method::GET)
1660                    .uri(url.as_str())
1661                    .header(USER_AGENT, self.hub._user_agent.clone());
1662
1663                if let Some(token) = token.as_ref() {
1664                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1665                }
1666
1667                let request = req_builder
1668                    .header(CONTENT_LENGTH, 0_u64)
1669                    .body(common::to_body::<String>(None));
1670
1671                client.request(request.unwrap()).await
1672            };
1673
1674            match req_result {
1675                Err(err) => {
1676                    if let common::Retry::After(d) = dlg.http_error(&err) {
1677                        sleep(d).await;
1678                        continue;
1679                    }
1680                    dlg.finished(false);
1681                    return Err(common::Error::HttpError(err));
1682                }
1683                Ok(res) => {
1684                    let (mut parts, body) = res.into_parts();
1685                    let mut body = common::Body::new(body);
1686                    if !parts.status.is_success() {
1687                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1688                        let error = serde_json::from_str(&common::to_string(&bytes));
1689                        let response = common::to_response(parts, bytes.into());
1690
1691                        if let common::Retry::After(d) =
1692                            dlg.http_failure(&response, error.as_ref().ok())
1693                        {
1694                            sleep(d).await;
1695                            continue;
1696                        }
1697
1698                        dlg.finished(false);
1699
1700                        return Err(match error {
1701                            Ok(value) => common::Error::BadRequest(value),
1702                            _ => common::Error::Failure(response),
1703                        });
1704                    }
1705                    let response = {
1706                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1707                        let encoded = common::to_string(&bytes);
1708                        match serde_json::from_str(&encoded) {
1709                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1710                            Err(error) => {
1711                                dlg.response_json_decode_error(&encoded, &error);
1712                                return Err(common::Error::JsonDecodeError(
1713                                    encoded.to_string(),
1714                                    error,
1715                                ));
1716                            }
1717                        }
1718                    };
1719
1720                    dlg.finished(true);
1721                    return Ok(response);
1722                }
1723            }
1724        }
1725    }
1726
1727    /// Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1728    ///
1729    /// Sets the *name* path property to the given value.
1730    ///
1731    /// Even though the property as already been set when instantiating this call,
1732    /// we provide this method for API completeness.
1733    pub fn name(
1734        mut self,
1735        new_value: &str,
1736    ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1737        self._name = new_value.to_string();
1738        self
1739    }
1740    /// The number of versions to list. Versions are listed in decreasing order of the version number. The maximum number of versions retained is 10. If this value is zero, it will return all the versions available.
1741    ///
1742    /// Sets the *num versions* query property to the given value.
1743    pub fn num_versions(
1744        mut self,
1745        new_value: i32,
1746    ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1747        self._num_versions = Some(new_value);
1748        self
1749    }
1750    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1751    /// while executing the actual API request.
1752    ///
1753    /// ````text
1754    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1755    /// ````
1756    ///
1757    /// Sets the *delegate* property to the given value.
1758    pub fn delegate(
1759        mut self,
1760        new_value: &'a mut dyn common::Delegate,
1761    ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1762        self._delegate = Some(new_value);
1763        self
1764    }
1765
1766    /// Set any additional parameter of the query string used in the request.
1767    /// It should be used to set parameters which are not yet available through their own
1768    /// setters.
1769    ///
1770    /// Please note that this method must not be used to set any of the known parameters
1771    /// which have their own setter method. If done anyway, the request will fail.
1772    ///
1773    /// # Additional Parameters
1774    ///
1775    /// * *$.xgafv* (query-string) - V1 error format.
1776    /// * *access_token* (query-string) - OAuth access token.
1777    /// * *alt* (query-string) - Data format for response.
1778    /// * *callback* (query-string) - JSONP
1779    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1780    /// * *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.
1781    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1782    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1783    /// * *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.
1784    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1785    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1786    pub fn param<T>(
1787        mut self,
1788        name: T,
1789        value: T,
1790    ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1791    where
1792        T: AsRef<str>,
1793    {
1794        self._additional_params
1795            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1796        self
1797    }
1798
1799    /// Identifies the authorization scope for the method you are building.
1800    ///
1801    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1802    /// [`Scope::CloudPlatform`].
1803    ///
1804    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1805    /// tokens for more than one scope.
1806    ///
1807    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1808    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1809    /// sufficient, a read-write scope will do as well.
1810    pub fn add_scope<St>(
1811        mut self,
1812        scope: St,
1813    ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1814    where
1815        St: AsRef<str>,
1816    {
1817        self._scopes.insert(String::from(scope.as_ref()));
1818        self
1819    }
1820    /// Identifies the authorization scope(s) for the method you are building.
1821    ///
1822    /// See [`Self::add_scope()`] for details.
1823    pub fn add_scopes<I, St>(
1824        mut self,
1825        scopes: I,
1826    ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1827    where
1828        I: IntoIterator<Item = St>,
1829        St: AsRef<str>,
1830    {
1831        self._scopes
1832            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1833        self
1834    }
1835
1836    /// Removes all scopes, and no default scope will be used either.
1837    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1838    /// for details).
1839    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1840        self._scopes.clear();
1841        self
1842    }
1843}
1844
1845/// Lists the last few versions of the device state in descending order (i.e.: newest first).
1846///
1847/// A builder for the *locations.registries.devices.states.list* method supported by a *project* resource.
1848/// It is not used directly, but through a [`ProjectMethods`] instance.
1849///
1850/// # Example
1851///
1852/// Instantiate a resource method builder
1853///
1854/// ```test_harness,no_run
1855/// # extern crate hyper;
1856/// # extern crate hyper_rustls;
1857/// # extern crate google_cloudiot1 as cloudiot1;
1858/// # async fn dox() {
1859/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1860///
1861/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1862/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1863/// #     .with_native_roots()
1864/// #     .unwrap()
1865/// #     .https_only()
1866/// #     .enable_http2()
1867/// #     .build();
1868///
1869/// # let executor = hyper_util::rt::TokioExecutor::new();
1870/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1871/// #     secret,
1872/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1873/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1874/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1875/// #     ),
1876/// # ).build().await.unwrap();
1877///
1878/// # let client = hyper_util::client::legacy::Client::builder(
1879/// #     hyper_util::rt::TokioExecutor::new()
1880/// # )
1881/// # .build(
1882/// #     hyper_rustls::HttpsConnectorBuilder::new()
1883/// #         .with_native_roots()
1884/// #         .unwrap()
1885/// #         .https_or_http()
1886/// #         .enable_http2()
1887/// #         .build()
1888/// # );
1889/// # let mut hub = CloudIot::new(client, auth);
1890/// // You can configure optional parameters by calling the respective setters at will, and
1891/// // execute the final call using `doit()`.
1892/// // Values shown here are possibly random and not representative !
1893/// let result = hub.projects().locations_registries_devices_states_list("name")
1894///              .num_states(-8)
1895///              .doit().await;
1896/// # }
1897/// ```
1898pub struct ProjectLocationRegistryDeviceStateListCall<'a, C>
1899where
1900    C: 'a,
1901{
1902    hub: &'a CloudIot<C>,
1903    _name: String,
1904    _num_states: Option<i32>,
1905    _delegate: Option<&'a mut dyn common::Delegate>,
1906    _additional_params: HashMap<String, String>,
1907    _scopes: BTreeSet<String>,
1908}
1909
1910impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceStateListCall<'a, C> {}
1911
1912impl<'a, C> ProjectLocationRegistryDeviceStateListCall<'a, C>
1913where
1914    C: common::Connector,
1915{
1916    /// Perform the operation you have build so far.
1917    pub async fn doit(mut self) -> common::Result<(common::Response, ListDeviceStatesResponse)> {
1918        use std::borrow::Cow;
1919        use std::io::{Read, Seek};
1920
1921        use common::{url::Params, ToParts};
1922        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1923
1924        let mut dd = common::DefaultDelegate;
1925        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1926        dlg.begin(common::MethodInfo {
1927            id: "cloudiot.projects.locations.registries.devices.states.list",
1928            http_method: hyper::Method::GET,
1929        });
1930
1931        for &field in ["alt", "name", "numStates"].iter() {
1932            if self._additional_params.contains_key(field) {
1933                dlg.finished(false);
1934                return Err(common::Error::FieldClash(field));
1935            }
1936        }
1937
1938        let mut params = Params::with_capacity(4 + self._additional_params.len());
1939        params.push("name", self._name);
1940        if let Some(value) = self._num_states.as_ref() {
1941            params.push("numStates", value.to_string());
1942        }
1943
1944        params.extend(self._additional_params.iter());
1945
1946        params.push("alt", "json");
1947        let mut url = self.hub._base_url.clone() + "v1/{+name}/states";
1948        if self._scopes.is_empty() {
1949            self._scopes
1950                .insert(Scope::CloudPlatform.as_ref().to_string());
1951        }
1952
1953        #[allow(clippy::single_element_loop)]
1954        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1955            url = params.uri_replacement(url, param_name, find_this, true);
1956        }
1957        {
1958            let to_remove = ["name"];
1959            params.remove_params(&to_remove);
1960        }
1961
1962        let url = params.parse_with_url(&url);
1963
1964        loop {
1965            let token = match self
1966                .hub
1967                .auth
1968                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1969                .await
1970            {
1971                Ok(token) => token,
1972                Err(e) => match dlg.token(e) {
1973                    Ok(token) => token,
1974                    Err(e) => {
1975                        dlg.finished(false);
1976                        return Err(common::Error::MissingToken(e));
1977                    }
1978                },
1979            };
1980            let mut req_result = {
1981                let client = &self.hub.client;
1982                dlg.pre_request();
1983                let mut req_builder = hyper::Request::builder()
1984                    .method(hyper::Method::GET)
1985                    .uri(url.as_str())
1986                    .header(USER_AGENT, self.hub._user_agent.clone());
1987
1988                if let Some(token) = token.as_ref() {
1989                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1990                }
1991
1992                let request = req_builder
1993                    .header(CONTENT_LENGTH, 0_u64)
1994                    .body(common::to_body::<String>(None));
1995
1996                client.request(request.unwrap()).await
1997            };
1998
1999            match req_result {
2000                Err(err) => {
2001                    if let common::Retry::After(d) = dlg.http_error(&err) {
2002                        sleep(d).await;
2003                        continue;
2004                    }
2005                    dlg.finished(false);
2006                    return Err(common::Error::HttpError(err));
2007                }
2008                Ok(res) => {
2009                    let (mut parts, body) = res.into_parts();
2010                    let mut body = common::Body::new(body);
2011                    if !parts.status.is_success() {
2012                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2013                        let error = serde_json::from_str(&common::to_string(&bytes));
2014                        let response = common::to_response(parts, bytes.into());
2015
2016                        if let common::Retry::After(d) =
2017                            dlg.http_failure(&response, error.as_ref().ok())
2018                        {
2019                            sleep(d).await;
2020                            continue;
2021                        }
2022
2023                        dlg.finished(false);
2024
2025                        return Err(match error {
2026                            Ok(value) => common::Error::BadRequest(value),
2027                            _ => common::Error::Failure(response),
2028                        });
2029                    }
2030                    let response = {
2031                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2032                        let encoded = common::to_string(&bytes);
2033                        match serde_json::from_str(&encoded) {
2034                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2035                            Err(error) => {
2036                                dlg.response_json_decode_error(&encoded, &error);
2037                                return Err(common::Error::JsonDecodeError(
2038                                    encoded.to_string(),
2039                                    error,
2040                                ));
2041                            }
2042                        }
2043                    };
2044
2045                    dlg.finished(true);
2046                    return Ok(response);
2047                }
2048            }
2049        }
2050    }
2051
2052    /// Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
2053    ///
2054    /// Sets the *name* path property to the given value.
2055    ///
2056    /// Even though the property as already been set when instantiating this call,
2057    /// we provide this method for API completeness.
2058    pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2059        self._name = new_value.to_string();
2060        self
2061    }
2062    /// The number of states to list. States are listed in descending order of update time. The maximum number of states retained is 10. If this value is zero, it will return all the states available.
2063    ///
2064    /// Sets the *num states* query property to the given value.
2065    pub fn num_states(
2066        mut self,
2067        new_value: i32,
2068    ) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2069        self._num_states = Some(new_value);
2070        self
2071    }
2072    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2073    /// while executing the actual API request.
2074    ///
2075    /// ````text
2076    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2077    /// ````
2078    ///
2079    /// Sets the *delegate* property to the given value.
2080    pub fn delegate(
2081        mut self,
2082        new_value: &'a mut dyn common::Delegate,
2083    ) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2084        self._delegate = Some(new_value);
2085        self
2086    }
2087
2088    /// Set any additional parameter of the query string used in the request.
2089    /// It should be used to set parameters which are not yet available through their own
2090    /// setters.
2091    ///
2092    /// Please note that this method must not be used to set any of the known parameters
2093    /// which have their own setter method. If done anyway, the request will fail.
2094    ///
2095    /// # Additional Parameters
2096    ///
2097    /// * *$.xgafv* (query-string) - V1 error format.
2098    /// * *access_token* (query-string) - OAuth access token.
2099    /// * *alt* (query-string) - Data format for response.
2100    /// * *callback* (query-string) - JSONP
2101    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2102    /// * *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.
2103    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2104    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2105    /// * *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.
2106    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2107    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2108    pub fn param<T>(
2109        mut self,
2110        name: T,
2111        value: T,
2112    ) -> ProjectLocationRegistryDeviceStateListCall<'a, C>
2113    where
2114        T: AsRef<str>,
2115    {
2116        self._additional_params
2117            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2118        self
2119    }
2120
2121    /// Identifies the authorization scope for the method you are building.
2122    ///
2123    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2124    /// [`Scope::CloudPlatform`].
2125    ///
2126    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2127    /// tokens for more than one scope.
2128    ///
2129    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2130    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2131    /// sufficient, a read-write scope will do as well.
2132    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceStateListCall<'a, C>
2133    where
2134        St: AsRef<str>,
2135    {
2136        self._scopes.insert(String::from(scope.as_ref()));
2137        self
2138    }
2139    /// Identifies the authorization scope(s) for the method you are building.
2140    ///
2141    /// See [`Self::add_scope()`] for details.
2142    pub fn add_scopes<I, St>(
2143        mut self,
2144        scopes: I,
2145    ) -> ProjectLocationRegistryDeviceStateListCall<'a, C>
2146    where
2147        I: IntoIterator<Item = St>,
2148        St: AsRef<str>,
2149    {
2150        self._scopes
2151            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2152        self
2153    }
2154
2155    /// Removes all scopes, and no default scope will be used either.
2156    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2157    /// for details).
2158    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2159        self._scopes.clear();
2160        self
2161    }
2162}
2163
2164/// Creates a device in a device registry.
2165///
2166/// A builder for the *locations.registries.devices.create* method supported by a *project* resource.
2167/// It is not used directly, but through a [`ProjectMethods`] instance.
2168///
2169/// # Example
2170///
2171/// Instantiate a resource method builder
2172///
2173/// ```test_harness,no_run
2174/// # extern crate hyper;
2175/// # extern crate hyper_rustls;
2176/// # extern crate google_cloudiot1 as cloudiot1;
2177/// use cloudiot1::api::Device;
2178/// # async fn dox() {
2179/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2180///
2181/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2182/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2183/// #     .with_native_roots()
2184/// #     .unwrap()
2185/// #     .https_only()
2186/// #     .enable_http2()
2187/// #     .build();
2188///
2189/// # let executor = hyper_util::rt::TokioExecutor::new();
2190/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2191/// #     secret,
2192/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2193/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2194/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2195/// #     ),
2196/// # ).build().await.unwrap();
2197///
2198/// # let client = hyper_util::client::legacy::Client::builder(
2199/// #     hyper_util::rt::TokioExecutor::new()
2200/// # )
2201/// # .build(
2202/// #     hyper_rustls::HttpsConnectorBuilder::new()
2203/// #         .with_native_roots()
2204/// #         .unwrap()
2205/// #         .https_or_http()
2206/// #         .enable_http2()
2207/// #         .build()
2208/// # );
2209/// # let mut hub = CloudIot::new(client, auth);
2210/// // As the method needs a request, you would usually fill it with the desired information
2211/// // into the respective structure. Some of the parts shown here might not be applicable !
2212/// // Values shown here are possibly random and not representative !
2213/// let mut req = Device::default();
2214///
2215/// // You can configure optional parameters by calling the respective setters at will, and
2216/// // execute the final call using `doit()`.
2217/// // Values shown here are possibly random and not representative !
2218/// let result = hub.projects().locations_registries_devices_create(req, "parent")
2219///              .doit().await;
2220/// # }
2221/// ```
2222pub struct ProjectLocationRegistryDeviceCreateCall<'a, C>
2223where
2224    C: 'a,
2225{
2226    hub: &'a CloudIot<C>,
2227    _request: Device,
2228    _parent: String,
2229    _delegate: Option<&'a mut dyn common::Delegate>,
2230    _additional_params: HashMap<String, String>,
2231    _scopes: BTreeSet<String>,
2232}
2233
2234impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceCreateCall<'a, C> {}
2235
2236impl<'a, C> ProjectLocationRegistryDeviceCreateCall<'a, C>
2237where
2238    C: common::Connector,
2239{
2240    /// Perform the operation you have build so far.
2241    pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
2242        use std::borrow::Cow;
2243        use std::io::{Read, Seek};
2244
2245        use common::{url::Params, ToParts};
2246        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2247
2248        let mut dd = common::DefaultDelegate;
2249        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2250        dlg.begin(common::MethodInfo {
2251            id: "cloudiot.projects.locations.registries.devices.create",
2252            http_method: hyper::Method::POST,
2253        });
2254
2255        for &field in ["alt", "parent"].iter() {
2256            if self._additional_params.contains_key(field) {
2257                dlg.finished(false);
2258                return Err(common::Error::FieldClash(field));
2259            }
2260        }
2261
2262        let mut params = Params::with_capacity(4 + self._additional_params.len());
2263        params.push("parent", self._parent);
2264
2265        params.extend(self._additional_params.iter());
2266
2267        params.push("alt", "json");
2268        let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
2269        if self._scopes.is_empty() {
2270            self._scopes
2271                .insert(Scope::CloudPlatform.as_ref().to_string());
2272        }
2273
2274        #[allow(clippy::single_element_loop)]
2275        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2276            url = params.uri_replacement(url, param_name, find_this, true);
2277        }
2278        {
2279            let to_remove = ["parent"];
2280            params.remove_params(&to_remove);
2281        }
2282
2283        let url = params.parse_with_url(&url);
2284
2285        let mut json_mime_type = mime::APPLICATION_JSON;
2286        let mut request_value_reader = {
2287            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2288            common::remove_json_null_values(&mut value);
2289            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2290            serde_json::to_writer(&mut dst, &value).unwrap();
2291            dst
2292        };
2293        let request_size = request_value_reader
2294            .seek(std::io::SeekFrom::End(0))
2295            .unwrap();
2296        request_value_reader
2297            .seek(std::io::SeekFrom::Start(0))
2298            .unwrap();
2299
2300        loop {
2301            let token = match self
2302                .hub
2303                .auth
2304                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2305                .await
2306            {
2307                Ok(token) => token,
2308                Err(e) => match dlg.token(e) {
2309                    Ok(token) => token,
2310                    Err(e) => {
2311                        dlg.finished(false);
2312                        return Err(common::Error::MissingToken(e));
2313                    }
2314                },
2315            };
2316            request_value_reader
2317                .seek(std::io::SeekFrom::Start(0))
2318                .unwrap();
2319            let mut req_result = {
2320                let client = &self.hub.client;
2321                dlg.pre_request();
2322                let mut req_builder = hyper::Request::builder()
2323                    .method(hyper::Method::POST)
2324                    .uri(url.as_str())
2325                    .header(USER_AGENT, self.hub._user_agent.clone());
2326
2327                if let Some(token) = token.as_ref() {
2328                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2329                }
2330
2331                let request = req_builder
2332                    .header(CONTENT_TYPE, json_mime_type.to_string())
2333                    .header(CONTENT_LENGTH, request_size as u64)
2334                    .body(common::to_body(
2335                        request_value_reader.get_ref().clone().into(),
2336                    ));
2337
2338                client.request(request.unwrap()).await
2339            };
2340
2341            match req_result {
2342                Err(err) => {
2343                    if let common::Retry::After(d) = dlg.http_error(&err) {
2344                        sleep(d).await;
2345                        continue;
2346                    }
2347                    dlg.finished(false);
2348                    return Err(common::Error::HttpError(err));
2349                }
2350                Ok(res) => {
2351                    let (mut parts, body) = res.into_parts();
2352                    let mut body = common::Body::new(body);
2353                    if !parts.status.is_success() {
2354                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2355                        let error = serde_json::from_str(&common::to_string(&bytes));
2356                        let response = common::to_response(parts, bytes.into());
2357
2358                        if let common::Retry::After(d) =
2359                            dlg.http_failure(&response, error.as_ref().ok())
2360                        {
2361                            sleep(d).await;
2362                            continue;
2363                        }
2364
2365                        dlg.finished(false);
2366
2367                        return Err(match error {
2368                            Ok(value) => common::Error::BadRequest(value),
2369                            _ => common::Error::Failure(response),
2370                        });
2371                    }
2372                    let response = {
2373                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2374                        let encoded = common::to_string(&bytes);
2375                        match serde_json::from_str(&encoded) {
2376                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2377                            Err(error) => {
2378                                dlg.response_json_decode_error(&encoded, &error);
2379                                return Err(common::Error::JsonDecodeError(
2380                                    encoded.to_string(),
2381                                    error,
2382                                ));
2383                            }
2384                        }
2385                    };
2386
2387                    dlg.finished(true);
2388                    return Ok(response);
2389                }
2390            }
2391        }
2392    }
2393
2394    ///
2395    /// Sets the *request* property to the given value.
2396    ///
2397    /// Even though the property as already been set when instantiating this call,
2398    /// we provide this method for API completeness.
2399    pub fn request(mut self, new_value: Device) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2400        self._request = new_value;
2401        self
2402    }
2403    /// Required. The name of the device registry where this device should be created. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
2404    ///
2405    /// Sets the *parent* path property to the given value.
2406    ///
2407    /// Even though the property as already been set when instantiating this call,
2408    /// we provide this method for API completeness.
2409    pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2410        self._parent = new_value.to_string();
2411        self
2412    }
2413    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2414    /// while executing the actual API request.
2415    ///
2416    /// ````text
2417    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2418    /// ````
2419    ///
2420    /// Sets the *delegate* property to the given value.
2421    pub fn delegate(
2422        mut self,
2423        new_value: &'a mut dyn common::Delegate,
2424    ) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2425        self._delegate = Some(new_value);
2426        self
2427    }
2428
2429    /// Set any additional parameter of the query string used in the request.
2430    /// It should be used to set parameters which are not yet available through their own
2431    /// setters.
2432    ///
2433    /// Please note that this method must not be used to set any of the known parameters
2434    /// which have their own setter method. If done anyway, the request will fail.
2435    ///
2436    /// # Additional Parameters
2437    ///
2438    /// * *$.xgafv* (query-string) - V1 error format.
2439    /// * *access_token* (query-string) - OAuth access token.
2440    /// * *alt* (query-string) - Data format for response.
2441    /// * *callback* (query-string) - JSONP
2442    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2443    /// * *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.
2444    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2445    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2446    /// * *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.
2447    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2448    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2449    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceCreateCall<'a, C>
2450    where
2451        T: AsRef<str>,
2452    {
2453        self._additional_params
2454            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2455        self
2456    }
2457
2458    /// Identifies the authorization scope for the method you are building.
2459    ///
2460    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2461    /// [`Scope::CloudPlatform`].
2462    ///
2463    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2464    /// tokens for more than one scope.
2465    ///
2466    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2467    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2468    /// sufficient, a read-write scope will do as well.
2469    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceCreateCall<'a, C>
2470    where
2471        St: AsRef<str>,
2472    {
2473        self._scopes.insert(String::from(scope.as_ref()));
2474        self
2475    }
2476    /// Identifies the authorization scope(s) for the method you are building.
2477    ///
2478    /// See [`Self::add_scope()`] for details.
2479    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceCreateCall<'a, C>
2480    where
2481        I: IntoIterator<Item = St>,
2482        St: AsRef<str>,
2483    {
2484        self._scopes
2485            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2486        self
2487    }
2488
2489    /// Removes all scopes, and no default scope will be used either.
2490    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2491    /// for details).
2492    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2493        self._scopes.clear();
2494        self
2495    }
2496}
2497
2498/// Deletes a device.
2499///
2500/// A builder for the *locations.registries.devices.delete* method supported by a *project* resource.
2501/// It is not used directly, but through a [`ProjectMethods`] instance.
2502///
2503/// # Example
2504///
2505/// Instantiate a resource method builder
2506///
2507/// ```test_harness,no_run
2508/// # extern crate hyper;
2509/// # extern crate hyper_rustls;
2510/// # extern crate google_cloudiot1 as cloudiot1;
2511/// # async fn dox() {
2512/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2513///
2514/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2515/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2516/// #     .with_native_roots()
2517/// #     .unwrap()
2518/// #     .https_only()
2519/// #     .enable_http2()
2520/// #     .build();
2521///
2522/// # let executor = hyper_util::rt::TokioExecutor::new();
2523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2524/// #     secret,
2525/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2526/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2527/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2528/// #     ),
2529/// # ).build().await.unwrap();
2530///
2531/// # let client = hyper_util::client::legacy::Client::builder(
2532/// #     hyper_util::rt::TokioExecutor::new()
2533/// # )
2534/// # .build(
2535/// #     hyper_rustls::HttpsConnectorBuilder::new()
2536/// #         .with_native_roots()
2537/// #         .unwrap()
2538/// #         .https_or_http()
2539/// #         .enable_http2()
2540/// #         .build()
2541/// # );
2542/// # let mut hub = CloudIot::new(client, auth);
2543/// // You can configure optional parameters by calling the respective setters at will, and
2544/// // execute the final call using `doit()`.
2545/// // Values shown here are possibly random and not representative !
2546/// let result = hub.projects().locations_registries_devices_delete("name")
2547///              .doit().await;
2548/// # }
2549/// ```
2550pub struct ProjectLocationRegistryDeviceDeleteCall<'a, C>
2551where
2552    C: 'a,
2553{
2554    hub: &'a CloudIot<C>,
2555    _name: String,
2556    _delegate: Option<&'a mut dyn common::Delegate>,
2557    _additional_params: HashMap<String, String>,
2558    _scopes: BTreeSet<String>,
2559}
2560
2561impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceDeleteCall<'a, C> {}
2562
2563impl<'a, C> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2564where
2565    C: common::Connector,
2566{
2567    /// Perform the operation you have build so far.
2568    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2569        use std::borrow::Cow;
2570        use std::io::{Read, Seek};
2571
2572        use common::{url::Params, ToParts};
2573        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2574
2575        let mut dd = common::DefaultDelegate;
2576        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2577        dlg.begin(common::MethodInfo {
2578            id: "cloudiot.projects.locations.registries.devices.delete",
2579            http_method: hyper::Method::DELETE,
2580        });
2581
2582        for &field in ["alt", "name"].iter() {
2583            if self._additional_params.contains_key(field) {
2584                dlg.finished(false);
2585                return Err(common::Error::FieldClash(field));
2586            }
2587        }
2588
2589        let mut params = Params::with_capacity(3 + self._additional_params.len());
2590        params.push("name", self._name);
2591
2592        params.extend(self._additional_params.iter());
2593
2594        params.push("alt", "json");
2595        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2596        if self._scopes.is_empty() {
2597            self._scopes
2598                .insert(Scope::CloudPlatform.as_ref().to_string());
2599        }
2600
2601        #[allow(clippy::single_element_loop)]
2602        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2603            url = params.uri_replacement(url, param_name, find_this, true);
2604        }
2605        {
2606            let to_remove = ["name"];
2607            params.remove_params(&to_remove);
2608        }
2609
2610        let url = params.parse_with_url(&url);
2611
2612        loop {
2613            let token = match self
2614                .hub
2615                .auth
2616                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2617                .await
2618            {
2619                Ok(token) => token,
2620                Err(e) => match dlg.token(e) {
2621                    Ok(token) => token,
2622                    Err(e) => {
2623                        dlg.finished(false);
2624                        return Err(common::Error::MissingToken(e));
2625                    }
2626                },
2627            };
2628            let mut req_result = {
2629                let client = &self.hub.client;
2630                dlg.pre_request();
2631                let mut req_builder = hyper::Request::builder()
2632                    .method(hyper::Method::DELETE)
2633                    .uri(url.as_str())
2634                    .header(USER_AGENT, self.hub._user_agent.clone());
2635
2636                if let Some(token) = token.as_ref() {
2637                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2638                }
2639
2640                let request = req_builder
2641                    .header(CONTENT_LENGTH, 0_u64)
2642                    .body(common::to_body::<String>(None));
2643
2644                client.request(request.unwrap()).await
2645            };
2646
2647            match req_result {
2648                Err(err) => {
2649                    if let common::Retry::After(d) = dlg.http_error(&err) {
2650                        sleep(d).await;
2651                        continue;
2652                    }
2653                    dlg.finished(false);
2654                    return Err(common::Error::HttpError(err));
2655                }
2656                Ok(res) => {
2657                    let (mut parts, body) = res.into_parts();
2658                    let mut body = common::Body::new(body);
2659                    if !parts.status.is_success() {
2660                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2661                        let error = serde_json::from_str(&common::to_string(&bytes));
2662                        let response = common::to_response(parts, bytes.into());
2663
2664                        if let common::Retry::After(d) =
2665                            dlg.http_failure(&response, error.as_ref().ok())
2666                        {
2667                            sleep(d).await;
2668                            continue;
2669                        }
2670
2671                        dlg.finished(false);
2672
2673                        return Err(match error {
2674                            Ok(value) => common::Error::BadRequest(value),
2675                            _ => common::Error::Failure(response),
2676                        });
2677                    }
2678                    let response = {
2679                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2680                        let encoded = common::to_string(&bytes);
2681                        match serde_json::from_str(&encoded) {
2682                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2683                            Err(error) => {
2684                                dlg.response_json_decode_error(&encoded, &error);
2685                                return Err(common::Error::JsonDecodeError(
2686                                    encoded.to_string(),
2687                                    error,
2688                                ));
2689                            }
2690                        }
2691                    };
2692
2693                    dlg.finished(true);
2694                    return Ok(response);
2695                }
2696            }
2697        }
2698    }
2699
2700    /// Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
2701    ///
2702    /// Sets the *name* path property to the given value.
2703    ///
2704    /// Even though the property as already been set when instantiating this call,
2705    /// we provide this method for API completeness.
2706    pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
2707        self._name = new_value.to_string();
2708        self
2709    }
2710    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2711    /// while executing the actual API request.
2712    ///
2713    /// ````text
2714    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2715    /// ````
2716    ///
2717    /// Sets the *delegate* property to the given value.
2718    pub fn delegate(
2719        mut self,
2720        new_value: &'a mut dyn common::Delegate,
2721    ) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
2722        self._delegate = Some(new_value);
2723        self
2724    }
2725
2726    /// Set any additional parameter of the query string used in the request.
2727    /// It should be used to set parameters which are not yet available through their own
2728    /// setters.
2729    ///
2730    /// Please note that this method must not be used to set any of the known parameters
2731    /// which have their own setter method. If done anyway, the request will fail.
2732    ///
2733    /// # Additional Parameters
2734    ///
2735    /// * *$.xgafv* (query-string) - V1 error format.
2736    /// * *access_token* (query-string) - OAuth access token.
2737    /// * *alt* (query-string) - Data format for response.
2738    /// * *callback* (query-string) - JSONP
2739    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2740    /// * *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.
2741    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2742    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2743    /// * *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.
2744    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2745    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2746    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2747    where
2748        T: AsRef<str>,
2749    {
2750        self._additional_params
2751            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2752        self
2753    }
2754
2755    /// Identifies the authorization scope for the method you are building.
2756    ///
2757    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2758    /// [`Scope::CloudPlatform`].
2759    ///
2760    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2761    /// tokens for more than one scope.
2762    ///
2763    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2764    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2765    /// sufficient, a read-write scope will do as well.
2766    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2767    where
2768        St: AsRef<str>,
2769    {
2770        self._scopes.insert(String::from(scope.as_ref()));
2771        self
2772    }
2773    /// Identifies the authorization scope(s) for the method you are building.
2774    ///
2775    /// See [`Self::add_scope()`] for details.
2776    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2777    where
2778        I: IntoIterator<Item = St>,
2779        St: AsRef<str>,
2780    {
2781        self._scopes
2782            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2783        self
2784    }
2785
2786    /// Removes all scopes, and no default scope will be used either.
2787    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2788    /// for details).
2789    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
2790        self._scopes.clear();
2791        self
2792    }
2793}
2794
2795/// Gets details about a device.
2796///
2797/// A builder for the *locations.registries.devices.get* method supported by a *project* resource.
2798/// It is not used directly, but through a [`ProjectMethods`] instance.
2799///
2800/// # Example
2801///
2802/// Instantiate a resource method builder
2803///
2804/// ```test_harness,no_run
2805/// # extern crate hyper;
2806/// # extern crate hyper_rustls;
2807/// # extern crate google_cloudiot1 as cloudiot1;
2808/// # async fn dox() {
2809/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2810///
2811/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2812/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2813/// #     .with_native_roots()
2814/// #     .unwrap()
2815/// #     .https_only()
2816/// #     .enable_http2()
2817/// #     .build();
2818///
2819/// # let executor = hyper_util::rt::TokioExecutor::new();
2820/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2821/// #     secret,
2822/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2823/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2824/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2825/// #     ),
2826/// # ).build().await.unwrap();
2827///
2828/// # let client = hyper_util::client::legacy::Client::builder(
2829/// #     hyper_util::rt::TokioExecutor::new()
2830/// # )
2831/// # .build(
2832/// #     hyper_rustls::HttpsConnectorBuilder::new()
2833/// #         .with_native_roots()
2834/// #         .unwrap()
2835/// #         .https_or_http()
2836/// #         .enable_http2()
2837/// #         .build()
2838/// # );
2839/// # let mut hub = CloudIot::new(client, auth);
2840/// // You can configure optional parameters by calling the respective setters at will, and
2841/// // execute the final call using `doit()`.
2842/// // Values shown here are possibly random and not representative !
2843/// let result = hub.projects().locations_registries_devices_get("name")
2844///              .field_mask(FieldMask::new::<&str>(&[]))
2845///              .doit().await;
2846/// # }
2847/// ```
2848pub struct ProjectLocationRegistryDeviceGetCall<'a, C>
2849where
2850    C: 'a,
2851{
2852    hub: &'a CloudIot<C>,
2853    _name: String,
2854    _field_mask: Option<common::FieldMask>,
2855    _delegate: Option<&'a mut dyn common::Delegate>,
2856    _additional_params: HashMap<String, String>,
2857    _scopes: BTreeSet<String>,
2858}
2859
2860impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceGetCall<'a, C> {}
2861
2862impl<'a, C> ProjectLocationRegistryDeviceGetCall<'a, C>
2863where
2864    C: common::Connector,
2865{
2866    /// Perform the operation you have build so far.
2867    pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
2868        use std::borrow::Cow;
2869        use std::io::{Read, Seek};
2870
2871        use common::{url::Params, ToParts};
2872        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2873
2874        let mut dd = common::DefaultDelegate;
2875        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2876        dlg.begin(common::MethodInfo {
2877            id: "cloudiot.projects.locations.registries.devices.get",
2878            http_method: hyper::Method::GET,
2879        });
2880
2881        for &field in ["alt", "name", "fieldMask"].iter() {
2882            if self._additional_params.contains_key(field) {
2883                dlg.finished(false);
2884                return Err(common::Error::FieldClash(field));
2885            }
2886        }
2887
2888        let mut params = Params::with_capacity(4 + self._additional_params.len());
2889        params.push("name", self._name);
2890        if let Some(value) = self._field_mask.as_ref() {
2891            params.push("fieldMask", value.to_string());
2892        }
2893
2894        params.extend(self._additional_params.iter());
2895
2896        params.push("alt", "json");
2897        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2898        if self._scopes.is_empty() {
2899            self._scopes
2900                .insert(Scope::CloudPlatform.as_ref().to_string());
2901        }
2902
2903        #[allow(clippy::single_element_loop)]
2904        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2905            url = params.uri_replacement(url, param_name, find_this, true);
2906        }
2907        {
2908            let to_remove = ["name"];
2909            params.remove_params(&to_remove);
2910        }
2911
2912        let url = params.parse_with_url(&url);
2913
2914        loop {
2915            let token = match self
2916                .hub
2917                .auth
2918                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2919                .await
2920            {
2921                Ok(token) => token,
2922                Err(e) => match dlg.token(e) {
2923                    Ok(token) => token,
2924                    Err(e) => {
2925                        dlg.finished(false);
2926                        return Err(common::Error::MissingToken(e));
2927                    }
2928                },
2929            };
2930            let mut req_result = {
2931                let client = &self.hub.client;
2932                dlg.pre_request();
2933                let mut req_builder = hyper::Request::builder()
2934                    .method(hyper::Method::GET)
2935                    .uri(url.as_str())
2936                    .header(USER_AGENT, self.hub._user_agent.clone());
2937
2938                if let Some(token) = token.as_ref() {
2939                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2940                }
2941
2942                let request = req_builder
2943                    .header(CONTENT_LENGTH, 0_u64)
2944                    .body(common::to_body::<String>(None));
2945
2946                client.request(request.unwrap()).await
2947            };
2948
2949            match req_result {
2950                Err(err) => {
2951                    if let common::Retry::After(d) = dlg.http_error(&err) {
2952                        sleep(d).await;
2953                        continue;
2954                    }
2955                    dlg.finished(false);
2956                    return Err(common::Error::HttpError(err));
2957                }
2958                Ok(res) => {
2959                    let (mut parts, body) = res.into_parts();
2960                    let mut body = common::Body::new(body);
2961                    if !parts.status.is_success() {
2962                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2963                        let error = serde_json::from_str(&common::to_string(&bytes));
2964                        let response = common::to_response(parts, bytes.into());
2965
2966                        if let common::Retry::After(d) =
2967                            dlg.http_failure(&response, error.as_ref().ok())
2968                        {
2969                            sleep(d).await;
2970                            continue;
2971                        }
2972
2973                        dlg.finished(false);
2974
2975                        return Err(match error {
2976                            Ok(value) => common::Error::BadRequest(value),
2977                            _ => common::Error::Failure(response),
2978                        });
2979                    }
2980                    let response = {
2981                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2982                        let encoded = common::to_string(&bytes);
2983                        match serde_json::from_str(&encoded) {
2984                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2985                            Err(error) => {
2986                                dlg.response_json_decode_error(&encoded, &error);
2987                                return Err(common::Error::JsonDecodeError(
2988                                    encoded.to_string(),
2989                                    error,
2990                                ));
2991                            }
2992                        }
2993                    };
2994
2995                    dlg.finished(true);
2996                    return Ok(response);
2997                }
2998            }
2999        }
3000    }
3001
3002    /// Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
3003    ///
3004    /// Sets the *name* path property to the given value.
3005    ///
3006    /// Even though the property as already been set when instantiating this call,
3007    /// we provide this method for API completeness.
3008    pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
3009        self._name = new_value.to_string();
3010        self
3011    }
3012    /// The fields of the `Device` resource to be returned in the response. If the field mask is unset or empty, all fields are returned. Fields have to be provided in snake_case format, for example: `last_heartbeat_time`.
3013    ///
3014    /// Sets the *field mask* query property to the given value.
3015    pub fn field_mask(
3016        mut self,
3017        new_value: common::FieldMask,
3018    ) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
3019        self._field_mask = Some(new_value);
3020        self
3021    }
3022    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3023    /// while executing the actual API request.
3024    ///
3025    /// ````text
3026    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3027    /// ````
3028    ///
3029    /// Sets the *delegate* property to the given value.
3030    pub fn delegate(
3031        mut self,
3032        new_value: &'a mut dyn common::Delegate,
3033    ) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
3034        self._delegate = Some(new_value);
3035        self
3036    }
3037
3038    /// Set any additional parameter of the query string used in the request.
3039    /// It should be used to set parameters which are not yet available through their own
3040    /// setters.
3041    ///
3042    /// Please note that this method must not be used to set any of the known parameters
3043    /// which have their own setter method. If done anyway, the request will fail.
3044    ///
3045    /// # Additional Parameters
3046    ///
3047    /// * *$.xgafv* (query-string) - V1 error format.
3048    /// * *access_token* (query-string) - OAuth access token.
3049    /// * *alt* (query-string) - Data format for response.
3050    /// * *callback* (query-string) - JSONP
3051    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3052    /// * *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.
3053    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3054    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3055    /// * *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.
3056    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3057    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3058    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceGetCall<'a, C>
3059    where
3060        T: AsRef<str>,
3061    {
3062        self._additional_params
3063            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3064        self
3065    }
3066
3067    /// Identifies the authorization scope for the method you are building.
3068    ///
3069    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3070    /// [`Scope::CloudPlatform`].
3071    ///
3072    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3073    /// tokens for more than one scope.
3074    ///
3075    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3076    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3077    /// sufficient, a read-write scope will do as well.
3078    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceGetCall<'a, C>
3079    where
3080        St: AsRef<str>,
3081    {
3082        self._scopes.insert(String::from(scope.as_ref()));
3083        self
3084    }
3085    /// Identifies the authorization scope(s) for the method you are building.
3086    ///
3087    /// See [`Self::add_scope()`] for details.
3088    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceGetCall<'a, C>
3089    where
3090        I: IntoIterator<Item = St>,
3091        St: AsRef<str>,
3092    {
3093        self._scopes
3094            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3095        self
3096    }
3097
3098    /// Removes all scopes, and no default scope will be used either.
3099    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3100    /// for details).
3101    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
3102        self._scopes.clear();
3103        self
3104    }
3105}
3106
3107/// List devices in a device registry.
3108///
3109/// A builder for the *locations.registries.devices.list* method supported by a *project* resource.
3110/// It is not used directly, but through a [`ProjectMethods`] instance.
3111///
3112/// # Example
3113///
3114/// Instantiate a resource method builder
3115///
3116/// ```test_harness,no_run
3117/// # extern crate hyper;
3118/// # extern crate hyper_rustls;
3119/// # extern crate google_cloudiot1 as cloudiot1;
3120/// # async fn dox() {
3121/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3122///
3123/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3124/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3125/// #     .with_native_roots()
3126/// #     .unwrap()
3127/// #     .https_only()
3128/// #     .enable_http2()
3129/// #     .build();
3130///
3131/// # let executor = hyper_util::rt::TokioExecutor::new();
3132/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3133/// #     secret,
3134/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3135/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3136/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3137/// #     ),
3138/// # ).build().await.unwrap();
3139///
3140/// # let client = hyper_util::client::legacy::Client::builder(
3141/// #     hyper_util::rt::TokioExecutor::new()
3142/// # )
3143/// # .build(
3144/// #     hyper_rustls::HttpsConnectorBuilder::new()
3145/// #         .with_native_roots()
3146/// #         .unwrap()
3147/// #         .https_or_http()
3148/// #         .enable_http2()
3149/// #         .build()
3150/// # );
3151/// # let mut hub = CloudIot::new(client, auth);
3152/// // You can configure optional parameters by calling the respective setters at will, and
3153/// // execute the final call using `doit()`.
3154/// // Values shown here are possibly random and not representative !
3155/// let result = hub.projects().locations_registries_devices_list("parent")
3156///              .page_token("duo")
3157///              .page_size(-55)
3158///              .gateway_list_options_gateway_type("gubergren")
3159///              .gateway_list_options_associations_gateway_id("Lorem")
3160///              .gateway_list_options_associations_device_id("gubergren")
3161///              .field_mask(FieldMask::new::<&str>(&[]))
3162///              .add_device_num_ids(26)
3163///              .add_device_ids("dolor")
3164///              .doit().await;
3165/// # }
3166/// ```
3167pub struct ProjectLocationRegistryDeviceListCall<'a, C>
3168where
3169    C: 'a,
3170{
3171    hub: &'a CloudIot<C>,
3172    _parent: String,
3173    _page_token: Option<String>,
3174    _page_size: Option<i32>,
3175    _gateway_list_options_gateway_type: Option<String>,
3176    _gateway_list_options_associations_gateway_id: Option<String>,
3177    _gateway_list_options_associations_device_id: Option<String>,
3178    _field_mask: Option<common::FieldMask>,
3179    _device_num_ids: Vec<u64>,
3180    _device_ids: Vec<String>,
3181    _delegate: Option<&'a mut dyn common::Delegate>,
3182    _additional_params: HashMap<String, String>,
3183    _scopes: BTreeSet<String>,
3184}
3185
3186impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceListCall<'a, C> {}
3187
3188impl<'a, C> ProjectLocationRegistryDeviceListCall<'a, C>
3189where
3190    C: common::Connector,
3191{
3192    /// Perform the operation you have build so far.
3193    pub async fn doit(mut self) -> common::Result<(common::Response, ListDevicesResponse)> {
3194        use std::borrow::Cow;
3195        use std::io::{Read, Seek};
3196
3197        use common::{url::Params, ToParts};
3198        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3199
3200        let mut dd = common::DefaultDelegate;
3201        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3202        dlg.begin(common::MethodInfo {
3203            id: "cloudiot.projects.locations.registries.devices.list",
3204            http_method: hyper::Method::GET,
3205        });
3206
3207        for &field in [
3208            "alt",
3209            "parent",
3210            "pageToken",
3211            "pageSize",
3212            "gatewayListOptions.gatewayType",
3213            "gatewayListOptions.associationsGatewayId",
3214            "gatewayListOptions.associationsDeviceId",
3215            "fieldMask",
3216            "deviceNumIds",
3217            "deviceIds",
3218        ]
3219        .iter()
3220        {
3221            if self._additional_params.contains_key(field) {
3222                dlg.finished(false);
3223                return Err(common::Error::FieldClash(field));
3224            }
3225        }
3226
3227        let mut params = Params::with_capacity(11 + self._additional_params.len());
3228        params.push("parent", self._parent);
3229        if let Some(value) = self._page_token.as_ref() {
3230            params.push("pageToken", value);
3231        }
3232        if let Some(value) = self._page_size.as_ref() {
3233            params.push("pageSize", value.to_string());
3234        }
3235        if let Some(value) = self._gateway_list_options_gateway_type.as_ref() {
3236            params.push("gatewayListOptions.gatewayType", value);
3237        }
3238        if let Some(value) = self._gateway_list_options_associations_gateway_id.as_ref() {
3239            params.push("gatewayListOptions.associationsGatewayId", value);
3240        }
3241        if let Some(value) = self._gateway_list_options_associations_device_id.as_ref() {
3242            params.push("gatewayListOptions.associationsDeviceId", value);
3243        }
3244        if let Some(value) = self._field_mask.as_ref() {
3245            params.push("fieldMask", value.to_string());
3246        }
3247        if !self._device_num_ids.is_empty() {
3248            for f in self._device_num_ids.iter() {
3249                params.push("deviceNumIds", f.to_string());
3250            }
3251        }
3252        if !self._device_ids.is_empty() {
3253            for f in self._device_ids.iter() {
3254                params.push("deviceIds", f);
3255            }
3256        }
3257
3258        params.extend(self._additional_params.iter());
3259
3260        params.push("alt", "json");
3261        let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
3262        if self._scopes.is_empty() {
3263            self._scopes
3264                .insert(Scope::CloudPlatform.as_ref().to_string());
3265        }
3266
3267        #[allow(clippy::single_element_loop)]
3268        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3269            url = params.uri_replacement(url, param_name, find_this, true);
3270        }
3271        {
3272            let to_remove = ["parent"];
3273            params.remove_params(&to_remove);
3274        }
3275
3276        let url = params.parse_with_url(&url);
3277
3278        loop {
3279            let token = match self
3280                .hub
3281                .auth
3282                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3283                .await
3284            {
3285                Ok(token) => token,
3286                Err(e) => match dlg.token(e) {
3287                    Ok(token) => token,
3288                    Err(e) => {
3289                        dlg.finished(false);
3290                        return Err(common::Error::MissingToken(e));
3291                    }
3292                },
3293            };
3294            let mut req_result = {
3295                let client = &self.hub.client;
3296                dlg.pre_request();
3297                let mut req_builder = hyper::Request::builder()
3298                    .method(hyper::Method::GET)
3299                    .uri(url.as_str())
3300                    .header(USER_AGENT, self.hub._user_agent.clone());
3301
3302                if let Some(token) = token.as_ref() {
3303                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3304                }
3305
3306                let request = req_builder
3307                    .header(CONTENT_LENGTH, 0_u64)
3308                    .body(common::to_body::<String>(None));
3309
3310                client.request(request.unwrap()).await
3311            };
3312
3313            match req_result {
3314                Err(err) => {
3315                    if let common::Retry::After(d) = dlg.http_error(&err) {
3316                        sleep(d).await;
3317                        continue;
3318                    }
3319                    dlg.finished(false);
3320                    return Err(common::Error::HttpError(err));
3321                }
3322                Ok(res) => {
3323                    let (mut parts, body) = res.into_parts();
3324                    let mut body = common::Body::new(body);
3325                    if !parts.status.is_success() {
3326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3327                        let error = serde_json::from_str(&common::to_string(&bytes));
3328                        let response = common::to_response(parts, bytes.into());
3329
3330                        if let common::Retry::After(d) =
3331                            dlg.http_failure(&response, error.as_ref().ok())
3332                        {
3333                            sleep(d).await;
3334                            continue;
3335                        }
3336
3337                        dlg.finished(false);
3338
3339                        return Err(match error {
3340                            Ok(value) => common::Error::BadRequest(value),
3341                            _ => common::Error::Failure(response),
3342                        });
3343                    }
3344                    let response = {
3345                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3346                        let encoded = common::to_string(&bytes);
3347                        match serde_json::from_str(&encoded) {
3348                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3349                            Err(error) => {
3350                                dlg.response_json_decode_error(&encoded, &error);
3351                                return Err(common::Error::JsonDecodeError(
3352                                    encoded.to_string(),
3353                                    error,
3354                                ));
3355                            }
3356                        }
3357                    };
3358
3359                    dlg.finished(true);
3360                    return Ok(response);
3361                }
3362            }
3363        }
3364    }
3365
3366    /// Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
3367    ///
3368    /// Sets the *parent* path property to the given value.
3369    ///
3370    /// Even though the property as already been set when instantiating this call,
3371    /// we provide this method for API completeness.
3372    pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3373        self._parent = new_value.to_string();
3374        self
3375    }
3376    /// The value returned by the last `ListDevicesResponse`; indicates that this is a continuation of a prior `ListDevices` call and the system should return the next page of data.
3377    ///
3378    /// Sets the *page token* query property to the given value.
3379    pub fn page_token(mut self, new_value: &str) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3380        self._page_token = Some(new_value.to_string());
3381        self
3382    }
3383    /// The maximum number of devices to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty `next_page_token` in the response indicates that more data is available.
3384    ///
3385    /// Sets the *page size* query property to the given value.
3386    pub fn page_size(mut self, new_value: i32) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3387        self._page_size = Some(new_value);
3388        self
3389    }
3390    /// If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY` is specified, only non-gateway devices are returned. If `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
3391    ///
3392    /// Sets the *gateway list options.gateway type* query property to the given value.
3393    pub fn gateway_list_options_gateway_type(
3394        mut self,
3395        new_value: &str,
3396    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3397        self._gateway_list_options_gateway_type = Some(new_value.to_string());
3398        self
3399    }
3400    /// If set, only devices associated with the specified gateway are returned. The gateway ID can be numeric (`num_id`) or the user-defined string (`id`). For example, if `123` is specified, only devices bound to the gateway with `num_id` 123 are returned.
3401    ///
3402    /// Sets the *gateway list options.associations gateway id* query property to the given value.
3403    pub fn gateway_list_options_associations_gateway_id(
3404        mut self,
3405        new_value: &str,
3406    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3407        self._gateway_list_options_associations_gateway_id = Some(new_value.to_string());
3408        self
3409    }
3410    /// If set, returns only the gateways with which the specified device is associated. The device ID can be numeric (`num_id`) or the user-defined string (`id`). For example, if `456` is specified, returns only the gateways to which the device with `num_id` 456 is bound.
3411    ///
3412    /// Sets the *gateway list options.associations device id* query property to the given value.
3413    pub fn gateway_list_options_associations_device_id(
3414        mut self,
3415        new_value: &str,
3416    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3417        self._gateway_list_options_associations_device_id = Some(new_value.to_string());
3418        self
3419    }
3420    /// The fields of the `Device` resource to be returned in the response. The fields `id` and `num_id` are always returned, along with any other fields specified in snake_case format, for example: `last_heartbeat_time`.
3421    ///
3422    /// Sets the *field mask* query property to the given value.
3423    pub fn field_mask(
3424        mut self,
3425        new_value: common::FieldMask,
3426    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3427        self._field_mask = Some(new_value);
3428        self
3429    }
3430    /// A list of device numeric IDs. If empty, this field is ignored. Maximum IDs: 10,000.
3431    ///
3432    /// Append the given value to the *device num ids* query property.
3433    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3434    pub fn add_device_num_ids(
3435        mut self,
3436        new_value: u64,
3437    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3438        self._device_num_ids.push(new_value);
3439        self
3440    }
3441    /// A list of device string IDs. For example, `['device0', 'device12']`. If empty, this field is ignored. Maximum IDs: 10,000
3442    ///
3443    /// Append the given value to the *device ids* query property.
3444    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3445    pub fn add_device_ids(
3446        mut self,
3447        new_value: &str,
3448    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3449        self._device_ids.push(new_value.to_string());
3450        self
3451    }
3452    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3453    /// while executing the actual API request.
3454    ///
3455    /// ````text
3456    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3457    /// ````
3458    ///
3459    /// Sets the *delegate* property to the given value.
3460    pub fn delegate(
3461        mut self,
3462        new_value: &'a mut dyn common::Delegate,
3463    ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3464        self._delegate = Some(new_value);
3465        self
3466    }
3467
3468    /// Set any additional parameter of the query string used in the request.
3469    /// It should be used to set parameters which are not yet available through their own
3470    /// setters.
3471    ///
3472    /// Please note that this method must not be used to set any of the known parameters
3473    /// which have their own setter method. If done anyway, the request will fail.
3474    ///
3475    /// # Additional Parameters
3476    ///
3477    /// * *$.xgafv* (query-string) - V1 error format.
3478    /// * *access_token* (query-string) - OAuth access token.
3479    /// * *alt* (query-string) - Data format for response.
3480    /// * *callback* (query-string) - JSONP
3481    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3482    /// * *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.
3483    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3484    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3485    /// * *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.
3486    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3487    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3488    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceListCall<'a, C>
3489    where
3490        T: AsRef<str>,
3491    {
3492        self._additional_params
3493            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3494        self
3495    }
3496
3497    /// Identifies the authorization scope for the method you are building.
3498    ///
3499    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3500    /// [`Scope::CloudPlatform`].
3501    ///
3502    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3503    /// tokens for more than one scope.
3504    ///
3505    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3506    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3507    /// sufficient, a read-write scope will do as well.
3508    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceListCall<'a, C>
3509    where
3510        St: AsRef<str>,
3511    {
3512        self._scopes.insert(String::from(scope.as_ref()));
3513        self
3514    }
3515    /// Identifies the authorization scope(s) for the method you are building.
3516    ///
3517    /// See [`Self::add_scope()`] for details.
3518    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceListCall<'a, C>
3519    where
3520        I: IntoIterator<Item = St>,
3521        St: AsRef<str>,
3522    {
3523        self._scopes
3524            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3525        self
3526    }
3527
3528    /// Removes all scopes, and no default scope will be used either.
3529    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3530    /// for details).
3531    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3532        self._scopes.clear();
3533        self
3534    }
3535}
3536
3537/// Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.
3538///
3539/// A builder for the *locations.registries.devices.modifyCloudToDeviceConfig* method supported by a *project* resource.
3540/// It is not used directly, but through a [`ProjectMethods`] instance.
3541///
3542/// # Example
3543///
3544/// Instantiate a resource method builder
3545///
3546/// ```test_harness,no_run
3547/// # extern crate hyper;
3548/// # extern crate hyper_rustls;
3549/// # extern crate google_cloudiot1 as cloudiot1;
3550/// use cloudiot1::api::ModifyCloudToDeviceConfigRequest;
3551/// # async fn dox() {
3552/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3553///
3554/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3555/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3556/// #     .with_native_roots()
3557/// #     .unwrap()
3558/// #     .https_only()
3559/// #     .enable_http2()
3560/// #     .build();
3561///
3562/// # let executor = hyper_util::rt::TokioExecutor::new();
3563/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3564/// #     secret,
3565/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3566/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3567/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3568/// #     ),
3569/// # ).build().await.unwrap();
3570///
3571/// # let client = hyper_util::client::legacy::Client::builder(
3572/// #     hyper_util::rt::TokioExecutor::new()
3573/// # )
3574/// # .build(
3575/// #     hyper_rustls::HttpsConnectorBuilder::new()
3576/// #         .with_native_roots()
3577/// #         .unwrap()
3578/// #         .https_or_http()
3579/// #         .enable_http2()
3580/// #         .build()
3581/// # );
3582/// # let mut hub = CloudIot::new(client, auth);
3583/// // As the method needs a request, you would usually fill it with the desired information
3584/// // into the respective structure. Some of the parts shown here might not be applicable !
3585/// // Values shown here are possibly random and not representative !
3586/// let mut req = ModifyCloudToDeviceConfigRequest::default();
3587///
3588/// // You can configure optional parameters by calling the respective setters at will, and
3589/// // execute the final call using `doit()`.
3590/// // Values shown here are possibly random and not representative !
3591/// let result = hub.projects().locations_registries_devices_modify_cloud_to_device_config(req, "name")
3592///              .doit().await;
3593/// # }
3594/// ```
3595pub struct ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3596where
3597    C: 'a,
3598{
3599    hub: &'a CloudIot<C>,
3600    _request: ModifyCloudToDeviceConfigRequest,
3601    _name: String,
3602    _delegate: Option<&'a mut dyn common::Delegate>,
3603    _additional_params: HashMap<String, String>,
3604    _scopes: BTreeSet<String>,
3605}
3606
3607impl<'a, C> common::CallBuilder
3608    for ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3609{
3610}
3611
3612impl<'a, C> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3613where
3614    C: common::Connector,
3615{
3616    /// Perform the operation you have build so far.
3617    pub async fn doit(mut self) -> common::Result<(common::Response, DeviceConfig)> {
3618        use std::borrow::Cow;
3619        use std::io::{Read, Seek};
3620
3621        use common::{url::Params, ToParts};
3622        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3623
3624        let mut dd = common::DefaultDelegate;
3625        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3626        dlg.begin(common::MethodInfo {
3627            id: "cloudiot.projects.locations.registries.devices.modifyCloudToDeviceConfig",
3628            http_method: hyper::Method::POST,
3629        });
3630
3631        for &field in ["alt", "name"].iter() {
3632            if self._additional_params.contains_key(field) {
3633                dlg.finished(false);
3634                return Err(common::Error::FieldClash(field));
3635            }
3636        }
3637
3638        let mut params = Params::with_capacity(4 + self._additional_params.len());
3639        params.push("name", self._name);
3640
3641        params.extend(self._additional_params.iter());
3642
3643        params.push("alt", "json");
3644        let mut url = self.hub._base_url.clone() + "v1/{+name}:modifyCloudToDeviceConfig";
3645        if self._scopes.is_empty() {
3646            self._scopes
3647                .insert(Scope::CloudPlatform.as_ref().to_string());
3648        }
3649
3650        #[allow(clippy::single_element_loop)]
3651        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3652            url = params.uri_replacement(url, param_name, find_this, true);
3653        }
3654        {
3655            let to_remove = ["name"];
3656            params.remove_params(&to_remove);
3657        }
3658
3659        let url = params.parse_with_url(&url);
3660
3661        let mut json_mime_type = mime::APPLICATION_JSON;
3662        let mut request_value_reader = {
3663            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3664            common::remove_json_null_values(&mut value);
3665            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3666            serde_json::to_writer(&mut dst, &value).unwrap();
3667            dst
3668        };
3669        let request_size = request_value_reader
3670            .seek(std::io::SeekFrom::End(0))
3671            .unwrap();
3672        request_value_reader
3673            .seek(std::io::SeekFrom::Start(0))
3674            .unwrap();
3675
3676        loop {
3677            let token = match self
3678                .hub
3679                .auth
3680                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3681                .await
3682            {
3683                Ok(token) => token,
3684                Err(e) => match dlg.token(e) {
3685                    Ok(token) => token,
3686                    Err(e) => {
3687                        dlg.finished(false);
3688                        return Err(common::Error::MissingToken(e));
3689                    }
3690                },
3691            };
3692            request_value_reader
3693                .seek(std::io::SeekFrom::Start(0))
3694                .unwrap();
3695            let mut req_result = {
3696                let client = &self.hub.client;
3697                dlg.pre_request();
3698                let mut req_builder = hyper::Request::builder()
3699                    .method(hyper::Method::POST)
3700                    .uri(url.as_str())
3701                    .header(USER_AGENT, self.hub._user_agent.clone());
3702
3703                if let Some(token) = token.as_ref() {
3704                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3705                }
3706
3707                let request = req_builder
3708                    .header(CONTENT_TYPE, json_mime_type.to_string())
3709                    .header(CONTENT_LENGTH, request_size as u64)
3710                    .body(common::to_body(
3711                        request_value_reader.get_ref().clone().into(),
3712                    ));
3713
3714                client.request(request.unwrap()).await
3715            };
3716
3717            match req_result {
3718                Err(err) => {
3719                    if let common::Retry::After(d) = dlg.http_error(&err) {
3720                        sleep(d).await;
3721                        continue;
3722                    }
3723                    dlg.finished(false);
3724                    return Err(common::Error::HttpError(err));
3725                }
3726                Ok(res) => {
3727                    let (mut parts, body) = res.into_parts();
3728                    let mut body = common::Body::new(body);
3729                    if !parts.status.is_success() {
3730                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3731                        let error = serde_json::from_str(&common::to_string(&bytes));
3732                        let response = common::to_response(parts, bytes.into());
3733
3734                        if let common::Retry::After(d) =
3735                            dlg.http_failure(&response, error.as_ref().ok())
3736                        {
3737                            sleep(d).await;
3738                            continue;
3739                        }
3740
3741                        dlg.finished(false);
3742
3743                        return Err(match error {
3744                            Ok(value) => common::Error::BadRequest(value),
3745                            _ => common::Error::Failure(response),
3746                        });
3747                    }
3748                    let response = {
3749                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3750                        let encoded = common::to_string(&bytes);
3751                        match serde_json::from_str(&encoded) {
3752                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3753                            Err(error) => {
3754                                dlg.response_json_decode_error(&encoded, &error);
3755                                return Err(common::Error::JsonDecodeError(
3756                                    encoded.to_string(),
3757                                    error,
3758                                ));
3759                            }
3760                        }
3761                    };
3762
3763                    dlg.finished(true);
3764                    return Ok(response);
3765                }
3766            }
3767        }
3768    }
3769
3770    ///
3771    /// Sets the *request* property to the given value.
3772    ///
3773    /// Even though the property as already been set when instantiating this call,
3774    /// we provide this method for API completeness.
3775    pub fn request(
3776        mut self,
3777        new_value: ModifyCloudToDeviceConfigRequest,
3778    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3779        self._request = new_value;
3780        self
3781    }
3782    /// Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
3783    ///
3784    /// Sets the *name* path property to the given value.
3785    ///
3786    /// Even though the property as already been set when instantiating this call,
3787    /// we provide this method for API completeness.
3788    pub fn name(
3789        mut self,
3790        new_value: &str,
3791    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3792        self._name = new_value.to_string();
3793        self
3794    }
3795    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3796    /// while executing the actual API request.
3797    ///
3798    /// ````text
3799    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3800    /// ````
3801    ///
3802    /// Sets the *delegate* property to the given value.
3803    pub fn delegate(
3804        mut self,
3805        new_value: &'a mut dyn common::Delegate,
3806    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3807        self._delegate = Some(new_value);
3808        self
3809    }
3810
3811    /// Set any additional parameter of the query string used in the request.
3812    /// It should be used to set parameters which are not yet available through their own
3813    /// setters.
3814    ///
3815    /// Please note that this method must not be used to set any of the known parameters
3816    /// which have their own setter method. If done anyway, the request will fail.
3817    ///
3818    /// # Additional Parameters
3819    ///
3820    /// * *$.xgafv* (query-string) - V1 error format.
3821    /// * *access_token* (query-string) - OAuth access token.
3822    /// * *alt* (query-string) - Data format for response.
3823    /// * *callback* (query-string) - JSONP
3824    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3825    /// * *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.
3826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3827    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3828    /// * *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.
3829    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3830    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3831    pub fn param<T>(
3832        mut self,
3833        name: T,
3834        value: T,
3835    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3836    where
3837        T: AsRef<str>,
3838    {
3839        self._additional_params
3840            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3841        self
3842    }
3843
3844    /// Identifies the authorization scope for the method you are building.
3845    ///
3846    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3847    /// [`Scope::CloudPlatform`].
3848    ///
3849    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3850    /// tokens for more than one scope.
3851    ///
3852    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3853    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3854    /// sufficient, a read-write scope will do as well.
3855    pub fn add_scope<St>(
3856        mut self,
3857        scope: St,
3858    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3859    where
3860        St: AsRef<str>,
3861    {
3862        self._scopes.insert(String::from(scope.as_ref()));
3863        self
3864    }
3865    /// Identifies the authorization scope(s) for the method you are building.
3866    ///
3867    /// See [`Self::add_scope()`] for details.
3868    pub fn add_scopes<I, St>(
3869        mut self,
3870        scopes: I,
3871    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3872    where
3873        I: IntoIterator<Item = St>,
3874        St: AsRef<str>,
3875    {
3876        self._scopes
3877            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3878        self
3879    }
3880
3881    /// Removes all scopes, and no default scope will be used either.
3882    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3883    /// for details).
3884    pub fn clear_scopes(
3885        mut self,
3886    ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3887        self._scopes.clear();
3888        self
3889    }
3890}
3891
3892/// Updates a device.
3893///
3894/// A builder for the *locations.registries.devices.patch* method supported by a *project* resource.
3895/// It is not used directly, but through a [`ProjectMethods`] instance.
3896///
3897/// # Example
3898///
3899/// Instantiate a resource method builder
3900///
3901/// ```test_harness,no_run
3902/// # extern crate hyper;
3903/// # extern crate hyper_rustls;
3904/// # extern crate google_cloudiot1 as cloudiot1;
3905/// use cloudiot1::api::Device;
3906/// # async fn dox() {
3907/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3908///
3909/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3910/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3911/// #     .with_native_roots()
3912/// #     .unwrap()
3913/// #     .https_only()
3914/// #     .enable_http2()
3915/// #     .build();
3916///
3917/// # let executor = hyper_util::rt::TokioExecutor::new();
3918/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3919/// #     secret,
3920/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3921/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3922/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3923/// #     ),
3924/// # ).build().await.unwrap();
3925///
3926/// # let client = hyper_util::client::legacy::Client::builder(
3927/// #     hyper_util::rt::TokioExecutor::new()
3928/// # )
3929/// # .build(
3930/// #     hyper_rustls::HttpsConnectorBuilder::new()
3931/// #         .with_native_roots()
3932/// #         .unwrap()
3933/// #         .https_or_http()
3934/// #         .enable_http2()
3935/// #         .build()
3936/// # );
3937/// # let mut hub = CloudIot::new(client, auth);
3938/// // As the method needs a request, you would usually fill it with the desired information
3939/// // into the respective structure. Some of the parts shown here might not be applicable !
3940/// // Values shown here are possibly random and not representative !
3941/// let mut req = Device::default();
3942///
3943/// // You can configure optional parameters by calling the respective setters at will, and
3944/// // execute the final call using `doit()`.
3945/// // Values shown here are possibly random and not representative !
3946/// let result = hub.projects().locations_registries_devices_patch(req, "name")
3947///              .update_mask(FieldMask::new::<&str>(&[]))
3948///              .doit().await;
3949/// # }
3950/// ```
3951pub struct ProjectLocationRegistryDevicePatchCall<'a, C>
3952where
3953    C: 'a,
3954{
3955    hub: &'a CloudIot<C>,
3956    _request: Device,
3957    _name: String,
3958    _update_mask: Option<common::FieldMask>,
3959    _delegate: Option<&'a mut dyn common::Delegate>,
3960    _additional_params: HashMap<String, String>,
3961    _scopes: BTreeSet<String>,
3962}
3963
3964impl<'a, C> common::CallBuilder for ProjectLocationRegistryDevicePatchCall<'a, C> {}
3965
3966impl<'a, C> ProjectLocationRegistryDevicePatchCall<'a, C>
3967where
3968    C: common::Connector,
3969{
3970    /// Perform the operation you have build so far.
3971    pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
3972        use std::borrow::Cow;
3973        use std::io::{Read, Seek};
3974
3975        use common::{url::Params, ToParts};
3976        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3977
3978        let mut dd = common::DefaultDelegate;
3979        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3980        dlg.begin(common::MethodInfo {
3981            id: "cloudiot.projects.locations.registries.devices.patch",
3982            http_method: hyper::Method::PATCH,
3983        });
3984
3985        for &field in ["alt", "name", "updateMask"].iter() {
3986            if self._additional_params.contains_key(field) {
3987                dlg.finished(false);
3988                return Err(common::Error::FieldClash(field));
3989            }
3990        }
3991
3992        let mut params = Params::with_capacity(5 + self._additional_params.len());
3993        params.push("name", self._name);
3994        if let Some(value) = self._update_mask.as_ref() {
3995            params.push("updateMask", value.to_string());
3996        }
3997
3998        params.extend(self._additional_params.iter());
3999
4000        params.push("alt", "json");
4001        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4002        if self._scopes.is_empty() {
4003            self._scopes
4004                .insert(Scope::CloudPlatform.as_ref().to_string());
4005        }
4006
4007        #[allow(clippy::single_element_loop)]
4008        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4009            url = params.uri_replacement(url, param_name, find_this, true);
4010        }
4011        {
4012            let to_remove = ["name"];
4013            params.remove_params(&to_remove);
4014        }
4015
4016        let url = params.parse_with_url(&url);
4017
4018        let mut json_mime_type = mime::APPLICATION_JSON;
4019        let mut request_value_reader = {
4020            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4021            common::remove_json_null_values(&mut value);
4022            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4023            serde_json::to_writer(&mut dst, &value).unwrap();
4024            dst
4025        };
4026        let request_size = request_value_reader
4027            .seek(std::io::SeekFrom::End(0))
4028            .unwrap();
4029        request_value_reader
4030            .seek(std::io::SeekFrom::Start(0))
4031            .unwrap();
4032
4033        loop {
4034            let token = match self
4035                .hub
4036                .auth
4037                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4038                .await
4039            {
4040                Ok(token) => token,
4041                Err(e) => match dlg.token(e) {
4042                    Ok(token) => token,
4043                    Err(e) => {
4044                        dlg.finished(false);
4045                        return Err(common::Error::MissingToken(e));
4046                    }
4047                },
4048            };
4049            request_value_reader
4050                .seek(std::io::SeekFrom::Start(0))
4051                .unwrap();
4052            let mut req_result = {
4053                let client = &self.hub.client;
4054                dlg.pre_request();
4055                let mut req_builder = hyper::Request::builder()
4056                    .method(hyper::Method::PATCH)
4057                    .uri(url.as_str())
4058                    .header(USER_AGENT, self.hub._user_agent.clone());
4059
4060                if let Some(token) = token.as_ref() {
4061                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4062                }
4063
4064                let request = req_builder
4065                    .header(CONTENT_TYPE, json_mime_type.to_string())
4066                    .header(CONTENT_LENGTH, request_size as u64)
4067                    .body(common::to_body(
4068                        request_value_reader.get_ref().clone().into(),
4069                    ));
4070
4071                client.request(request.unwrap()).await
4072            };
4073
4074            match req_result {
4075                Err(err) => {
4076                    if let common::Retry::After(d) = dlg.http_error(&err) {
4077                        sleep(d).await;
4078                        continue;
4079                    }
4080                    dlg.finished(false);
4081                    return Err(common::Error::HttpError(err));
4082                }
4083                Ok(res) => {
4084                    let (mut parts, body) = res.into_parts();
4085                    let mut body = common::Body::new(body);
4086                    if !parts.status.is_success() {
4087                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4088                        let error = serde_json::from_str(&common::to_string(&bytes));
4089                        let response = common::to_response(parts, bytes.into());
4090
4091                        if let common::Retry::After(d) =
4092                            dlg.http_failure(&response, error.as_ref().ok())
4093                        {
4094                            sleep(d).await;
4095                            continue;
4096                        }
4097
4098                        dlg.finished(false);
4099
4100                        return Err(match error {
4101                            Ok(value) => common::Error::BadRequest(value),
4102                            _ => common::Error::Failure(response),
4103                        });
4104                    }
4105                    let response = {
4106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4107                        let encoded = common::to_string(&bytes);
4108                        match serde_json::from_str(&encoded) {
4109                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4110                            Err(error) => {
4111                                dlg.response_json_decode_error(&encoded, &error);
4112                                return Err(common::Error::JsonDecodeError(
4113                                    encoded.to_string(),
4114                                    error,
4115                                ));
4116                            }
4117                        }
4118                    };
4119
4120                    dlg.finished(true);
4121                    return Ok(response);
4122                }
4123            }
4124        }
4125    }
4126
4127    ///
4128    /// Sets the *request* property to the given value.
4129    ///
4130    /// Even though the property as already been set when instantiating this call,
4131    /// we provide this method for API completeness.
4132    pub fn request(mut self, new_value: Device) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4133        self._request = new_value;
4134        self
4135    }
4136    /// The resource path name. For example, `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. When `name` is populated as a response from the service, it always ends in the device numeric ID.
4137    ///
4138    /// Sets the *name* path property to the given value.
4139    ///
4140    /// Even though the property as already been set when instantiating this call,
4141    /// we provide this method for API completeness.
4142    pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4143        self._name = new_value.to_string();
4144        self
4145    }
4146    /// Required. Only updates the `device` fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: `credentials`, `blocked`, and `metadata`
4147    ///
4148    /// Sets the *update mask* query property to the given value.
4149    pub fn update_mask(
4150        mut self,
4151        new_value: common::FieldMask,
4152    ) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4153        self._update_mask = Some(new_value);
4154        self
4155    }
4156    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4157    /// while executing the actual API request.
4158    ///
4159    /// ````text
4160    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4161    /// ````
4162    ///
4163    /// Sets the *delegate* property to the given value.
4164    pub fn delegate(
4165        mut self,
4166        new_value: &'a mut dyn common::Delegate,
4167    ) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4168        self._delegate = Some(new_value);
4169        self
4170    }
4171
4172    /// Set any additional parameter of the query string used in the request.
4173    /// It should be used to set parameters which are not yet available through their own
4174    /// setters.
4175    ///
4176    /// Please note that this method must not be used to set any of the known parameters
4177    /// which have their own setter method. If done anyway, the request will fail.
4178    ///
4179    /// # Additional Parameters
4180    ///
4181    /// * *$.xgafv* (query-string) - V1 error format.
4182    /// * *access_token* (query-string) - OAuth access token.
4183    /// * *alt* (query-string) - Data format for response.
4184    /// * *callback* (query-string) - JSONP
4185    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4186    /// * *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.
4187    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4188    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4189    /// * *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.
4190    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4191    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4192    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDevicePatchCall<'a, C>
4193    where
4194        T: AsRef<str>,
4195    {
4196        self._additional_params
4197            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4198        self
4199    }
4200
4201    /// Identifies the authorization scope for the method you are building.
4202    ///
4203    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4204    /// [`Scope::CloudPlatform`].
4205    ///
4206    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4207    /// tokens for more than one scope.
4208    ///
4209    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4210    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4211    /// sufficient, a read-write scope will do as well.
4212    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDevicePatchCall<'a, C>
4213    where
4214        St: AsRef<str>,
4215    {
4216        self._scopes.insert(String::from(scope.as_ref()));
4217        self
4218    }
4219    /// Identifies the authorization scope(s) for the method you are building.
4220    ///
4221    /// See [`Self::add_scope()`] for details.
4222    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDevicePatchCall<'a, C>
4223    where
4224        I: IntoIterator<Item = St>,
4225        St: AsRef<str>,
4226    {
4227        self._scopes
4228            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4229        self
4230    }
4231
4232    /// Removes all scopes, and no default scope will be used either.
4233    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4234    /// for details).
4235    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4236        self._scopes.clear();
4237        self
4238    }
4239}
4240
4241/// Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.
4242///
4243/// A builder for the *locations.registries.devices.sendCommandToDevice* method supported by a *project* resource.
4244/// It is not used directly, but through a [`ProjectMethods`] instance.
4245///
4246/// # Example
4247///
4248/// Instantiate a resource method builder
4249///
4250/// ```test_harness,no_run
4251/// # extern crate hyper;
4252/// # extern crate hyper_rustls;
4253/// # extern crate google_cloudiot1 as cloudiot1;
4254/// use cloudiot1::api::SendCommandToDeviceRequest;
4255/// # async fn dox() {
4256/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4257///
4258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4259/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4260/// #     .with_native_roots()
4261/// #     .unwrap()
4262/// #     .https_only()
4263/// #     .enable_http2()
4264/// #     .build();
4265///
4266/// # let executor = hyper_util::rt::TokioExecutor::new();
4267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4268/// #     secret,
4269/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4270/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4271/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4272/// #     ),
4273/// # ).build().await.unwrap();
4274///
4275/// # let client = hyper_util::client::legacy::Client::builder(
4276/// #     hyper_util::rt::TokioExecutor::new()
4277/// # )
4278/// # .build(
4279/// #     hyper_rustls::HttpsConnectorBuilder::new()
4280/// #         .with_native_roots()
4281/// #         .unwrap()
4282/// #         .https_or_http()
4283/// #         .enable_http2()
4284/// #         .build()
4285/// # );
4286/// # let mut hub = CloudIot::new(client, auth);
4287/// // As the method needs a request, you would usually fill it with the desired information
4288/// // into the respective structure. Some of the parts shown here might not be applicable !
4289/// // Values shown here are possibly random and not representative !
4290/// let mut req = SendCommandToDeviceRequest::default();
4291///
4292/// // You can configure optional parameters by calling the respective setters at will, and
4293/// // execute the final call using `doit()`.
4294/// // Values shown here are possibly random and not representative !
4295/// let result = hub.projects().locations_registries_devices_send_command_to_device(req, "name")
4296///              .doit().await;
4297/// # }
4298/// ```
4299pub struct ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4300where
4301    C: 'a,
4302{
4303    hub: &'a CloudIot<C>,
4304    _request: SendCommandToDeviceRequest,
4305    _name: String,
4306    _delegate: Option<&'a mut dyn common::Delegate>,
4307    _additional_params: HashMap<String, String>,
4308    _scopes: BTreeSet<String>,
4309}
4310
4311impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {}
4312
4313impl<'a, C> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4314where
4315    C: common::Connector,
4316{
4317    /// Perform the operation you have build so far.
4318    pub async fn doit(mut self) -> common::Result<(common::Response, SendCommandToDeviceResponse)> {
4319        use std::borrow::Cow;
4320        use std::io::{Read, Seek};
4321
4322        use common::{url::Params, ToParts};
4323        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4324
4325        let mut dd = common::DefaultDelegate;
4326        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4327        dlg.begin(common::MethodInfo {
4328            id: "cloudiot.projects.locations.registries.devices.sendCommandToDevice",
4329            http_method: hyper::Method::POST,
4330        });
4331
4332        for &field in ["alt", "name"].iter() {
4333            if self._additional_params.contains_key(field) {
4334                dlg.finished(false);
4335                return Err(common::Error::FieldClash(field));
4336            }
4337        }
4338
4339        let mut params = Params::with_capacity(4 + self._additional_params.len());
4340        params.push("name", self._name);
4341
4342        params.extend(self._additional_params.iter());
4343
4344        params.push("alt", "json");
4345        let mut url = self.hub._base_url.clone() + "v1/{+name}:sendCommandToDevice";
4346        if self._scopes.is_empty() {
4347            self._scopes
4348                .insert(Scope::CloudPlatform.as_ref().to_string());
4349        }
4350
4351        #[allow(clippy::single_element_loop)]
4352        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4353            url = params.uri_replacement(url, param_name, find_this, true);
4354        }
4355        {
4356            let to_remove = ["name"];
4357            params.remove_params(&to_remove);
4358        }
4359
4360        let url = params.parse_with_url(&url);
4361
4362        let mut json_mime_type = mime::APPLICATION_JSON;
4363        let mut request_value_reader = {
4364            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4365            common::remove_json_null_values(&mut value);
4366            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4367            serde_json::to_writer(&mut dst, &value).unwrap();
4368            dst
4369        };
4370        let request_size = request_value_reader
4371            .seek(std::io::SeekFrom::End(0))
4372            .unwrap();
4373        request_value_reader
4374            .seek(std::io::SeekFrom::Start(0))
4375            .unwrap();
4376
4377        loop {
4378            let token = match self
4379                .hub
4380                .auth
4381                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4382                .await
4383            {
4384                Ok(token) => token,
4385                Err(e) => match dlg.token(e) {
4386                    Ok(token) => token,
4387                    Err(e) => {
4388                        dlg.finished(false);
4389                        return Err(common::Error::MissingToken(e));
4390                    }
4391                },
4392            };
4393            request_value_reader
4394                .seek(std::io::SeekFrom::Start(0))
4395                .unwrap();
4396            let mut req_result = {
4397                let client = &self.hub.client;
4398                dlg.pre_request();
4399                let mut req_builder = hyper::Request::builder()
4400                    .method(hyper::Method::POST)
4401                    .uri(url.as_str())
4402                    .header(USER_AGENT, self.hub._user_agent.clone());
4403
4404                if let Some(token) = token.as_ref() {
4405                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4406                }
4407
4408                let request = req_builder
4409                    .header(CONTENT_TYPE, json_mime_type.to_string())
4410                    .header(CONTENT_LENGTH, request_size as u64)
4411                    .body(common::to_body(
4412                        request_value_reader.get_ref().clone().into(),
4413                    ));
4414
4415                client.request(request.unwrap()).await
4416            };
4417
4418            match req_result {
4419                Err(err) => {
4420                    if let common::Retry::After(d) = dlg.http_error(&err) {
4421                        sleep(d).await;
4422                        continue;
4423                    }
4424                    dlg.finished(false);
4425                    return Err(common::Error::HttpError(err));
4426                }
4427                Ok(res) => {
4428                    let (mut parts, body) = res.into_parts();
4429                    let mut body = common::Body::new(body);
4430                    if !parts.status.is_success() {
4431                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4432                        let error = serde_json::from_str(&common::to_string(&bytes));
4433                        let response = common::to_response(parts, bytes.into());
4434
4435                        if let common::Retry::After(d) =
4436                            dlg.http_failure(&response, error.as_ref().ok())
4437                        {
4438                            sleep(d).await;
4439                            continue;
4440                        }
4441
4442                        dlg.finished(false);
4443
4444                        return Err(match error {
4445                            Ok(value) => common::Error::BadRequest(value),
4446                            _ => common::Error::Failure(response),
4447                        });
4448                    }
4449                    let response = {
4450                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4451                        let encoded = common::to_string(&bytes);
4452                        match serde_json::from_str(&encoded) {
4453                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4454                            Err(error) => {
4455                                dlg.response_json_decode_error(&encoded, &error);
4456                                return Err(common::Error::JsonDecodeError(
4457                                    encoded.to_string(),
4458                                    error,
4459                                ));
4460                            }
4461                        }
4462                    };
4463
4464                    dlg.finished(true);
4465                    return Ok(response);
4466                }
4467            }
4468        }
4469    }
4470
4471    ///
4472    /// Sets the *request* property to the given value.
4473    ///
4474    /// Even though the property as already been set when instantiating this call,
4475    /// we provide this method for API completeness.
4476    pub fn request(
4477        mut self,
4478        new_value: SendCommandToDeviceRequest,
4479    ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4480        self._request = new_value;
4481        self
4482    }
4483    /// Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
4484    ///
4485    /// Sets the *name* path property to the given value.
4486    ///
4487    /// Even though the property as already been set when instantiating this call,
4488    /// we provide this method for API completeness.
4489    pub fn name(
4490        mut self,
4491        new_value: &str,
4492    ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4493        self._name = new_value.to_string();
4494        self
4495    }
4496    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4497    /// while executing the actual API request.
4498    ///
4499    /// ````text
4500    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4501    /// ````
4502    ///
4503    /// Sets the *delegate* property to the given value.
4504    pub fn delegate(
4505        mut self,
4506        new_value: &'a mut dyn common::Delegate,
4507    ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4508        self._delegate = Some(new_value);
4509        self
4510    }
4511
4512    /// Set any additional parameter of the query string used in the request.
4513    /// It should be used to set parameters which are not yet available through their own
4514    /// setters.
4515    ///
4516    /// Please note that this method must not be used to set any of the known parameters
4517    /// which have their own setter method. If done anyway, the request will fail.
4518    ///
4519    /// # Additional Parameters
4520    ///
4521    /// * *$.xgafv* (query-string) - V1 error format.
4522    /// * *access_token* (query-string) - OAuth access token.
4523    /// * *alt* (query-string) - Data format for response.
4524    /// * *callback* (query-string) - JSONP
4525    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4526    /// * *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.
4527    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4528    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4529    /// * *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.
4530    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4531    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4532    pub fn param<T>(
4533        mut self,
4534        name: T,
4535        value: T,
4536    ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4537    where
4538        T: AsRef<str>,
4539    {
4540        self._additional_params
4541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4542        self
4543    }
4544
4545    /// Identifies the authorization scope for the method you are building.
4546    ///
4547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4548    /// [`Scope::CloudPlatform`].
4549    ///
4550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4551    /// tokens for more than one scope.
4552    ///
4553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4555    /// sufficient, a read-write scope will do as well.
4556    pub fn add_scope<St>(
4557        mut self,
4558        scope: St,
4559    ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4560    where
4561        St: AsRef<str>,
4562    {
4563        self._scopes.insert(String::from(scope.as_ref()));
4564        self
4565    }
4566    /// Identifies the authorization scope(s) for the method you are building.
4567    ///
4568    /// See [`Self::add_scope()`] for details.
4569    pub fn add_scopes<I, St>(
4570        mut self,
4571        scopes: I,
4572    ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4573    where
4574        I: IntoIterator<Item = St>,
4575        St: AsRef<str>,
4576    {
4577        self._scopes
4578            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4579        self
4580    }
4581
4582    /// Removes all scopes, and no default scope will be used either.
4583    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4584    /// for details).
4585    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4586        self._scopes.clear();
4587        self
4588    }
4589}
4590
4591/// List devices in a device registry.
4592///
4593/// A builder for the *locations.registries.groups.devices.list* method supported by a *project* resource.
4594/// It is not used directly, but through a [`ProjectMethods`] instance.
4595///
4596/// # Example
4597///
4598/// Instantiate a resource method builder
4599///
4600/// ```test_harness,no_run
4601/// # extern crate hyper;
4602/// # extern crate hyper_rustls;
4603/// # extern crate google_cloudiot1 as cloudiot1;
4604/// # async fn dox() {
4605/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4606///
4607/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4608/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4609/// #     .with_native_roots()
4610/// #     .unwrap()
4611/// #     .https_only()
4612/// #     .enable_http2()
4613/// #     .build();
4614///
4615/// # let executor = hyper_util::rt::TokioExecutor::new();
4616/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4617/// #     secret,
4618/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4619/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4620/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4621/// #     ),
4622/// # ).build().await.unwrap();
4623///
4624/// # let client = hyper_util::client::legacy::Client::builder(
4625/// #     hyper_util::rt::TokioExecutor::new()
4626/// # )
4627/// # .build(
4628/// #     hyper_rustls::HttpsConnectorBuilder::new()
4629/// #         .with_native_roots()
4630/// #         .unwrap()
4631/// #         .https_or_http()
4632/// #         .enable_http2()
4633/// #         .build()
4634/// # );
4635/// # let mut hub = CloudIot::new(client, auth);
4636/// // You can configure optional parameters by calling the respective setters at will, and
4637/// // execute the final call using `doit()`.
4638/// // Values shown here are possibly random and not representative !
4639/// let result = hub.projects().locations_registries_groups_devices_list("parent")
4640///              .page_token("duo")
4641///              .page_size(-50)
4642///              .gateway_list_options_gateway_type("sed")
4643///              .gateway_list_options_associations_gateway_id("ut")
4644///              .gateway_list_options_associations_device_id("gubergren")
4645///              .field_mask(FieldMask::new::<&str>(&[]))
4646///              .add_device_num_ids(85)
4647///              .add_device_ids("est")
4648///              .doit().await;
4649/// # }
4650/// ```
4651pub struct ProjectLocationRegistryGroupDeviceListCall<'a, C>
4652where
4653    C: 'a,
4654{
4655    hub: &'a CloudIot<C>,
4656    _parent: String,
4657    _page_token: Option<String>,
4658    _page_size: Option<i32>,
4659    _gateway_list_options_gateway_type: Option<String>,
4660    _gateway_list_options_associations_gateway_id: Option<String>,
4661    _gateway_list_options_associations_device_id: Option<String>,
4662    _field_mask: Option<common::FieldMask>,
4663    _device_num_ids: Vec<u64>,
4664    _device_ids: Vec<String>,
4665    _delegate: Option<&'a mut dyn common::Delegate>,
4666    _additional_params: HashMap<String, String>,
4667    _scopes: BTreeSet<String>,
4668}
4669
4670impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupDeviceListCall<'a, C> {}
4671
4672impl<'a, C> ProjectLocationRegistryGroupDeviceListCall<'a, C>
4673where
4674    C: common::Connector,
4675{
4676    /// Perform the operation you have build so far.
4677    pub async fn doit(mut self) -> common::Result<(common::Response, ListDevicesResponse)> {
4678        use std::borrow::Cow;
4679        use std::io::{Read, Seek};
4680
4681        use common::{url::Params, ToParts};
4682        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4683
4684        let mut dd = common::DefaultDelegate;
4685        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4686        dlg.begin(common::MethodInfo {
4687            id: "cloudiot.projects.locations.registries.groups.devices.list",
4688            http_method: hyper::Method::GET,
4689        });
4690
4691        for &field in [
4692            "alt",
4693            "parent",
4694            "pageToken",
4695            "pageSize",
4696            "gatewayListOptions.gatewayType",
4697            "gatewayListOptions.associationsGatewayId",
4698            "gatewayListOptions.associationsDeviceId",
4699            "fieldMask",
4700            "deviceNumIds",
4701            "deviceIds",
4702        ]
4703        .iter()
4704        {
4705            if self._additional_params.contains_key(field) {
4706                dlg.finished(false);
4707                return Err(common::Error::FieldClash(field));
4708            }
4709        }
4710
4711        let mut params = Params::with_capacity(11 + self._additional_params.len());
4712        params.push("parent", self._parent);
4713        if let Some(value) = self._page_token.as_ref() {
4714            params.push("pageToken", value);
4715        }
4716        if let Some(value) = self._page_size.as_ref() {
4717            params.push("pageSize", value.to_string());
4718        }
4719        if let Some(value) = self._gateway_list_options_gateway_type.as_ref() {
4720            params.push("gatewayListOptions.gatewayType", value);
4721        }
4722        if let Some(value) = self._gateway_list_options_associations_gateway_id.as_ref() {
4723            params.push("gatewayListOptions.associationsGatewayId", value);
4724        }
4725        if let Some(value) = self._gateway_list_options_associations_device_id.as_ref() {
4726            params.push("gatewayListOptions.associationsDeviceId", value);
4727        }
4728        if let Some(value) = self._field_mask.as_ref() {
4729            params.push("fieldMask", value.to_string());
4730        }
4731        if !self._device_num_ids.is_empty() {
4732            for f in self._device_num_ids.iter() {
4733                params.push("deviceNumIds", f.to_string());
4734            }
4735        }
4736        if !self._device_ids.is_empty() {
4737            for f in self._device_ids.iter() {
4738                params.push("deviceIds", f);
4739            }
4740        }
4741
4742        params.extend(self._additional_params.iter());
4743
4744        params.push("alt", "json");
4745        let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
4746        if self._scopes.is_empty() {
4747            self._scopes
4748                .insert(Scope::CloudPlatform.as_ref().to_string());
4749        }
4750
4751        #[allow(clippy::single_element_loop)]
4752        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4753            url = params.uri_replacement(url, param_name, find_this, true);
4754        }
4755        {
4756            let to_remove = ["parent"];
4757            params.remove_params(&to_remove);
4758        }
4759
4760        let url = params.parse_with_url(&url);
4761
4762        loop {
4763            let token = match self
4764                .hub
4765                .auth
4766                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4767                .await
4768            {
4769                Ok(token) => token,
4770                Err(e) => match dlg.token(e) {
4771                    Ok(token) => token,
4772                    Err(e) => {
4773                        dlg.finished(false);
4774                        return Err(common::Error::MissingToken(e));
4775                    }
4776                },
4777            };
4778            let mut req_result = {
4779                let client = &self.hub.client;
4780                dlg.pre_request();
4781                let mut req_builder = hyper::Request::builder()
4782                    .method(hyper::Method::GET)
4783                    .uri(url.as_str())
4784                    .header(USER_AGENT, self.hub._user_agent.clone());
4785
4786                if let Some(token) = token.as_ref() {
4787                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4788                }
4789
4790                let request = req_builder
4791                    .header(CONTENT_LENGTH, 0_u64)
4792                    .body(common::to_body::<String>(None));
4793
4794                client.request(request.unwrap()).await
4795            };
4796
4797            match req_result {
4798                Err(err) => {
4799                    if let common::Retry::After(d) = dlg.http_error(&err) {
4800                        sleep(d).await;
4801                        continue;
4802                    }
4803                    dlg.finished(false);
4804                    return Err(common::Error::HttpError(err));
4805                }
4806                Ok(res) => {
4807                    let (mut parts, body) = res.into_parts();
4808                    let mut body = common::Body::new(body);
4809                    if !parts.status.is_success() {
4810                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4811                        let error = serde_json::from_str(&common::to_string(&bytes));
4812                        let response = common::to_response(parts, bytes.into());
4813
4814                        if let common::Retry::After(d) =
4815                            dlg.http_failure(&response, error.as_ref().ok())
4816                        {
4817                            sleep(d).await;
4818                            continue;
4819                        }
4820
4821                        dlg.finished(false);
4822
4823                        return Err(match error {
4824                            Ok(value) => common::Error::BadRequest(value),
4825                            _ => common::Error::Failure(response),
4826                        });
4827                    }
4828                    let response = {
4829                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4830                        let encoded = common::to_string(&bytes);
4831                        match serde_json::from_str(&encoded) {
4832                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4833                            Err(error) => {
4834                                dlg.response_json_decode_error(&encoded, &error);
4835                                return Err(common::Error::JsonDecodeError(
4836                                    encoded.to_string(),
4837                                    error,
4838                                ));
4839                            }
4840                        }
4841                    };
4842
4843                    dlg.finished(true);
4844                    return Ok(response);
4845                }
4846            }
4847        }
4848    }
4849
4850    /// Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
4851    ///
4852    /// Sets the *parent* path property to the given value.
4853    ///
4854    /// Even though the property as already been set when instantiating this call,
4855    /// we provide this method for API completeness.
4856    pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4857        self._parent = new_value.to_string();
4858        self
4859    }
4860    /// The value returned by the last `ListDevicesResponse`; indicates that this is a continuation of a prior `ListDevices` call and the system should return the next page of data.
4861    ///
4862    /// Sets the *page token* query property to the given value.
4863    pub fn page_token(
4864        mut self,
4865        new_value: &str,
4866    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4867        self._page_token = Some(new_value.to_string());
4868        self
4869    }
4870    /// The maximum number of devices to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty `next_page_token` in the response indicates that more data is available.
4871    ///
4872    /// Sets the *page size* query property to the given value.
4873    pub fn page_size(
4874        mut self,
4875        new_value: i32,
4876    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4877        self._page_size = Some(new_value);
4878        self
4879    }
4880    /// If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY` is specified, only non-gateway devices are returned. If `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
4881    ///
4882    /// Sets the *gateway list options.gateway type* query property to the given value.
4883    pub fn gateway_list_options_gateway_type(
4884        mut self,
4885        new_value: &str,
4886    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4887        self._gateway_list_options_gateway_type = Some(new_value.to_string());
4888        self
4889    }
4890    /// If set, only devices associated with the specified gateway are returned. The gateway ID can be numeric (`num_id`) or the user-defined string (`id`). For example, if `123` is specified, only devices bound to the gateway with `num_id` 123 are returned.
4891    ///
4892    /// Sets the *gateway list options.associations gateway id* query property to the given value.
4893    pub fn gateway_list_options_associations_gateway_id(
4894        mut self,
4895        new_value: &str,
4896    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4897        self._gateway_list_options_associations_gateway_id = Some(new_value.to_string());
4898        self
4899    }
4900    /// If set, returns only the gateways with which the specified device is associated. The device ID can be numeric (`num_id`) or the user-defined string (`id`). For example, if `456` is specified, returns only the gateways to which the device with `num_id` 456 is bound.
4901    ///
4902    /// Sets the *gateway list options.associations device id* query property to the given value.
4903    pub fn gateway_list_options_associations_device_id(
4904        mut self,
4905        new_value: &str,
4906    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4907        self._gateway_list_options_associations_device_id = Some(new_value.to_string());
4908        self
4909    }
4910    /// The fields of the `Device` resource to be returned in the response. The fields `id` and `num_id` are always returned, along with any other fields specified in snake_case format, for example: `last_heartbeat_time`.
4911    ///
4912    /// Sets the *field mask* query property to the given value.
4913    pub fn field_mask(
4914        mut self,
4915        new_value: common::FieldMask,
4916    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4917        self._field_mask = Some(new_value);
4918        self
4919    }
4920    /// A list of device numeric IDs. If empty, this field is ignored. Maximum IDs: 10,000.
4921    ///
4922    /// Append the given value to the *device num ids* query property.
4923    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4924    pub fn add_device_num_ids(
4925        mut self,
4926        new_value: u64,
4927    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4928        self._device_num_ids.push(new_value);
4929        self
4930    }
4931    /// A list of device string IDs. For example, `['device0', 'device12']`. If empty, this field is ignored. Maximum IDs: 10,000
4932    ///
4933    /// Append the given value to the *device ids* query property.
4934    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4935    pub fn add_device_ids(
4936        mut self,
4937        new_value: &str,
4938    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4939        self._device_ids.push(new_value.to_string());
4940        self
4941    }
4942    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4943    /// while executing the actual API request.
4944    ///
4945    /// ````text
4946    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4947    /// ````
4948    ///
4949    /// Sets the *delegate* property to the given value.
4950    pub fn delegate(
4951        mut self,
4952        new_value: &'a mut dyn common::Delegate,
4953    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4954        self._delegate = Some(new_value);
4955        self
4956    }
4957
4958    /// Set any additional parameter of the query string used in the request.
4959    /// It should be used to set parameters which are not yet available through their own
4960    /// setters.
4961    ///
4962    /// Please note that this method must not be used to set any of the known parameters
4963    /// which have their own setter method. If done anyway, the request will fail.
4964    ///
4965    /// # Additional Parameters
4966    ///
4967    /// * *$.xgafv* (query-string) - V1 error format.
4968    /// * *access_token* (query-string) - OAuth access token.
4969    /// * *alt* (query-string) - Data format for response.
4970    /// * *callback* (query-string) - JSONP
4971    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4972    /// * *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.
4973    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4974    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4975    /// * *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.
4976    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4977    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4978    pub fn param<T>(
4979        mut self,
4980        name: T,
4981        value: T,
4982    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C>
4983    where
4984        T: AsRef<str>,
4985    {
4986        self._additional_params
4987            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4988        self
4989    }
4990
4991    /// Identifies the authorization scope for the method you are building.
4992    ///
4993    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4994    /// [`Scope::CloudPlatform`].
4995    ///
4996    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4997    /// tokens for more than one scope.
4998    ///
4999    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5000    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5001    /// sufficient, a read-write scope will do as well.
5002    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGroupDeviceListCall<'a, C>
5003    where
5004        St: AsRef<str>,
5005    {
5006        self._scopes.insert(String::from(scope.as_ref()));
5007        self
5008    }
5009    /// Identifies the authorization scope(s) for the method you are building.
5010    ///
5011    /// See [`Self::add_scope()`] for details.
5012    pub fn add_scopes<I, St>(
5013        mut self,
5014        scopes: I,
5015    ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C>
5016    where
5017        I: IntoIterator<Item = St>,
5018        St: AsRef<str>,
5019    {
5020        self._scopes
5021            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5022        self
5023    }
5024
5025    /// Removes all scopes, and no default scope will be used either.
5026    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5027    /// for details).
5028    pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
5029        self._scopes.clear();
5030        self
5031    }
5032}
5033
5034/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
5035///
5036/// A builder for the *locations.registries.groups.getIamPolicy* method supported by a *project* resource.
5037/// It is not used directly, but through a [`ProjectMethods`] instance.
5038///
5039/// # Example
5040///
5041/// Instantiate a resource method builder
5042///
5043/// ```test_harness,no_run
5044/// # extern crate hyper;
5045/// # extern crate hyper_rustls;
5046/// # extern crate google_cloudiot1 as cloudiot1;
5047/// use cloudiot1::api::GetIamPolicyRequest;
5048/// # async fn dox() {
5049/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5050///
5051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5052/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5053/// #     .with_native_roots()
5054/// #     .unwrap()
5055/// #     .https_only()
5056/// #     .enable_http2()
5057/// #     .build();
5058///
5059/// # let executor = hyper_util::rt::TokioExecutor::new();
5060/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5061/// #     secret,
5062/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5063/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5064/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5065/// #     ),
5066/// # ).build().await.unwrap();
5067///
5068/// # let client = hyper_util::client::legacy::Client::builder(
5069/// #     hyper_util::rt::TokioExecutor::new()
5070/// # )
5071/// # .build(
5072/// #     hyper_rustls::HttpsConnectorBuilder::new()
5073/// #         .with_native_roots()
5074/// #         .unwrap()
5075/// #         .https_or_http()
5076/// #         .enable_http2()
5077/// #         .build()
5078/// # );
5079/// # let mut hub = CloudIot::new(client, auth);
5080/// // As the method needs a request, you would usually fill it with the desired information
5081/// // into the respective structure. Some of the parts shown here might not be applicable !
5082/// // Values shown here are possibly random and not representative !
5083/// let mut req = GetIamPolicyRequest::default();
5084///
5085/// // You can configure optional parameters by calling the respective setters at will, and
5086/// // execute the final call using `doit()`.
5087/// // Values shown here are possibly random and not representative !
5088/// let result = hub.projects().locations_registries_groups_get_iam_policy(req, "resource")
5089///              .doit().await;
5090/// # }
5091/// ```
5092pub struct ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5093where
5094    C: 'a,
5095{
5096    hub: &'a CloudIot<C>,
5097    _request: GetIamPolicyRequest,
5098    _resource: String,
5099    _delegate: Option<&'a mut dyn common::Delegate>,
5100    _additional_params: HashMap<String, String>,
5101    _scopes: BTreeSet<String>,
5102}
5103
5104impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {}
5105
5106impl<'a, C> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5107where
5108    C: common::Connector,
5109{
5110    /// Perform the operation you have build so far.
5111    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5112        use std::borrow::Cow;
5113        use std::io::{Read, Seek};
5114
5115        use common::{url::Params, ToParts};
5116        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5117
5118        let mut dd = common::DefaultDelegate;
5119        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5120        dlg.begin(common::MethodInfo {
5121            id: "cloudiot.projects.locations.registries.groups.getIamPolicy",
5122            http_method: hyper::Method::POST,
5123        });
5124
5125        for &field in ["alt", "resource"].iter() {
5126            if self._additional_params.contains_key(field) {
5127                dlg.finished(false);
5128                return Err(common::Error::FieldClash(field));
5129            }
5130        }
5131
5132        let mut params = Params::with_capacity(4 + self._additional_params.len());
5133        params.push("resource", self._resource);
5134
5135        params.extend(self._additional_params.iter());
5136
5137        params.push("alt", "json");
5138        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
5139        if self._scopes.is_empty() {
5140            self._scopes
5141                .insert(Scope::CloudPlatform.as_ref().to_string());
5142        }
5143
5144        #[allow(clippy::single_element_loop)]
5145        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5146            url = params.uri_replacement(url, param_name, find_this, true);
5147        }
5148        {
5149            let to_remove = ["resource"];
5150            params.remove_params(&to_remove);
5151        }
5152
5153        let url = params.parse_with_url(&url);
5154
5155        let mut json_mime_type = mime::APPLICATION_JSON;
5156        let mut request_value_reader = {
5157            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5158            common::remove_json_null_values(&mut value);
5159            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5160            serde_json::to_writer(&mut dst, &value).unwrap();
5161            dst
5162        };
5163        let request_size = request_value_reader
5164            .seek(std::io::SeekFrom::End(0))
5165            .unwrap();
5166        request_value_reader
5167            .seek(std::io::SeekFrom::Start(0))
5168            .unwrap();
5169
5170        loop {
5171            let token = match self
5172                .hub
5173                .auth
5174                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5175                .await
5176            {
5177                Ok(token) => token,
5178                Err(e) => match dlg.token(e) {
5179                    Ok(token) => token,
5180                    Err(e) => {
5181                        dlg.finished(false);
5182                        return Err(common::Error::MissingToken(e));
5183                    }
5184                },
5185            };
5186            request_value_reader
5187                .seek(std::io::SeekFrom::Start(0))
5188                .unwrap();
5189            let mut req_result = {
5190                let client = &self.hub.client;
5191                dlg.pre_request();
5192                let mut req_builder = hyper::Request::builder()
5193                    .method(hyper::Method::POST)
5194                    .uri(url.as_str())
5195                    .header(USER_AGENT, self.hub._user_agent.clone());
5196
5197                if let Some(token) = token.as_ref() {
5198                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5199                }
5200
5201                let request = req_builder
5202                    .header(CONTENT_TYPE, json_mime_type.to_string())
5203                    .header(CONTENT_LENGTH, request_size as u64)
5204                    .body(common::to_body(
5205                        request_value_reader.get_ref().clone().into(),
5206                    ));
5207
5208                client.request(request.unwrap()).await
5209            };
5210
5211            match req_result {
5212                Err(err) => {
5213                    if let common::Retry::After(d) = dlg.http_error(&err) {
5214                        sleep(d).await;
5215                        continue;
5216                    }
5217                    dlg.finished(false);
5218                    return Err(common::Error::HttpError(err));
5219                }
5220                Ok(res) => {
5221                    let (mut parts, body) = res.into_parts();
5222                    let mut body = common::Body::new(body);
5223                    if !parts.status.is_success() {
5224                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5225                        let error = serde_json::from_str(&common::to_string(&bytes));
5226                        let response = common::to_response(parts, bytes.into());
5227
5228                        if let common::Retry::After(d) =
5229                            dlg.http_failure(&response, error.as_ref().ok())
5230                        {
5231                            sleep(d).await;
5232                            continue;
5233                        }
5234
5235                        dlg.finished(false);
5236
5237                        return Err(match error {
5238                            Ok(value) => common::Error::BadRequest(value),
5239                            _ => common::Error::Failure(response),
5240                        });
5241                    }
5242                    let response = {
5243                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5244                        let encoded = common::to_string(&bytes);
5245                        match serde_json::from_str(&encoded) {
5246                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5247                            Err(error) => {
5248                                dlg.response_json_decode_error(&encoded, &error);
5249                                return Err(common::Error::JsonDecodeError(
5250                                    encoded.to_string(),
5251                                    error,
5252                                ));
5253                            }
5254                        }
5255                    };
5256
5257                    dlg.finished(true);
5258                    return Ok(response);
5259                }
5260            }
5261        }
5262    }
5263
5264    ///
5265    /// Sets the *request* property to the given value.
5266    ///
5267    /// Even though the property as already been set when instantiating this call,
5268    /// we provide this method for API completeness.
5269    pub fn request(
5270        mut self,
5271        new_value: GetIamPolicyRequest,
5272    ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5273        self._request = new_value;
5274        self
5275    }
5276    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5277    ///
5278    /// Sets the *resource* path property to the given value.
5279    ///
5280    /// Even though the property as already been set when instantiating this call,
5281    /// we provide this method for API completeness.
5282    pub fn resource(
5283        mut self,
5284        new_value: &str,
5285    ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5286        self._resource = new_value.to_string();
5287        self
5288    }
5289    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5290    /// while executing the actual API request.
5291    ///
5292    /// ````text
5293    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5294    /// ````
5295    ///
5296    /// Sets the *delegate* property to the given value.
5297    pub fn delegate(
5298        mut self,
5299        new_value: &'a mut dyn common::Delegate,
5300    ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5301        self._delegate = Some(new_value);
5302        self
5303    }
5304
5305    /// Set any additional parameter of the query string used in the request.
5306    /// It should be used to set parameters which are not yet available through their own
5307    /// setters.
5308    ///
5309    /// Please note that this method must not be used to set any of the known parameters
5310    /// which have their own setter method. If done anyway, the request will fail.
5311    ///
5312    /// # Additional Parameters
5313    ///
5314    /// * *$.xgafv* (query-string) - V1 error format.
5315    /// * *access_token* (query-string) - OAuth access token.
5316    /// * *alt* (query-string) - Data format for response.
5317    /// * *callback* (query-string) - JSONP
5318    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5319    /// * *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.
5320    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5321    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5322    /// * *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.
5323    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5324    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5325    pub fn param<T>(
5326        mut self,
5327        name: T,
5328        value: T,
5329    ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5330    where
5331        T: AsRef<str>,
5332    {
5333        self._additional_params
5334            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5335        self
5336    }
5337
5338    /// Identifies the authorization scope for the method you are building.
5339    ///
5340    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5341    /// [`Scope::CloudPlatform`].
5342    ///
5343    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5344    /// tokens for more than one scope.
5345    ///
5346    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5347    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5348    /// sufficient, a read-write scope will do as well.
5349    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5350    where
5351        St: AsRef<str>,
5352    {
5353        self._scopes.insert(String::from(scope.as_ref()));
5354        self
5355    }
5356    /// Identifies the authorization scope(s) for the method you are building.
5357    ///
5358    /// See [`Self::add_scope()`] for details.
5359    pub fn add_scopes<I, St>(
5360        mut self,
5361        scopes: I,
5362    ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5363    where
5364        I: IntoIterator<Item = St>,
5365        St: AsRef<str>,
5366    {
5367        self._scopes
5368            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5369        self
5370    }
5371
5372    /// Removes all scopes, and no default scope will be used either.
5373    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5374    /// for details).
5375    pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5376        self._scopes.clear();
5377        self
5378    }
5379}
5380
5381/// Sets the access control policy on the specified resource. Replaces any existing policy.
5382///
5383/// A builder for the *locations.registries.groups.setIamPolicy* method supported by a *project* resource.
5384/// It is not used directly, but through a [`ProjectMethods`] instance.
5385///
5386/// # Example
5387///
5388/// Instantiate a resource method builder
5389///
5390/// ```test_harness,no_run
5391/// # extern crate hyper;
5392/// # extern crate hyper_rustls;
5393/// # extern crate google_cloudiot1 as cloudiot1;
5394/// use cloudiot1::api::SetIamPolicyRequest;
5395/// # async fn dox() {
5396/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5397///
5398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5400/// #     .with_native_roots()
5401/// #     .unwrap()
5402/// #     .https_only()
5403/// #     .enable_http2()
5404/// #     .build();
5405///
5406/// # let executor = hyper_util::rt::TokioExecutor::new();
5407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5408/// #     secret,
5409/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5410/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5411/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5412/// #     ),
5413/// # ).build().await.unwrap();
5414///
5415/// # let client = hyper_util::client::legacy::Client::builder(
5416/// #     hyper_util::rt::TokioExecutor::new()
5417/// # )
5418/// # .build(
5419/// #     hyper_rustls::HttpsConnectorBuilder::new()
5420/// #         .with_native_roots()
5421/// #         .unwrap()
5422/// #         .https_or_http()
5423/// #         .enable_http2()
5424/// #         .build()
5425/// # );
5426/// # let mut hub = CloudIot::new(client, auth);
5427/// // As the method needs a request, you would usually fill it with the desired information
5428/// // into the respective structure. Some of the parts shown here might not be applicable !
5429/// // Values shown here are possibly random and not representative !
5430/// let mut req = SetIamPolicyRequest::default();
5431///
5432/// // You can configure optional parameters by calling the respective setters at will, and
5433/// // execute the final call using `doit()`.
5434/// // Values shown here are possibly random and not representative !
5435/// let result = hub.projects().locations_registries_groups_set_iam_policy(req, "resource")
5436///              .doit().await;
5437/// # }
5438/// ```
5439pub struct ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5440where
5441    C: 'a,
5442{
5443    hub: &'a CloudIot<C>,
5444    _request: SetIamPolicyRequest,
5445    _resource: String,
5446    _delegate: Option<&'a mut dyn common::Delegate>,
5447    _additional_params: HashMap<String, String>,
5448    _scopes: BTreeSet<String>,
5449}
5450
5451impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {}
5452
5453impl<'a, C> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5454where
5455    C: common::Connector,
5456{
5457    /// Perform the operation you have build so far.
5458    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5459        use std::borrow::Cow;
5460        use std::io::{Read, Seek};
5461
5462        use common::{url::Params, ToParts};
5463        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5464
5465        let mut dd = common::DefaultDelegate;
5466        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5467        dlg.begin(common::MethodInfo {
5468            id: "cloudiot.projects.locations.registries.groups.setIamPolicy",
5469            http_method: hyper::Method::POST,
5470        });
5471
5472        for &field in ["alt", "resource"].iter() {
5473            if self._additional_params.contains_key(field) {
5474                dlg.finished(false);
5475                return Err(common::Error::FieldClash(field));
5476            }
5477        }
5478
5479        let mut params = Params::with_capacity(4 + self._additional_params.len());
5480        params.push("resource", self._resource);
5481
5482        params.extend(self._additional_params.iter());
5483
5484        params.push("alt", "json");
5485        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
5486        if self._scopes.is_empty() {
5487            self._scopes
5488                .insert(Scope::CloudPlatform.as_ref().to_string());
5489        }
5490
5491        #[allow(clippy::single_element_loop)]
5492        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5493            url = params.uri_replacement(url, param_name, find_this, true);
5494        }
5495        {
5496            let to_remove = ["resource"];
5497            params.remove_params(&to_remove);
5498        }
5499
5500        let url = params.parse_with_url(&url);
5501
5502        let mut json_mime_type = mime::APPLICATION_JSON;
5503        let mut request_value_reader = {
5504            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5505            common::remove_json_null_values(&mut value);
5506            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5507            serde_json::to_writer(&mut dst, &value).unwrap();
5508            dst
5509        };
5510        let request_size = request_value_reader
5511            .seek(std::io::SeekFrom::End(0))
5512            .unwrap();
5513        request_value_reader
5514            .seek(std::io::SeekFrom::Start(0))
5515            .unwrap();
5516
5517        loop {
5518            let token = match self
5519                .hub
5520                .auth
5521                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5522                .await
5523            {
5524                Ok(token) => token,
5525                Err(e) => match dlg.token(e) {
5526                    Ok(token) => token,
5527                    Err(e) => {
5528                        dlg.finished(false);
5529                        return Err(common::Error::MissingToken(e));
5530                    }
5531                },
5532            };
5533            request_value_reader
5534                .seek(std::io::SeekFrom::Start(0))
5535                .unwrap();
5536            let mut req_result = {
5537                let client = &self.hub.client;
5538                dlg.pre_request();
5539                let mut req_builder = hyper::Request::builder()
5540                    .method(hyper::Method::POST)
5541                    .uri(url.as_str())
5542                    .header(USER_AGENT, self.hub._user_agent.clone());
5543
5544                if let Some(token) = token.as_ref() {
5545                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5546                }
5547
5548                let request = req_builder
5549                    .header(CONTENT_TYPE, json_mime_type.to_string())
5550                    .header(CONTENT_LENGTH, request_size as u64)
5551                    .body(common::to_body(
5552                        request_value_reader.get_ref().clone().into(),
5553                    ));
5554
5555                client.request(request.unwrap()).await
5556            };
5557
5558            match req_result {
5559                Err(err) => {
5560                    if let common::Retry::After(d) = dlg.http_error(&err) {
5561                        sleep(d).await;
5562                        continue;
5563                    }
5564                    dlg.finished(false);
5565                    return Err(common::Error::HttpError(err));
5566                }
5567                Ok(res) => {
5568                    let (mut parts, body) = res.into_parts();
5569                    let mut body = common::Body::new(body);
5570                    if !parts.status.is_success() {
5571                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5572                        let error = serde_json::from_str(&common::to_string(&bytes));
5573                        let response = common::to_response(parts, bytes.into());
5574
5575                        if let common::Retry::After(d) =
5576                            dlg.http_failure(&response, error.as_ref().ok())
5577                        {
5578                            sleep(d).await;
5579                            continue;
5580                        }
5581
5582                        dlg.finished(false);
5583
5584                        return Err(match error {
5585                            Ok(value) => common::Error::BadRequest(value),
5586                            _ => common::Error::Failure(response),
5587                        });
5588                    }
5589                    let response = {
5590                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5591                        let encoded = common::to_string(&bytes);
5592                        match serde_json::from_str(&encoded) {
5593                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5594                            Err(error) => {
5595                                dlg.response_json_decode_error(&encoded, &error);
5596                                return Err(common::Error::JsonDecodeError(
5597                                    encoded.to_string(),
5598                                    error,
5599                                ));
5600                            }
5601                        }
5602                    };
5603
5604                    dlg.finished(true);
5605                    return Ok(response);
5606                }
5607            }
5608        }
5609    }
5610
5611    ///
5612    /// Sets the *request* property to the given value.
5613    ///
5614    /// Even though the property as already been set when instantiating this call,
5615    /// we provide this method for API completeness.
5616    pub fn request(
5617        mut self,
5618        new_value: SetIamPolicyRequest,
5619    ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5620        self._request = new_value;
5621        self
5622    }
5623    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5624    ///
5625    /// Sets the *resource* path property to the given value.
5626    ///
5627    /// Even though the property as already been set when instantiating this call,
5628    /// we provide this method for API completeness.
5629    pub fn resource(
5630        mut self,
5631        new_value: &str,
5632    ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5633        self._resource = new_value.to_string();
5634        self
5635    }
5636    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5637    /// while executing the actual API request.
5638    ///
5639    /// ````text
5640    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5641    /// ````
5642    ///
5643    /// Sets the *delegate* property to the given value.
5644    pub fn delegate(
5645        mut self,
5646        new_value: &'a mut dyn common::Delegate,
5647    ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5648        self._delegate = Some(new_value);
5649        self
5650    }
5651
5652    /// Set any additional parameter of the query string used in the request.
5653    /// It should be used to set parameters which are not yet available through their own
5654    /// setters.
5655    ///
5656    /// Please note that this method must not be used to set any of the known parameters
5657    /// which have their own setter method. If done anyway, the request will fail.
5658    ///
5659    /// # Additional Parameters
5660    ///
5661    /// * *$.xgafv* (query-string) - V1 error format.
5662    /// * *access_token* (query-string) - OAuth access token.
5663    /// * *alt* (query-string) - Data format for response.
5664    /// * *callback* (query-string) - JSONP
5665    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5666    /// * *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.
5667    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5668    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5669    /// * *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.
5670    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5671    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5672    pub fn param<T>(
5673        mut self,
5674        name: T,
5675        value: T,
5676    ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5677    where
5678        T: AsRef<str>,
5679    {
5680        self._additional_params
5681            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5682        self
5683    }
5684
5685    /// Identifies the authorization scope for the method you are building.
5686    ///
5687    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5688    /// [`Scope::CloudPlatform`].
5689    ///
5690    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5691    /// tokens for more than one scope.
5692    ///
5693    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5694    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5695    /// sufficient, a read-write scope will do as well.
5696    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5697    where
5698        St: AsRef<str>,
5699    {
5700        self._scopes.insert(String::from(scope.as_ref()));
5701        self
5702    }
5703    /// Identifies the authorization scope(s) for the method you are building.
5704    ///
5705    /// See [`Self::add_scope()`] for details.
5706    pub fn add_scopes<I, St>(
5707        mut self,
5708        scopes: I,
5709    ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5710    where
5711        I: IntoIterator<Item = St>,
5712        St: AsRef<str>,
5713    {
5714        self._scopes
5715            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5716        self
5717    }
5718
5719    /// Removes all scopes, and no default scope will be used either.
5720    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5721    /// for details).
5722    pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5723        self._scopes.clear();
5724        self
5725    }
5726}
5727
5728/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
5729///
5730/// A builder for the *locations.registries.groups.testIamPermissions* method supported by a *project* resource.
5731/// It is not used directly, but through a [`ProjectMethods`] instance.
5732///
5733/// # Example
5734///
5735/// Instantiate a resource method builder
5736///
5737/// ```test_harness,no_run
5738/// # extern crate hyper;
5739/// # extern crate hyper_rustls;
5740/// # extern crate google_cloudiot1 as cloudiot1;
5741/// use cloudiot1::api::TestIamPermissionsRequest;
5742/// # async fn dox() {
5743/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5744///
5745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5746/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5747/// #     .with_native_roots()
5748/// #     .unwrap()
5749/// #     .https_only()
5750/// #     .enable_http2()
5751/// #     .build();
5752///
5753/// # let executor = hyper_util::rt::TokioExecutor::new();
5754/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5755/// #     secret,
5756/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5757/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5758/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5759/// #     ),
5760/// # ).build().await.unwrap();
5761///
5762/// # let client = hyper_util::client::legacy::Client::builder(
5763/// #     hyper_util::rt::TokioExecutor::new()
5764/// # )
5765/// # .build(
5766/// #     hyper_rustls::HttpsConnectorBuilder::new()
5767/// #         .with_native_roots()
5768/// #         .unwrap()
5769/// #         .https_or_http()
5770/// #         .enable_http2()
5771/// #         .build()
5772/// # );
5773/// # let mut hub = CloudIot::new(client, auth);
5774/// // As the method needs a request, you would usually fill it with the desired information
5775/// // into the respective structure. Some of the parts shown here might not be applicable !
5776/// // Values shown here are possibly random and not representative !
5777/// let mut req = TestIamPermissionsRequest::default();
5778///
5779/// // You can configure optional parameters by calling the respective setters at will, and
5780/// // execute the final call using `doit()`.
5781/// // Values shown here are possibly random and not representative !
5782/// let result = hub.projects().locations_registries_groups_test_iam_permissions(req, "resource")
5783///              .doit().await;
5784/// # }
5785/// ```
5786pub struct ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
5787where
5788    C: 'a,
5789{
5790    hub: &'a CloudIot<C>,
5791    _request: TestIamPermissionsRequest,
5792    _resource: String,
5793    _delegate: Option<&'a mut dyn common::Delegate>,
5794    _additional_params: HashMap<String, String>,
5795    _scopes: BTreeSet<String>,
5796}
5797
5798impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {}
5799
5800impl<'a, C> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
5801where
5802    C: common::Connector,
5803{
5804    /// Perform the operation you have build so far.
5805    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
5806        use std::borrow::Cow;
5807        use std::io::{Read, Seek};
5808
5809        use common::{url::Params, ToParts};
5810        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5811
5812        let mut dd = common::DefaultDelegate;
5813        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5814        dlg.begin(common::MethodInfo {
5815            id: "cloudiot.projects.locations.registries.groups.testIamPermissions",
5816            http_method: hyper::Method::POST,
5817        });
5818
5819        for &field in ["alt", "resource"].iter() {
5820            if self._additional_params.contains_key(field) {
5821                dlg.finished(false);
5822                return Err(common::Error::FieldClash(field));
5823            }
5824        }
5825
5826        let mut params = Params::with_capacity(4 + self._additional_params.len());
5827        params.push("resource", self._resource);
5828
5829        params.extend(self._additional_params.iter());
5830
5831        params.push("alt", "json");
5832        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
5833        if self._scopes.is_empty() {
5834            self._scopes
5835                .insert(Scope::CloudPlatform.as_ref().to_string());
5836        }
5837
5838        #[allow(clippy::single_element_loop)]
5839        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5840            url = params.uri_replacement(url, param_name, find_this, true);
5841        }
5842        {
5843            let to_remove = ["resource"];
5844            params.remove_params(&to_remove);
5845        }
5846
5847        let url = params.parse_with_url(&url);
5848
5849        let mut json_mime_type = mime::APPLICATION_JSON;
5850        let mut request_value_reader = {
5851            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5852            common::remove_json_null_values(&mut value);
5853            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5854            serde_json::to_writer(&mut dst, &value).unwrap();
5855            dst
5856        };
5857        let request_size = request_value_reader
5858            .seek(std::io::SeekFrom::End(0))
5859            .unwrap();
5860        request_value_reader
5861            .seek(std::io::SeekFrom::Start(0))
5862            .unwrap();
5863
5864        loop {
5865            let token = match self
5866                .hub
5867                .auth
5868                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5869                .await
5870            {
5871                Ok(token) => token,
5872                Err(e) => match dlg.token(e) {
5873                    Ok(token) => token,
5874                    Err(e) => {
5875                        dlg.finished(false);
5876                        return Err(common::Error::MissingToken(e));
5877                    }
5878                },
5879            };
5880            request_value_reader
5881                .seek(std::io::SeekFrom::Start(0))
5882                .unwrap();
5883            let mut req_result = {
5884                let client = &self.hub.client;
5885                dlg.pre_request();
5886                let mut req_builder = hyper::Request::builder()
5887                    .method(hyper::Method::POST)
5888                    .uri(url.as_str())
5889                    .header(USER_AGENT, self.hub._user_agent.clone());
5890
5891                if let Some(token) = token.as_ref() {
5892                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5893                }
5894
5895                let request = req_builder
5896                    .header(CONTENT_TYPE, json_mime_type.to_string())
5897                    .header(CONTENT_LENGTH, request_size as u64)
5898                    .body(common::to_body(
5899                        request_value_reader.get_ref().clone().into(),
5900                    ));
5901
5902                client.request(request.unwrap()).await
5903            };
5904
5905            match req_result {
5906                Err(err) => {
5907                    if let common::Retry::After(d) = dlg.http_error(&err) {
5908                        sleep(d).await;
5909                        continue;
5910                    }
5911                    dlg.finished(false);
5912                    return Err(common::Error::HttpError(err));
5913                }
5914                Ok(res) => {
5915                    let (mut parts, body) = res.into_parts();
5916                    let mut body = common::Body::new(body);
5917                    if !parts.status.is_success() {
5918                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5919                        let error = serde_json::from_str(&common::to_string(&bytes));
5920                        let response = common::to_response(parts, bytes.into());
5921
5922                        if let common::Retry::After(d) =
5923                            dlg.http_failure(&response, error.as_ref().ok())
5924                        {
5925                            sleep(d).await;
5926                            continue;
5927                        }
5928
5929                        dlg.finished(false);
5930
5931                        return Err(match error {
5932                            Ok(value) => common::Error::BadRequest(value),
5933                            _ => common::Error::Failure(response),
5934                        });
5935                    }
5936                    let response = {
5937                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5938                        let encoded = common::to_string(&bytes);
5939                        match serde_json::from_str(&encoded) {
5940                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5941                            Err(error) => {
5942                                dlg.response_json_decode_error(&encoded, &error);
5943                                return Err(common::Error::JsonDecodeError(
5944                                    encoded.to_string(),
5945                                    error,
5946                                ));
5947                            }
5948                        }
5949                    };
5950
5951                    dlg.finished(true);
5952                    return Ok(response);
5953                }
5954            }
5955        }
5956    }
5957
5958    ///
5959    /// Sets the *request* property to the given value.
5960    ///
5961    /// Even though the property as already been set when instantiating this call,
5962    /// we provide this method for API completeness.
5963    pub fn request(
5964        mut self,
5965        new_value: TestIamPermissionsRequest,
5966    ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
5967        self._request = new_value;
5968        self
5969    }
5970    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5971    ///
5972    /// Sets the *resource* path property to the given value.
5973    ///
5974    /// Even though the property as already been set when instantiating this call,
5975    /// we provide this method for API completeness.
5976    pub fn resource(
5977        mut self,
5978        new_value: &str,
5979    ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
5980        self._resource = new_value.to_string();
5981        self
5982    }
5983    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5984    /// while executing the actual API request.
5985    ///
5986    /// ````text
5987    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5988    /// ````
5989    ///
5990    /// Sets the *delegate* property to the given value.
5991    pub fn delegate(
5992        mut self,
5993        new_value: &'a mut dyn common::Delegate,
5994    ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
5995        self._delegate = Some(new_value);
5996        self
5997    }
5998
5999    /// Set any additional parameter of the query string used in the request.
6000    /// It should be used to set parameters which are not yet available through their own
6001    /// setters.
6002    ///
6003    /// Please note that this method must not be used to set any of the known parameters
6004    /// which have their own setter method. If done anyway, the request will fail.
6005    ///
6006    /// # Additional Parameters
6007    ///
6008    /// * *$.xgafv* (query-string) - V1 error format.
6009    /// * *access_token* (query-string) - OAuth access token.
6010    /// * *alt* (query-string) - Data format for response.
6011    /// * *callback* (query-string) - JSONP
6012    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6013    /// * *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.
6014    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6015    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6016    /// * *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.
6017    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6018    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6019    pub fn param<T>(
6020        mut self,
6021        name: T,
6022        value: T,
6023    ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
6024    where
6025        T: AsRef<str>,
6026    {
6027        self._additional_params
6028            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6029        self
6030    }
6031
6032    /// Identifies the authorization scope for the method you are building.
6033    ///
6034    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6035    /// [`Scope::CloudPlatform`].
6036    ///
6037    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6038    /// tokens for more than one scope.
6039    ///
6040    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6041    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6042    /// sufficient, a read-write scope will do as well.
6043    pub fn add_scope<St>(
6044        mut self,
6045        scope: St,
6046    ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
6047    where
6048        St: AsRef<str>,
6049    {
6050        self._scopes.insert(String::from(scope.as_ref()));
6051        self
6052    }
6053    /// Identifies the authorization scope(s) for the method you are building.
6054    ///
6055    /// See [`Self::add_scope()`] for details.
6056    pub fn add_scopes<I, St>(
6057        mut self,
6058        scopes: I,
6059    ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
6060    where
6061        I: IntoIterator<Item = St>,
6062        St: AsRef<str>,
6063    {
6064        self._scopes
6065            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6066        self
6067    }
6068
6069    /// Removes all scopes, and no default scope will be used either.
6070    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6071    /// for details).
6072    pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
6073        self._scopes.clear();
6074        self
6075    }
6076}
6077
6078/// Associates the device with the gateway.
6079///
6080/// A builder for the *locations.registries.bindDeviceToGateway* method supported by a *project* resource.
6081/// It is not used directly, but through a [`ProjectMethods`] instance.
6082///
6083/// # Example
6084///
6085/// Instantiate a resource method builder
6086///
6087/// ```test_harness,no_run
6088/// # extern crate hyper;
6089/// # extern crate hyper_rustls;
6090/// # extern crate google_cloudiot1 as cloudiot1;
6091/// use cloudiot1::api::BindDeviceToGatewayRequest;
6092/// # async fn dox() {
6093/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6094///
6095/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6096/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6097/// #     .with_native_roots()
6098/// #     .unwrap()
6099/// #     .https_only()
6100/// #     .enable_http2()
6101/// #     .build();
6102///
6103/// # let executor = hyper_util::rt::TokioExecutor::new();
6104/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6105/// #     secret,
6106/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6107/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6108/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6109/// #     ),
6110/// # ).build().await.unwrap();
6111///
6112/// # let client = hyper_util::client::legacy::Client::builder(
6113/// #     hyper_util::rt::TokioExecutor::new()
6114/// # )
6115/// # .build(
6116/// #     hyper_rustls::HttpsConnectorBuilder::new()
6117/// #         .with_native_roots()
6118/// #         .unwrap()
6119/// #         .https_or_http()
6120/// #         .enable_http2()
6121/// #         .build()
6122/// # );
6123/// # let mut hub = CloudIot::new(client, auth);
6124/// // As the method needs a request, you would usually fill it with the desired information
6125/// // into the respective structure. Some of the parts shown here might not be applicable !
6126/// // Values shown here are possibly random and not representative !
6127/// let mut req = BindDeviceToGatewayRequest::default();
6128///
6129/// // You can configure optional parameters by calling the respective setters at will, and
6130/// // execute the final call using `doit()`.
6131/// // Values shown here are possibly random and not representative !
6132/// let result = hub.projects().locations_registries_bind_device_to_gateway(req, "parent")
6133///              .doit().await;
6134/// # }
6135/// ```
6136pub struct ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6137where
6138    C: 'a,
6139{
6140    hub: &'a CloudIot<C>,
6141    _request: BindDeviceToGatewayRequest,
6142    _parent: String,
6143    _delegate: Option<&'a mut dyn common::Delegate>,
6144    _additional_params: HashMap<String, String>,
6145    _scopes: BTreeSet<String>,
6146}
6147
6148impl<'a, C> common::CallBuilder for ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {}
6149
6150impl<'a, C> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6151where
6152    C: common::Connector,
6153{
6154    /// Perform the operation you have build so far.
6155    pub async fn doit(mut self) -> common::Result<(common::Response, BindDeviceToGatewayResponse)> {
6156        use std::borrow::Cow;
6157        use std::io::{Read, Seek};
6158
6159        use common::{url::Params, ToParts};
6160        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6161
6162        let mut dd = common::DefaultDelegate;
6163        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6164        dlg.begin(common::MethodInfo {
6165            id: "cloudiot.projects.locations.registries.bindDeviceToGateway",
6166            http_method: hyper::Method::POST,
6167        });
6168
6169        for &field in ["alt", "parent"].iter() {
6170            if self._additional_params.contains_key(field) {
6171                dlg.finished(false);
6172                return Err(common::Error::FieldClash(field));
6173            }
6174        }
6175
6176        let mut params = Params::with_capacity(4 + self._additional_params.len());
6177        params.push("parent", self._parent);
6178
6179        params.extend(self._additional_params.iter());
6180
6181        params.push("alt", "json");
6182        let mut url = self.hub._base_url.clone() + "v1/{+parent}:bindDeviceToGateway";
6183        if self._scopes.is_empty() {
6184            self._scopes
6185                .insert(Scope::CloudPlatform.as_ref().to_string());
6186        }
6187
6188        #[allow(clippy::single_element_loop)]
6189        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6190            url = params.uri_replacement(url, param_name, find_this, true);
6191        }
6192        {
6193            let to_remove = ["parent"];
6194            params.remove_params(&to_remove);
6195        }
6196
6197        let url = params.parse_with_url(&url);
6198
6199        let mut json_mime_type = mime::APPLICATION_JSON;
6200        let mut request_value_reader = {
6201            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6202            common::remove_json_null_values(&mut value);
6203            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6204            serde_json::to_writer(&mut dst, &value).unwrap();
6205            dst
6206        };
6207        let request_size = request_value_reader
6208            .seek(std::io::SeekFrom::End(0))
6209            .unwrap();
6210        request_value_reader
6211            .seek(std::io::SeekFrom::Start(0))
6212            .unwrap();
6213
6214        loop {
6215            let token = match self
6216                .hub
6217                .auth
6218                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6219                .await
6220            {
6221                Ok(token) => token,
6222                Err(e) => match dlg.token(e) {
6223                    Ok(token) => token,
6224                    Err(e) => {
6225                        dlg.finished(false);
6226                        return Err(common::Error::MissingToken(e));
6227                    }
6228                },
6229            };
6230            request_value_reader
6231                .seek(std::io::SeekFrom::Start(0))
6232                .unwrap();
6233            let mut req_result = {
6234                let client = &self.hub.client;
6235                dlg.pre_request();
6236                let mut req_builder = hyper::Request::builder()
6237                    .method(hyper::Method::POST)
6238                    .uri(url.as_str())
6239                    .header(USER_AGENT, self.hub._user_agent.clone());
6240
6241                if let Some(token) = token.as_ref() {
6242                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6243                }
6244
6245                let request = req_builder
6246                    .header(CONTENT_TYPE, json_mime_type.to_string())
6247                    .header(CONTENT_LENGTH, request_size as u64)
6248                    .body(common::to_body(
6249                        request_value_reader.get_ref().clone().into(),
6250                    ));
6251
6252                client.request(request.unwrap()).await
6253            };
6254
6255            match req_result {
6256                Err(err) => {
6257                    if let common::Retry::After(d) = dlg.http_error(&err) {
6258                        sleep(d).await;
6259                        continue;
6260                    }
6261                    dlg.finished(false);
6262                    return Err(common::Error::HttpError(err));
6263                }
6264                Ok(res) => {
6265                    let (mut parts, body) = res.into_parts();
6266                    let mut body = common::Body::new(body);
6267                    if !parts.status.is_success() {
6268                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6269                        let error = serde_json::from_str(&common::to_string(&bytes));
6270                        let response = common::to_response(parts, bytes.into());
6271
6272                        if let common::Retry::After(d) =
6273                            dlg.http_failure(&response, error.as_ref().ok())
6274                        {
6275                            sleep(d).await;
6276                            continue;
6277                        }
6278
6279                        dlg.finished(false);
6280
6281                        return Err(match error {
6282                            Ok(value) => common::Error::BadRequest(value),
6283                            _ => common::Error::Failure(response),
6284                        });
6285                    }
6286                    let response = {
6287                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6288                        let encoded = common::to_string(&bytes);
6289                        match serde_json::from_str(&encoded) {
6290                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6291                            Err(error) => {
6292                                dlg.response_json_decode_error(&encoded, &error);
6293                                return Err(common::Error::JsonDecodeError(
6294                                    encoded.to_string(),
6295                                    error,
6296                                ));
6297                            }
6298                        }
6299                    };
6300
6301                    dlg.finished(true);
6302                    return Ok(response);
6303                }
6304            }
6305        }
6306    }
6307
6308    ///
6309    /// Sets the *request* property to the given value.
6310    ///
6311    /// Even though the property as already been set when instantiating this call,
6312    /// we provide this method for API completeness.
6313    pub fn request(
6314        mut self,
6315        new_value: BindDeviceToGatewayRequest,
6316    ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6317        self._request = new_value;
6318        self
6319    }
6320    /// Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
6321    ///
6322    /// Sets the *parent* path property to the given value.
6323    ///
6324    /// Even though the property as already been set when instantiating this call,
6325    /// we provide this method for API completeness.
6326    pub fn parent(
6327        mut self,
6328        new_value: &str,
6329    ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6330        self._parent = new_value.to_string();
6331        self
6332    }
6333    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6334    /// while executing the actual API request.
6335    ///
6336    /// ````text
6337    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6338    /// ````
6339    ///
6340    /// Sets the *delegate* property to the given value.
6341    pub fn delegate(
6342        mut self,
6343        new_value: &'a mut dyn common::Delegate,
6344    ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6345        self._delegate = Some(new_value);
6346        self
6347    }
6348
6349    /// Set any additional parameter of the query string used in the request.
6350    /// It should be used to set parameters which are not yet available through their own
6351    /// setters.
6352    ///
6353    /// Please note that this method must not be used to set any of the known parameters
6354    /// which have their own setter method. If done anyway, the request will fail.
6355    ///
6356    /// # Additional Parameters
6357    ///
6358    /// * *$.xgafv* (query-string) - V1 error format.
6359    /// * *access_token* (query-string) - OAuth access token.
6360    /// * *alt* (query-string) - Data format for response.
6361    /// * *callback* (query-string) - JSONP
6362    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6363    /// * *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.
6364    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6365    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6366    /// * *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.
6367    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6368    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6369    pub fn param<T>(
6370        mut self,
6371        name: T,
6372        value: T,
6373    ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6374    where
6375        T: AsRef<str>,
6376    {
6377        self._additional_params
6378            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6379        self
6380    }
6381
6382    /// Identifies the authorization scope for the method you are building.
6383    ///
6384    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6385    /// [`Scope::CloudPlatform`].
6386    ///
6387    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6388    /// tokens for more than one scope.
6389    ///
6390    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6391    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6392    /// sufficient, a read-write scope will do as well.
6393    pub fn add_scope<St>(
6394        mut self,
6395        scope: St,
6396    ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6397    where
6398        St: AsRef<str>,
6399    {
6400        self._scopes.insert(String::from(scope.as_ref()));
6401        self
6402    }
6403    /// Identifies the authorization scope(s) for the method you are building.
6404    ///
6405    /// See [`Self::add_scope()`] for details.
6406    pub fn add_scopes<I, St>(
6407        mut self,
6408        scopes: I,
6409    ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6410    where
6411        I: IntoIterator<Item = St>,
6412        St: AsRef<str>,
6413    {
6414        self._scopes
6415            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6416        self
6417    }
6418
6419    /// Removes all scopes, and no default scope will be used either.
6420    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6421    /// for details).
6422    pub fn clear_scopes(mut self) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6423        self._scopes.clear();
6424        self
6425    }
6426}
6427
6428/// Creates a device registry that contains devices.
6429///
6430/// A builder for the *locations.registries.create* method supported by a *project* resource.
6431/// It is not used directly, but through a [`ProjectMethods`] instance.
6432///
6433/// # Example
6434///
6435/// Instantiate a resource method builder
6436///
6437/// ```test_harness,no_run
6438/// # extern crate hyper;
6439/// # extern crate hyper_rustls;
6440/// # extern crate google_cloudiot1 as cloudiot1;
6441/// use cloudiot1::api::DeviceRegistry;
6442/// # async fn dox() {
6443/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6444///
6445/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6446/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6447/// #     .with_native_roots()
6448/// #     .unwrap()
6449/// #     .https_only()
6450/// #     .enable_http2()
6451/// #     .build();
6452///
6453/// # let executor = hyper_util::rt::TokioExecutor::new();
6454/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6455/// #     secret,
6456/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6457/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6458/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6459/// #     ),
6460/// # ).build().await.unwrap();
6461///
6462/// # let client = hyper_util::client::legacy::Client::builder(
6463/// #     hyper_util::rt::TokioExecutor::new()
6464/// # )
6465/// # .build(
6466/// #     hyper_rustls::HttpsConnectorBuilder::new()
6467/// #         .with_native_roots()
6468/// #         .unwrap()
6469/// #         .https_or_http()
6470/// #         .enable_http2()
6471/// #         .build()
6472/// # );
6473/// # let mut hub = CloudIot::new(client, auth);
6474/// // As the method needs a request, you would usually fill it with the desired information
6475/// // into the respective structure. Some of the parts shown here might not be applicable !
6476/// // Values shown here are possibly random and not representative !
6477/// let mut req = DeviceRegistry::default();
6478///
6479/// // You can configure optional parameters by calling the respective setters at will, and
6480/// // execute the final call using `doit()`.
6481/// // Values shown here are possibly random and not representative !
6482/// let result = hub.projects().locations_registries_create(req, "parent")
6483///              .doit().await;
6484/// # }
6485/// ```
6486pub struct ProjectLocationRegistryCreateCall<'a, C>
6487where
6488    C: 'a,
6489{
6490    hub: &'a CloudIot<C>,
6491    _request: DeviceRegistry,
6492    _parent: String,
6493    _delegate: Option<&'a mut dyn common::Delegate>,
6494    _additional_params: HashMap<String, String>,
6495    _scopes: BTreeSet<String>,
6496}
6497
6498impl<'a, C> common::CallBuilder for ProjectLocationRegistryCreateCall<'a, C> {}
6499
6500impl<'a, C> ProjectLocationRegistryCreateCall<'a, C>
6501where
6502    C: common::Connector,
6503{
6504    /// Perform the operation you have build so far.
6505    pub async fn doit(mut self) -> common::Result<(common::Response, DeviceRegistry)> {
6506        use std::borrow::Cow;
6507        use std::io::{Read, Seek};
6508
6509        use common::{url::Params, ToParts};
6510        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6511
6512        let mut dd = common::DefaultDelegate;
6513        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6514        dlg.begin(common::MethodInfo {
6515            id: "cloudiot.projects.locations.registries.create",
6516            http_method: hyper::Method::POST,
6517        });
6518
6519        for &field in ["alt", "parent"].iter() {
6520            if self._additional_params.contains_key(field) {
6521                dlg.finished(false);
6522                return Err(common::Error::FieldClash(field));
6523            }
6524        }
6525
6526        let mut params = Params::with_capacity(4 + self._additional_params.len());
6527        params.push("parent", self._parent);
6528
6529        params.extend(self._additional_params.iter());
6530
6531        params.push("alt", "json");
6532        let mut url = self.hub._base_url.clone() + "v1/{+parent}/registries";
6533        if self._scopes.is_empty() {
6534            self._scopes
6535                .insert(Scope::CloudPlatform.as_ref().to_string());
6536        }
6537
6538        #[allow(clippy::single_element_loop)]
6539        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6540            url = params.uri_replacement(url, param_name, find_this, true);
6541        }
6542        {
6543            let to_remove = ["parent"];
6544            params.remove_params(&to_remove);
6545        }
6546
6547        let url = params.parse_with_url(&url);
6548
6549        let mut json_mime_type = mime::APPLICATION_JSON;
6550        let mut request_value_reader = {
6551            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6552            common::remove_json_null_values(&mut value);
6553            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6554            serde_json::to_writer(&mut dst, &value).unwrap();
6555            dst
6556        };
6557        let request_size = request_value_reader
6558            .seek(std::io::SeekFrom::End(0))
6559            .unwrap();
6560        request_value_reader
6561            .seek(std::io::SeekFrom::Start(0))
6562            .unwrap();
6563
6564        loop {
6565            let token = match self
6566                .hub
6567                .auth
6568                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6569                .await
6570            {
6571                Ok(token) => token,
6572                Err(e) => match dlg.token(e) {
6573                    Ok(token) => token,
6574                    Err(e) => {
6575                        dlg.finished(false);
6576                        return Err(common::Error::MissingToken(e));
6577                    }
6578                },
6579            };
6580            request_value_reader
6581                .seek(std::io::SeekFrom::Start(0))
6582                .unwrap();
6583            let mut req_result = {
6584                let client = &self.hub.client;
6585                dlg.pre_request();
6586                let mut req_builder = hyper::Request::builder()
6587                    .method(hyper::Method::POST)
6588                    .uri(url.as_str())
6589                    .header(USER_AGENT, self.hub._user_agent.clone());
6590
6591                if let Some(token) = token.as_ref() {
6592                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6593                }
6594
6595                let request = req_builder
6596                    .header(CONTENT_TYPE, json_mime_type.to_string())
6597                    .header(CONTENT_LENGTH, request_size as u64)
6598                    .body(common::to_body(
6599                        request_value_reader.get_ref().clone().into(),
6600                    ));
6601
6602                client.request(request.unwrap()).await
6603            };
6604
6605            match req_result {
6606                Err(err) => {
6607                    if let common::Retry::After(d) = dlg.http_error(&err) {
6608                        sleep(d).await;
6609                        continue;
6610                    }
6611                    dlg.finished(false);
6612                    return Err(common::Error::HttpError(err));
6613                }
6614                Ok(res) => {
6615                    let (mut parts, body) = res.into_parts();
6616                    let mut body = common::Body::new(body);
6617                    if !parts.status.is_success() {
6618                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6619                        let error = serde_json::from_str(&common::to_string(&bytes));
6620                        let response = common::to_response(parts, bytes.into());
6621
6622                        if let common::Retry::After(d) =
6623                            dlg.http_failure(&response, error.as_ref().ok())
6624                        {
6625                            sleep(d).await;
6626                            continue;
6627                        }
6628
6629                        dlg.finished(false);
6630
6631                        return Err(match error {
6632                            Ok(value) => common::Error::BadRequest(value),
6633                            _ => common::Error::Failure(response),
6634                        });
6635                    }
6636                    let response = {
6637                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6638                        let encoded = common::to_string(&bytes);
6639                        match serde_json::from_str(&encoded) {
6640                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6641                            Err(error) => {
6642                                dlg.response_json_decode_error(&encoded, &error);
6643                                return Err(common::Error::JsonDecodeError(
6644                                    encoded.to_string(),
6645                                    error,
6646                                ));
6647                            }
6648                        }
6649                    };
6650
6651                    dlg.finished(true);
6652                    return Ok(response);
6653                }
6654            }
6655        }
6656    }
6657
6658    ///
6659    /// Sets the *request* property to the given value.
6660    ///
6661    /// Even though the property as already been set when instantiating this call,
6662    /// we provide this method for API completeness.
6663    pub fn request(
6664        mut self,
6665        new_value: DeviceRegistry,
6666    ) -> ProjectLocationRegistryCreateCall<'a, C> {
6667        self._request = new_value;
6668        self
6669    }
6670    /// Required. The project and cloud region where this device registry must be created. For example, `projects/example-project/locations/us-central1`.
6671    ///
6672    /// Sets the *parent* path property to the given value.
6673    ///
6674    /// Even though the property as already been set when instantiating this call,
6675    /// we provide this method for API completeness.
6676    pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryCreateCall<'a, C> {
6677        self._parent = new_value.to_string();
6678        self
6679    }
6680    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6681    /// while executing the actual API request.
6682    ///
6683    /// ````text
6684    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6685    /// ````
6686    ///
6687    /// Sets the *delegate* property to the given value.
6688    pub fn delegate(
6689        mut self,
6690        new_value: &'a mut dyn common::Delegate,
6691    ) -> ProjectLocationRegistryCreateCall<'a, C> {
6692        self._delegate = Some(new_value);
6693        self
6694    }
6695
6696    /// Set any additional parameter of the query string used in the request.
6697    /// It should be used to set parameters which are not yet available through their own
6698    /// setters.
6699    ///
6700    /// Please note that this method must not be used to set any of the known parameters
6701    /// which have their own setter method. If done anyway, the request will fail.
6702    ///
6703    /// # Additional Parameters
6704    ///
6705    /// * *$.xgafv* (query-string) - V1 error format.
6706    /// * *access_token* (query-string) - OAuth access token.
6707    /// * *alt* (query-string) - Data format for response.
6708    /// * *callback* (query-string) - JSONP
6709    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6710    /// * *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.
6711    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6712    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6713    /// * *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.
6714    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6715    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6716    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryCreateCall<'a, C>
6717    where
6718        T: AsRef<str>,
6719    {
6720        self._additional_params
6721            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6722        self
6723    }
6724
6725    /// Identifies the authorization scope for the method you are building.
6726    ///
6727    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6728    /// [`Scope::CloudPlatform`].
6729    ///
6730    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6731    /// tokens for more than one scope.
6732    ///
6733    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6734    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6735    /// sufficient, a read-write scope will do as well.
6736    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryCreateCall<'a, C>
6737    where
6738        St: AsRef<str>,
6739    {
6740        self._scopes.insert(String::from(scope.as_ref()));
6741        self
6742    }
6743    /// Identifies the authorization scope(s) for the method you are building.
6744    ///
6745    /// See [`Self::add_scope()`] for details.
6746    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryCreateCall<'a, C>
6747    where
6748        I: IntoIterator<Item = St>,
6749        St: AsRef<str>,
6750    {
6751        self._scopes
6752            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6753        self
6754    }
6755
6756    /// Removes all scopes, and no default scope will be used either.
6757    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6758    /// for details).
6759    pub fn clear_scopes(mut self) -> ProjectLocationRegistryCreateCall<'a, C> {
6760        self._scopes.clear();
6761        self
6762    }
6763}
6764
6765/// Deletes a device registry configuration.
6766///
6767/// A builder for the *locations.registries.delete* method supported by a *project* resource.
6768/// It is not used directly, but through a [`ProjectMethods`] instance.
6769///
6770/// # Example
6771///
6772/// Instantiate a resource method builder
6773///
6774/// ```test_harness,no_run
6775/// # extern crate hyper;
6776/// # extern crate hyper_rustls;
6777/// # extern crate google_cloudiot1 as cloudiot1;
6778/// # async fn dox() {
6779/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6780///
6781/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6782/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6783/// #     .with_native_roots()
6784/// #     .unwrap()
6785/// #     .https_only()
6786/// #     .enable_http2()
6787/// #     .build();
6788///
6789/// # let executor = hyper_util::rt::TokioExecutor::new();
6790/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6791/// #     secret,
6792/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6793/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6794/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6795/// #     ),
6796/// # ).build().await.unwrap();
6797///
6798/// # let client = hyper_util::client::legacy::Client::builder(
6799/// #     hyper_util::rt::TokioExecutor::new()
6800/// # )
6801/// # .build(
6802/// #     hyper_rustls::HttpsConnectorBuilder::new()
6803/// #         .with_native_roots()
6804/// #         .unwrap()
6805/// #         .https_or_http()
6806/// #         .enable_http2()
6807/// #         .build()
6808/// # );
6809/// # let mut hub = CloudIot::new(client, auth);
6810/// // You can configure optional parameters by calling the respective setters at will, and
6811/// // execute the final call using `doit()`.
6812/// // Values shown here are possibly random and not representative !
6813/// let result = hub.projects().locations_registries_delete("name")
6814///              .doit().await;
6815/// # }
6816/// ```
6817pub struct ProjectLocationRegistryDeleteCall<'a, C>
6818where
6819    C: 'a,
6820{
6821    hub: &'a CloudIot<C>,
6822    _name: String,
6823    _delegate: Option<&'a mut dyn common::Delegate>,
6824    _additional_params: HashMap<String, String>,
6825    _scopes: BTreeSet<String>,
6826}
6827
6828impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeleteCall<'a, C> {}
6829
6830impl<'a, C> ProjectLocationRegistryDeleteCall<'a, C>
6831where
6832    C: common::Connector,
6833{
6834    /// Perform the operation you have build so far.
6835    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6836        use std::borrow::Cow;
6837        use std::io::{Read, Seek};
6838
6839        use common::{url::Params, ToParts};
6840        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6841
6842        let mut dd = common::DefaultDelegate;
6843        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6844        dlg.begin(common::MethodInfo {
6845            id: "cloudiot.projects.locations.registries.delete",
6846            http_method: hyper::Method::DELETE,
6847        });
6848
6849        for &field in ["alt", "name"].iter() {
6850            if self._additional_params.contains_key(field) {
6851                dlg.finished(false);
6852                return Err(common::Error::FieldClash(field));
6853            }
6854        }
6855
6856        let mut params = Params::with_capacity(3 + self._additional_params.len());
6857        params.push("name", self._name);
6858
6859        params.extend(self._additional_params.iter());
6860
6861        params.push("alt", "json");
6862        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6863        if self._scopes.is_empty() {
6864            self._scopes
6865                .insert(Scope::CloudPlatform.as_ref().to_string());
6866        }
6867
6868        #[allow(clippy::single_element_loop)]
6869        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6870            url = params.uri_replacement(url, param_name, find_this, true);
6871        }
6872        {
6873            let to_remove = ["name"];
6874            params.remove_params(&to_remove);
6875        }
6876
6877        let url = params.parse_with_url(&url);
6878
6879        loop {
6880            let token = match self
6881                .hub
6882                .auth
6883                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6884                .await
6885            {
6886                Ok(token) => token,
6887                Err(e) => match dlg.token(e) {
6888                    Ok(token) => token,
6889                    Err(e) => {
6890                        dlg.finished(false);
6891                        return Err(common::Error::MissingToken(e));
6892                    }
6893                },
6894            };
6895            let mut req_result = {
6896                let client = &self.hub.client;
6897                dlg.pre_request();
6898                let mut req_builder = hyper::Request::builder()
6899                    .method(hyper::Method::DELETE)
6900                    .uri(url.as_str())
6901                    .header(USER_AGENT, self.hub._user_agent.clone());
6902
6903                if let Some(token) = token.as_ref() {
6904                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6905                }
6906
6907                let request = req_builder
6908                    .header(CONTENT_LENGTH, 0_u64)
6909                    .body(common::to_body::<String>(None));
6910
6911                client.request(request.unwrap()).await
6912            };
6913
6914            match req_result {
6915                Err(err) => {
6916                    if let common::Retry::After(d) = dlg.http_error(&err) {
6917                        sleep(d).await;
6918                        continue;
6919                    }
6920                    dlg.finished(false);
6921                    return Err(common::Error::HttpError(err));
6922                }
6923                Ok(res) => {
6924                    let (mut parts, body) = res.into_parts();
6925                    let mut body = common::Body::new(body);
6926                    if !parts.status.is_success() {
6927                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6928                        let error = serde_json::from_str(&common::to_string(&bytes));
6929                        let response = common::to_response(parts, bytes.into());
6930
6931                        if let common::Retry::After(d) =
6932                            dlg.http_failure(&response, error.as_ref().ok())
6933                        {
6934                            sleep(d).await;
6935                            continue;
6936                        }
6937
6938                        dlg.finished(false);
6939
6940                        return Err(match error {
6941                            Ok(value) => common::Error::BadRequest(value),
6942                            _ => common::Error::Failure(response),
6943                        });
6944                    }
6945                    let response = {
6946                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6947                        let encoded = common::to_string(&bytes);
6948                        match serde_json::from_str(&encoded) {
6949                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6950                            Err(error) => {
6951                                dlg.response_json_decode_error(&encoded, &error);
6952                                return Err(common::Error::JsonDecodeError(
6953                                    encoded.to_string(),
6954                                    error,
6955                                ));
6956                            }
6957                        }
6958                    };
6959
6960                    dlg.finished(true);
6961                    return Ok(response);
6962                }
6963            }
6964        }
6965    }
6966
6967    /// Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
6968    ///
6969    /// Sets the *name* path property to the given value.
6970    ///
6971    /// Even though the property as already been set when instantiating this call,
6972    /// we provide this method for API completeness.
6973    pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeleteCall<'a, C> {
6974        self._name = new_value.to_string();
6975        self
6976    }
6977    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6978    /// while executing the actual API request.
6979    ///
6980    /// ````text
6981    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6982    /// ````
6983    ///
6984    /// Sets the *delegate* property to the given value.
6985    pub fn delegate(
6986        mut self,
6987        new_value: &'a mut dyn common::Delegate,
6988    ) -> ProjectLocationRegistryDeleteCall<'a, C> {
6989        self._delegate = Some(new_value);
6990        self
6991    }
6992
6993    /// Set any additional parameter of the query string used in the request.
6994    /// It should be used to set parameters which are not yet available through their own
6995    /// setters.
6996    ///
6997    /// Please note that this method must not be used to set any of the known parameters
6998    /// which have their own setter method. If done anyway, the request will fail.
6999    ///
7000    /// # Additional Parameters
7001    ///
7002    /// * *$.xgafv* (query-string) - V1 error format.
7003    /// * *access_token* (query-string) - OAuth access token.
7004    /// * *alt* (query-string) - Data format for response.
7005    /// * *callback* (query-string) - JSONP
7006    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7007    /// * *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.
7008    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7009    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7010    /// * *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.
7011    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7012    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7013    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeleteCall<'a, C>
7014    where
7015        T: AsRef<str>,
7016    {
7017        self._additional_params
7018            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7019        self
7020    }
7021
7022    /// Identifies the authorization scope for the method you are building.
7023    ///
7024    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7025    /// [`Scope::CloudPlatform`].
7026    ///
7027    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7028    /// tokens for more than one scope.
7029    ///
7030    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7031    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7032    /// sufficient, a read-write scope will do as well.
7033    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeleteCall<'a, C>
7034    where
7035        St: AsRef<str>,
7036    {
7037        self._scopes.insert(String::from(scope.as_ref()));
7038        self
7039    }
7040    /// Identifies the authorization scope(s) for the method you are building.
7041    ///
7042    /// See [`Self::add_scope()`] for details.
7043    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeleteCall<'a, C>
7044    where
7045        I: IntoIterator<Item = St>,
7046        St: AsRef<str>,
7047    {
7048        self._scopes
7049            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7050        self
7051    }
7052
7053    /// Removes all scopes, and no default scope will be used either.
7054    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7055    /// for details).
7056    pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeleteCall<'a, C> {
7057        self._scopes.clear();
7058        self
7059    }
7060}
7061
7062/// Gets a device registry configuration.
7063///
7064/// A builder for the *locations.registries.get* method supported by a *project* resource.
7065/// It is not used directly, but through a [`ProjectMethods`] instance.
7066///
7067/// # Example
7068///
7069/// Instantiate a resource method builder
7070///
7071/// ```test_harness,no_run
7072/// # extern crate hyper;
7073/// # extern crate hyper_rustls;
7074/// # extern crate google_cloudiot1 as cloudiot1;
7075/// # async fn dox() {
7076/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7077///
7078/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7079/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7080/// #     .with_native_roots()
7081/// #     .unwrap()
7082/// #     .https_only()
7083/// #     .enable_http2()
7084/// #     .build();
7085///
7086/// # let executor = hyper_util::rt::TokioExecutor::new();
7087/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7088/// #     secret,
7089/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7090/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7091/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7092/// #     ),
7093/// # ).build().await.unwrap();
7094///
7095/// # let client = hyper_util::client::legacy::Client::builder(
7096/// #     hyper_util::rt::TokioExecutor::new()
7097/// # )
7098/// # .build(
7099/// #     hyper_rustls::HttpsConnectorBuilder::new()
7100/// #         .with_native_roots()
7101/// #         .unwrap()
7102/// #         .https_or_http()
7103/// #         .enable_http2()
7104/// #         .build()
7105/// # );
7106/// # let mut hub = CloudIot::new(client, auth);
7107/// // You can configure optional parameters by calling the respective setters at will, and
7108/// // execute the final call using `doit()`.
7109/// // Values shown here are possibly random and not representative !
7110/// let result = hub.projects().locations_registries_get("name")
7111///              .doit().await;
7112/// # }
7113/// ```
7114pub struct ProjectLocationRegistryGetCall<'a, C>
7115where
7116    C: 'a,
7117{
7118    hub: &'a CloudIot<C>,
7119    _name: String,
7120    _delegate: Option<&'a mut dyn common::Delegate>,
7121    _additional_params: HashMap<String, String>,
7122    _scopes: BTreeSet<String>,
7123}
7124
7125impl<'a, C> common::CallBuilder for ProjectLocationRegistryGetCall<'a, C> {}
7126
7127impl<'a, C> ProjectLocationRegistryGetCall<'a, C>
7128where
7129    C: common::Connector,
7130{
7131    /// Perform the operation you have build so far.
7132    pub async fn doit(mut self) -> common::Result<(common::Response, DeviceRegistry)> {
7133        use std::borrow::Cow;
7134        use std::io::{Read, Seek};
7135
7136        use common::{url::Params, ToParts};
7137        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7138
7139        let mut dd = common::DefaultDelegate;
7140        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7141        dlg.begin(common::MethodInfo {
7142            id: "cloudiot.projects.locations.registries.get",
7143            http_method: hyper::Method::GET,
7144        });
7145
7146        for &field in ["alt", "name"].iter() {
7147            if self._additional_params.contains_key(field) {
7148                dlg.finished(false);
7149                return Err(common::Error::FieldClash(field));
7150            }
7151        }
7152
7153        let mut params = Params::with_capacity(3 + self._additional_params.len());
7154        params.push("name", self._name);
7155
7156        params.extend(self._additional_params.iter());
7157
7158        params.push("alt", "json");
7159        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7160        if self._scopes.is_empty() {
7161            self._scopes
7162                .insert(Scope::CloudPlatform.as_ref().to_string());
7163        }
7164
7165        #[allow(clippy::single_element_loop)]
7166        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7167            url = params.uri_replacement(url, param_name, find_this, true);
7168        }
7169        {
7170            let to_remove = ["name"];
7171            params.remove_params(&to_remove);
7172        }
7173
7174        let url = params.parse_with_url(&url);
7175
7176        loop {
7177            let token = match self
7178                .hub
7179                .auth
7180                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7181                .await
7182            {
7183                Ok(token) => token,
7184                Err(e) => match dlg.token(e) {
7185                    Ok(token) => token,
7186                    Err(e) => {
7187                        dlg.finished(false);
7188                        return Err(common::Error::MissingToken(e));
7189                    }
7190                },
7191            };
7192            let mut req_result = {
7193                let client = &self.hub.client;
7194                dlg.pre_request();
7195                let mut req_builder = hyper::Request::builder()
7196                    .method(hyper::Method::GET)
7197                    .uri(url.as_str())
7198                    .header(USER_AGENT, self.hub._user_agent.clone());
7199
7200                if let Some(token) = token.as_ref() {
7201                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7202                }
7203
7204                let request = req_builder
7205                    .header(CONTENT_LENGTH, 0_u64)
7206                    .body(common::to_body::<String>(None));
7207
7208                client.request(request.unwrap()).await
7209            };
7210
7211            match req_result {
7212                Err(err) => {
7213                    if let common::Retry::After(d) = dlg.http_error(&err) {
7214                        sleep(d).await;
7215                        continue;
7216                    }
7217                    dlg.finished(false);
7218                    return Err(common::Error::HttpError(err));
7219                }
7220                Ok(res) => {
7221                    let (mut parts, body) = res.into_parts();
7222                    let mut body = common::Body::new(body);
7223                    if !parts.status.is_success() {
7224                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7225                        let error = serde_json::from_str(&common::to_string(&bytes));
7226                        let response = common::to_response(parts, bytes.into());
7227
7228                        if let common::Retry::After(d) =
7229                            dlg.http_failure(&response, error.as_ref().ok())
7230                        {
7231                            sleep(d).await;
7232                            continue;
7233                        }
7234
7235                        dlg.finished(false);
7236
7237                        return Err(match error {
7238                            Ok(value) => common::Error::BadRequest(value),
7239                            _ => common::Error::Failure(response),
7240                        });
7241                    }
7242                    let response = {
7243                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7244                        let encoded = common::to_string(&bytes);
7245                        match serde_json::from_str(&encoded) {
7246                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7247                            Err(error) => {
7248                                dlg.response_json_decode_error(&encoded, &error);
7249                                return Err(common::Error::JsonDecodeError(
7250                                    encoded.to_string(),
7251                                    error,
7252                                ));
7253                            }
7254                        }
7255                    };
7256
7257                    dlg.finished(true);
7258                    return Ok(response);
7259                }
7260            }
7261        }
7262    }
7263
7264    /// Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
7265    ///
7266    /// Sets the *name* path property to the given value.
7267    ///
7268    /// Even though the property as already been set when instantiating this call,
7269    /// we provide this method for API completeness.
7270    pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryGetCall<'a, C> {
7271        self._name = new_value.to_string();
7272        self
7273    }
7274    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7275    /// while executing the actual API request.
7276    ///
7277    /// ````text
7278    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7279    /// ````
7280    ///
7281    /// Sets the *delegate* property to the given value.
7282    pub fn delegate(
7283        mut self,
7284        new_value: &'a mut dyn common::Delegate,
7285    ) -> ProjectLocationRegistryGetCall<'a, C> {
7286        self._delegate = Some(new_value);
7287        self
7288    }
7289
7290    /// Set any additional parameter of the query string used in the request.
7291    /// It should be used to set parameters which are not yet available through their own
7292    /// setters.
7293    ///
7294    /// Please note that this method must not be used to set any of the known parameters
7295    /// which have their own setter method. If done anyway, the request will fail.
7296    ///
7297    /// # Additional Parameters
7298    ///
7299    /// * *$.xgafv* (query-string) - V1 error format.
7300    /// * *access_token* (query-string) - OAuth access token.
7301    /// * *alt* (query-string) - Data format for response.
7302    /// * *callback* (query-string) - JSONP
7303    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7304    /// * *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.
7305    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7306    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7307    /// * *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.
7308    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7309    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7310    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryGetCall<'a, C>
7311    where
7312        T: AsRef<str>,
7313    {
7314        self._additional_params
7315            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7316        self
7317    }
7318
7319    /// Identifies the authorization scope for the method you are building.
7320    ///
7321    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7322    /// [`Scope::CloudPlatform`].
7323    ///
7324    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7325    /// tokens for more than one scope.
7326    ///
7327    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7328    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7329    /// sufficient, a read-write scope will do as well.
7330    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGetCall<'a, C>
7331    where
7332        St: AsRef<str>,
7333    {
7334        self._scopes.insert(String::from(scope.as_ref()));
7335        self
7336    }
7337    /// Identifies the authorization scope(s) for the method you are building.
7338    ///
7339    /// See [`Self::add_scope()`] for details.
7340    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryGetCall<'a, C>
7341    where
7342        I: IntoIterator<Item = St>,
7343        St: AsRef<str>,
7344    {
7345        self._scopes
7346            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7347        self
7348    }
7349
7350    /// Removes all scopes, and no default scope will be used either.
7351    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7352    /// for details).
7353    pub fn clear_scopes(mut self) -> ProjectLocationRegistryGetCall<'a, C> {
7354        self._scopes.clear();
7355        self
7356    }
7357}
7358
7359/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7360///
7361/// A builder for the *locations.registries.getIamPolicy* method supported by a *project* resource.
7362/// It is not used directly, but through a [`ProjectMethods`] instance.
7363///
7364/// # Example
7365///
7366/// Instantiate a resource method builder
7367///
7368/// ```test_harness,no_run
7369/// # extern crate hyper;
7370/// # extern crate hyper_rustls;
7371/// # extern crate google_cloudiot1 as cloudiot1;
7372/// use cloudiot1::api::GetIamPolicyRequest;
7373/// # async fn dox() {
7374/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7375///
7376/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7377/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7378/// #     .with_native_roots()
7379/// #     .unwrap()
7380/// #     .https_only()
7381/// #     .enable_http2()
7382/// #     .build();
7383///
7384/// # let executor = hyper_util::rt::TokioExecutor::new();
7385/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7386/// #     secret,
7387/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7388/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7389/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7390/// #     ),
7391/// # ).build().await.unwrap();
7392///
7393/// # let client = hyper_util::client::legacy::Client::builder(
7394/// #     hyper_util::rt::TokioExecutor::new()
7395/// # )
7396/// # .build(
7397/// #     hyper_rustls::HttpsConnectorBuilder::new()
7398/// #         .with_native_roots()
7399/// #         .unwrap()
7400/// #         .https_or_http()
7401/// #         .enable_http2()
7402/// #         .build()
7403/// # );
7404/// # let mut hub = CloudIot::new(client, auth);
7405/// // As the method needs a request, you would usually fill it with the desired information
7406/// // into the respective structure. Some of the parts shown here might not be applicable !
7407/// // Values shown here are possibly random and not representative !
7408/// let mut req = GetIamPolicyRequest::default();
7409///
7410/// // You can configure optional parameters by calling the respective setters at will, and
7411/// // execute the final call using `doit()`.
7412/// // Values shown here are possibly random and not representative !
7413/// let result = hub.projects().locations_registries_get_iam_policy(req, "resource")
7414///              .doit().await;
7415/// # }
7416/// ```
7417pub struct ProjectLocationRegistryGetIamPolicyCall<'a, C>
7418where
7419    C: 'a,
7420{
7421    hub: &'a CloudIot<C>,
7422    _request: GetIamPolicyRequest,
7423    _resource: String,
7424    _delegate: Option<&'a mut dyn common::Delegate>,
7425    _additional_params: HashMap<String, String>,
7426    _scopes: BTreeSet<String>,
7427}
7428
7429impl<'a, C> common::CallBuilder for ProjectLocationRegistryGetIamPolicyCall<'a, C> {}
7430
7431impl<'a, C> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7432where
7433    C: common::Connector,
7434{
7435    /// Perform the operation you have build so far.
7436    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7437        use std::borrow::Cow;
7438        use std::io::{Read, Seek};
7439
7440        use common::{url::Params, ToParts};
7441        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7442
7443        let mut dd = common::DefaultDelegate;
7444        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7445        dlg.begin(common::MethodInfo {
7446            id: "cloudiot.projects.locations.registries.getIamPolicy",
7447            http_method: hyper::Method::POST,
7448        });
7449
7450        for &field in ["alt", "resource"].iter() {
7451            if self._additional_params.contains_key(field) {
7452                dlg.finished(false);
7453                return Err(common::Error::FieldClash(field));
7454            }
7455        }
7456
7457        let mut params = Params::with_capacity(4 + self._additional_params.len());
7458        params.push("resource", self._resource);
7459
7460        params.extend(self._additional_params.iter());
7461
7462        params.push("alt", "json");
7463        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7464        if self._scopes.is_empty() {
7465            self._scopes
7466                .insert(Scope::CloudPlatform.as_ref().to_string());
7467        }
7468
7469        #[allow(clippy::single_element_loop)]
7470        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7471            url = params.uri_replacement(url, param_name, find_this, true);
7472        }
7473        {
7474            let to_remove = ["resource"];
7475            params.remove_params(&to_remove);
7476        }
7477
7478        let url = params.parse_with_url(&url);
7479
7480        let mut json_mime_type = mime::APPLICATION_JSON;
7481        let mut request_value_reader = {
7482            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7483            common::remove_json_null_values(&mut value);
7484            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7485            serde_json::to_writer(&mut dst, &value).unwrap();
7486            dst
7487        };
7488        let request_size = request_value_reader
7489            .seek(std::io::SeekFrom::End(0))
7490            .unwrap();
7491        request_value_reader
7492            .seek(std::io::SeekFrom::Start(0))
7493            .unwrap();
7494
7495        loop {
7496            let token = match self
7497                .hub
7498                .auth
7499                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7500                .await
7501            {
7502                Ok(token) => token,
7503                Err(e) => match dlg.token(e) {
7504                    Ok(token) => token,
7505                    Err(e) => {
7506                        dlg.finished(false);
7507                        return Err(common::Error::MissingToken(e));
7508                    }
7509                },
7510            };
7511            request_value_reader
7512                .seek(std::io::SeekFrom::Start(0))
7513                .unwrap();
7514            let mut req_result = {
7515                let client = &self.hub.client;
7516                dlg.pre_request();
7517                let mut req_builder = hyper::Request::builder()
7518                    .method(hyper::Method::POST)
7519                    .uri(url.as_str())
7520                    .header(USER_AGENT, self.hub._user_agent.clone());
7521
7522                if let Some(token) = token.as_ref() {
7523                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7524                }
7525
7526                let request = req_builder
7527                    .header(CONTENT_TYPE, json_mime_type.to_string())
7528                    .header(CONTENT_LENGTH, request_size as u64)
7529                    .body(common::to_body(
7530                        request_value_reader.get_ref().clone().into(),
7531                    ));
7532
7533                client.request(request.unwrap()).await
7534            };
7535
7536            match req_result {
7537                Err(err) => {
7538                    if let common::Retry::After(d) = dlg.http_error(&err) {
7539                        sleep(d).await;
7540                        continue;
7541                    }
7542                    dlg.finished(false);
7543                    return Err(common::Error::HttpError(err));
7544                }
7545                Ok(res) => {
7546                    let (mut parts, body) = res.into_parts();
7547                    let mut body = common::Body::new(body);
7548                    if !parts.status.is_success() {
7549                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7550                        let error = serde_json::from_str(&common::to_string(&bytes));
7551                        let response = common::to_response(parts, bytes.into());
7552
7553                        if let common::Retry::After(d) =
7554                            dlg.http_failure(&response, error.as_ref().ok())
7555                        {
7556                            sleep(d).await;
7557                            continue;
7558                        }
7559
7560                        dlg.finished(false);
7561
7562                        return Err(match error {
7563                            Ok(value) => common::Error::BadRequest(value),
7564                            _ => common::Error::Failure(response),
7565                        });
7566                    }
7567                    let response = {
7568                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7569                        let encoded = common::to_string(&bytes);
7570                        match serde_json::from_str(&encoded) {
7571                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7572                            Err(error) => {
7573                                dlg.response_json_decode_error(&encoded, &error);
7574                                return Err(common::Error::JsonDecodeError(
7575                                    encoded.to_string(),
7576                                    error,
7577                                ));
7578                            }
7579                        }
7580                    };
7581
7582                    dlg.finished(true);
7583                    return Ok(response);
7584                }
7585            }
7586        }
7587    }
7588
7589    ///
7590    /// Sets the *request* property to the given value.
7591    ///
7592    /// Even though the property as already been set when instantiating this call,
7593    /// we provide this method for API completeness.
7594    pub fn request(
7595        mut self,
7596        new_value: GetIamPolicyRequest,
7597    ) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7598        self._request = new_value;
7599        self
7600    }
7601    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
7602    ///
7603    /// Sets the *resource* path property to the given value.
7604    ///
7605    /// Even though the property as already been set when instantiating this call,
7606    /// we provide this method for API completeness.
7607    pub fn resource(mut self, new_value: &str) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7608        self._resource = new_value.to_string();
7609        self
7610    }
7611    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7612    /// while executing the actual API request.
7613    ///
7614    /// ````text
7615    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7616    /// ````
7617    ///
7618    /// Sets the *delegate* property to the given value.
7619    pub fn delegate(
7620        mut self,
7621        new_value: &'a mut dyn common::Delegate,
7622    ) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7623        self._delegate = Some(new_value);
7624        self
7625    }
7626
7627    /// Set any additional parameter of the query string used in the request.
7628    /// It should be used to set parameters which are not yet available through their own
7629    /// setters.
7630    ///
7631    /// Please note that this method must not be used to set any of the known parameters
7632    /// which have their own setter method. If done anyway, the request will fail.
7633    ///
7634    /// # Additional Parameters
7635    ///
7636    /// * *$.xgafv* (query-string) - V1 error format.
7637    /// * *access_token* (query-string) - OAuth access token.
7638    /// * *alt* (query-string) - Data format for response.
7639    /// * *callback* (query-string) - JSONP
7640    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7641    /// * *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.
7642    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7643    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7644    /// * *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.
7645    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7646    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7647    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7648    where
7649        T: AsRef<str>,
7650    {
7651        self._additional_params
7652            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7653        self
7654    }
7655
7656    /// Identifies the authorization scope for the method you are building.
7657    ///
7658    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7659    /// [`Scope::CloudPlatform`].
7660    ///
7661    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7662    /// tokens for more than one scope.
7663    ///
7664    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7665    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7666    /// sufficient, a read-write scope will do as well.
7667    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7668    where
7669        St: AsRef<str>,
7670    {
7671        self._scopes.insert(String::from(scope.as_ref()));
7672        self
7673    }
7674    /// Identifies the authorization scope(s) for the method you are building.
7675    ///
7676    /// See [`Self::add_scope()`] for details.
7677    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7678    where
7679        I: IntoIterator<Item = St>,
7680        St: AsRef<str>,
7681    {
7682        self._scopes
7683            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7684        self
7685    }
7686
7687    /// Removes all scopes, and no default scope will be used either.
7688    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7689    /// for details).
7690    pub fn clear_scopes(mut self) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7691        self._scopes.clear();
7692        self
7693    }
7694}
7695
7696/// Lists device registries.
7697///
7698/// A builder for the *locations.registries.list* method supported by a *project* resource.
7699/// It is not used directly, but through a [`ProjectMethods`] instance.
7700///
7701/// # Example
7702///
7703/// Instantiate a resource method builder
7704///
7705/// ```test_harness,no_run
7706/// # extern crate hyper;
7707/// # extern crate hyper_rustls;
7708/// # extern crate google_cloudiot1 as cloudiot1;
7709/// # async fn dox() {
7710/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7711///
7712/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7713/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7714/// #     .with_native_roots()
7715/// #     .unwrap()
7716/// #     .https_only()
7717/// #     .enable_http2()
7718/// #     .build();
7719///
7720/// # let executor = hyper_util::rt::TokioExecutor::new();
7721/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7722/// #     secret,
7723/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7724/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7725/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7726/// #     ),
7727/// # ).build().await.unwrap();
7728///
7729/// # let client = hyper_util::client::legacy::Client::builder(
7730/// #     hyper_util::rt::TokioExecutor::new()
7731/// # )
7732/// # .build(
7733/// #     hyper_rustls::HttpsConnectorBuilder::new()
7734/// #         .with_native_roots()
7735/// #         .unwrap()
7736/// #         .https_or_http()
7737/// #         .enable_http2()
7738/// #         .build()
7739/// # );
7740/// # let mut hub = CloudIot::new(client, auth);
7741/// // You can configure optional parameters by calling the respective setters at will, and
7742/// // execute the final call using `doit()`.
7743/// // Values shown here are possibly random and not representative !
7744/// let result = hub.projects().locations_registries_list("parent")
7745///              .page_token("sed")
7746///              .page_size(-70)
7747///              .doit().await;
7748/// # }
7749/// ```
7750pub struct ProjectLocationRegistryListCall<'a, C>
7751where
7752    C: 'a,
7753{
7754    hub: &'a CloudIot<C>,
7755    _parent: String,
7756    _page_token: Option<String>,
7757    _page_size: Option<i32>,
7758    _delegate: Option<&'a mut dyn common::Delegate>,
7759    _additional_params: HashMap<String, String>,
7760    _scopes: BTreeSet<String>,
7761}
7762
7763impl<'a, C> common::CallBuilder for ProjectLocationRegistryListCall<'a, C> {}
7764
7765impl<'a, C> ProjectLocationRegistryListCall<'a, C>
7766where
7767    C: common::Connector,
7768{
7769    /// Perform the operation you have build so far.
7770    pub async fn doit(
7771        mut self,
7772    ) -> common::Result<(common::Response, ListDeviceRegistriesResponse)> {
7773        use std::borrow::Cow;
7774        use std::io::{Read, Seek};
7775
7776        use common::{url::Params, ToParts};
7777        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7778
7779        let mut dd = common::DefaultDelegate;
7780        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7781        dlg.begin(common::MethodInfo {
7782            id: "cloudiot.projects.locations.registries.list",
7783            http_method: hyper::Method::GET,
7784        });
7785
7786        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
7787            if self._additional_params.contains_key(field) {
7788                dlg.finished(false);
7789                return Err(common::Error::FieldClash(field));
7790            }
7791        }
7792
7793        let mut params = Params::with_capacity(5 + self._additional_params.len());
7794        params.push("parent", self._parent);
7795        if let Some(value) = self._page_token.as_ref() {
7796            params.push("pageToken", value);
7797        }
7798        if let Some(value) = self._page_size.as_ref() {
7799            params.push("pageSize", value.to_string());
7800        }
7801
7802        params.extend(self._additional_params.iter());
7803
7804        params.push("alt", "json");
7805        let mut url = self.hub._base_url.clone() + "v1/{+parent}/registries";
7806        if self._scopes.is_empty() {
7807            self._scopes
7808                .insert(Scope::CloudPlatform.as_ref().to_string());
7809        }
7810
7811        #[allow(clippy::single_element_loop)]
7812        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7813            url = params.uri_replacement(url, param_name, find_this, true);
7814        }
7815        {
7816            let to_remove = ["parent"];
7817            params.remove_params(&to_remove);
7818        }
7819
7820        let url = params.parse_with_url(&url);
7821
7822        loop {
7823            let token = match self
7824                .hub
7825                .auth
7826                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7827                .await
7828            {
7829                Ok(token) => token,
7830                Err(e) => match dlg.token(e) {
7831                    Ok(token) => token,
7832                    Err(e) => {
7833                        dlg.finished(false);
7834                        return Err(common::Error::MissingToken(e));
7835                    }
7836                },
7837            };
7838            let mut req_result = {
7839                let client = &self.hub.client;
7840                dlg.pre_request();
7841                let mut req_builder = hyper::Request::builder()
7842                    .method(hyper::Method::GET)
7843                    .uri(url.as_str())
7844                    .header(USER_AGENT, self.hub._user_agent.clone());
7845
7846                if let Some(token) = token.as_ref() {
7847                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7848                }
7849
7850                let request = req_builder
7851                    .header(CONTENT_LENGTH, 0_u64)
7852                    .body(common::to_body::<String>(None));
7853
7854                client.request(request.unwrap()).await
7855            };
7856
7857            match req_result {
7858                Err(err) => {
7859                    if let common::Retry::After(d) = dlg.http_error(&err) {
7860                        sleep(d).await;
7861                        continue;
7862                    }
7863                    dlg.finished(false);
7864                    return Err(common::Error::HttpError(err));
7865                }
7866                Ok(res) => {
7867                    let (mut parts, body) = res.into_parts();
7868                    let mut body = common::Body::new(body);
7869                    if !parts.status.is_success() {
7870                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7871                        let error = serde_json::from_str(&common::to_string(&bytes));
7872                        let response = common::to_response(parts, bytes.into());
7873
7874                        if let common::Retry::After(d) =
7875                            dlg.http_failure(&response, error.as_ref().ok())
7876                        {
7877                            sleep(d).await;
7878                            continue;
7879                        }
7880
7881                        dlg.finished(false);
7882
7883                        return Err(match error {
7884                            Ok(value) => common::Error::BadRequest(value),
7885                            _ => common::Error::Failure(response),
7886                        });
7887                    }
7888                    let response = {
7889                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7890                        let encoded = common::to_string(&bytes);
7891                        match serde_json::from_str(&encoded) {
7892                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7893                            Err(error) => {
7894                                dlg.response_json_decode_error(&encoded, &error);
7895                                return Err(common::Error::JsonDecodeError(
7896                                    encoded.to_string(),
7897                                    error,
7898                                ));
7899                            }
7900                        }
7901                    };
7902
7903                    dlg.finished(true);
7904                    return Ok(response);
7905                }
7906            }
7907        }
7908    }
7909
7910    /// Required. The project and cloud region path. For example, `projects/example-project/locations/us-central1`.
7911    ///
7912    /// Sets the *parent* path property to the given value.
7913    ///
7914    /// Even though the property as already been set when instantiating this call,
7915    /// we provide this method for API completeness.
7916    pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryListCall<'a, C> {
7917        self._parent = new_value.to_string();
7918        self
7919    }
7920    /// The value returned by the last `ListDeviceRegistriesResponse`; indicates that this is a continuation of a prior `ListDeviceRegistries` call and the system should return the next page of data.
7921    ///
7922    /// Sets the *page token* query property to the given value.
7923    pub fn page_token(mut self, new_value: &str) -> ProjectLocationRegistryListCall<'a, C> {
7924        self._page_token = Some(new_value.to_string());
7925        self
7926    }
7927    /// The maximum number of registries to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty `next_page_token` in the response indicates that more data is available.
7928    ///
7929    /// Sets the *page size* query property to the given value.
7930    pub fn page_size(mut self, new_value: i32) -> ProjectLocationRegistryListCall<'a, C> {
7931        self._page_size = Some(new_value);
7932        self
7933    }
7934    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7935    /// while executing the actual API request.
7936    ///
7937    /// ````text
7938    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7939    /// ````
7940    ///
7941    /// Sets the *delegate* property to the given value.
7942    pub fn delegate(
7943        mut self,
7944        new_value: &'a mut dyn common::Delegate,
7945    ) -> ProjectLocationRegistryListCall<'a, C> {
7946        self._delegate = Some(new_value);
7947        self
7948    }
7949
7950    /// Set any additional parameter of the query string used in the request.
7951    /// It should be used to set parameters which are not yet available through their own
7952    /// setters.
7953    ///
7954    /// Please note that this method must not be used to set any of the known parameters
7955    /// which have their own setter method. If done anyway, the request will fail.
7956    ///
7957    /// # Additional Parameters
7958    ///
7959    /// * *$.xgafv* (query-string) - V1 error format.
7960    /// * *access_token* (query-string) - OAuth access token.
7961    /// * *alt* (query-string) - Data format for response.
7962    /// * *callback* (query-string) - JSONP
7963    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7964    /// * *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.
7965    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7966    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7967    /// * *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.
7968    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7969    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7970    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryListCall<'a, C>
7971    where
7972        T: AsRef<str>,
7973    {
7974        self._additional_params
7975            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7976        self
7977    }
7978
7979    /// Identifies the authorization scope for the method you are building.
7980    ///
7981    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7982    /// [`Scope::CloudPlatform`].
7983    ///
7984    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7985    /// tokens for more than one scope.
7986    ///
7987    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7988    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7989    /// sufficient, a read-write scope will do as well.
7990    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryListCall<'a, C>
7991    where
7992        St: AsRef<str>,
7993    {
7994        self._scopes.insert(String::from(scope.as_ref()));
7995        self
7996    }
7997    /// Identifies the authorization scope(s) for the method you are building.
7998    ///
7999    /// See [`Self::add_scope()`] for details.
8000    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryListCall<'a, C>
8001    where
8002        I: IntoIterator<Item = St>,
8003        St: AsRef<str>,
8004    {
8005        self._scopes
8006            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8007        self
8008    }
8009
8010    /// Removes all scopes, and no default scope will be used either.
8011    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8012    /// for details).
8013    pub fn clear_scopes(mut self) -> ProjectLocationRegistryListCall<'a, C> {
8014        self._scopes.clear();
8015        self
8016    }
8017}
8018
8019/// Updates a device registry configuration.
8020///
8021/// A builder for the *locations.registries.patch* method supported by a *project* resource.
8022/// It is not used directly, but through a [`ProjectMethods`] instance.
8023///
8024/// # Example
8025///
8026/// Instantiate a resource method builder
8027///
8028/// ```test_harness,no_run
8029/// # extern crate hyper;
8030/// # extern crate hyper_rustls;
8031/// # extern crate google_cloudiot1 as cloudiot1;
8032/// use cloudiot1::api::DeviceRegistry;
8033/// # async fn dox() {
8034/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8035///
8036/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8037/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8038/// #     .with_native_roots()
8039/// #     .unwrap()
8040/// #     .https_only()
8041/// #     .enable_http2()
8042/// #     .build();
8043///
8044/// # let executor = hyper_util::rt::TokioExecutor::new();
8045/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8046/// #     secret,
8047/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8048/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8049/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8050/// #     ),
8051/// # ).build().await.unwrap();
8052///
8053/// # let client = hyper_util::client::legacy::Client::builder(
8054/// #     hyper_util::rt::TokioExecutor::new()
8055/// # )
8056/// # .build(
8057/// #     hyper_rustls::HttpsConnectorBuilder::new()
8058/// #         .with_native_roots()
8059/// #         .unwrap()
8060/// #         .https_or_http()
8061/// #         .enable_http2()
8062/// #         .build()
8063/// # );
8064/// # let mut hub = CloudIot::new(client, auth);
8065/// // As the method needs a request, you would usually fill it with the desired information
8066/// // into the respective structure. Some of the parts shown here might not be applicable !
8067/// // Values shown here are possibly random and not representative !
8068/// let mut req = DeviceRegistry::default();
8069///
8070/// // You can configure optional parameters by calling the respective setters at will, and
8071/// // execute the final call using `doit()`.
8072/// // Values shown here are possibly random and not representative !
8073/// let result = hub.projects().locations_registries_patch(req, "name")
8074///              .update_mask(FieldMask::new::<&str>(&[]))
8075///              .doit().await;
8076/// # }
8077/// ```
8078pub struct ProjectLocationRegistryPatchCall<'a, C>
8079where
8080    C: 'a,
8081{
8082    hub: &'a CloudIot<C>,
8083    _request: DeviceRegistry,
8084    _name: String,
8085    _update_mask: Option<common::FieldMask>,
8086    _delegate: Option<&'a mut dyn common::Delegate>,
8087    _additional_params: HashMap<String, String>,
8088    _scopes: BTreeSet<String>,
8089}
8090
8091impl<'a, C> common::CallBuilder for ProjectLocationRegistryPatchCall<'a, C> {}
8092
8093impl<'a, C> ProjectLocationRegistryPatchCall<'a, C>
8094where
8095    C: common::Connector,
8096{
8097    /// Perform the operation you have build so far.
8098    pub async fn doit(mut self) -> common::Result<(common::Response, DeviceRegistry)> {
8099        use std::borrow::Cow;
8100        use std::io::{Read, Seek};
8101
8102        use common::{url::Params, ToParts};
8103        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8104
8105        let mut dd = common::DefaultDelegate;
8106        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8107        dlg.begin(common::MethodInfo {
8108            id: "cloudiot.projects.locations.registries.patch",
8109            http_method: hyper::Method::PATCH,
8110        });
8111
8112        for &field in ["alt", "name", "updateMask"].iter() {
8113            if self._additional_params.contains_key(field) {
8114                dlg.finished(false);
8115                return Err(common::Error::FieldClash(field));
8116            }
8117        }
8118
8119        let mut params = Params::with_capacity(5 + self._additional_params.len());
8120        params.push("name", self._name);
8121        if let Some(value) = self._update_mask.as_ref() {
8122            params.push("updateMask", value.to_string());
8123        }
8124
8125        params.extend(self._additional_params.iter());
8126
8127        params.push("alt", "json");
8128        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8129        if self._scopes.is_empty() {
8130            self._scopes
8131                .insert(Scope::CloudPlatform.as_ref().to_string());
8132        }
8133
8134        #[allow(clippy::single_element_loop)]
8135        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8136            url = params.uri_replacement(url, param_name, find_this, true);
8137        }
8138        {
8139            let to_remove = ["name"];
8140            params.remove_params(&to_remove);
8141        }
8142
8143        let url = params.parse_with_url(&url);
8144
8145        let mut json_mime_type = mime::APPLICATION_JSON;
8146        let mut request_value_reader = {
8147            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8148            common::remove_json_null_values(&mut value);
8149            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8150            serde_json::to_writer(&mut dst, &value).unwrap();
8151            dst
8152        };
8153        let request_size = request_value_reader
8154            .seek(std::io::SeekFrom::End(0))
8155            .unwrap();
8156        request_value_reader
8157            .seek(std::io::SeekFrom::Start(0))
8158            .unwrap();
8159
8160        loop {
8161            let token = match self
8162                .hub
8163                .auth
8164                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8165                .await
8166            {
8167                Ok(token) => token,
8168                Err(e) => match dlg.token(e) {
8169                    Ok(token) => token,
8170                    Err(e) => {
8171                        dlg.finished(false);
8172                        return Err(common::Error::MissingToken(e));
8173                    }
8174                },
8175            };
8176            request_value_reader
8177                .seek(std::io::SeekFrom::Start(0))
8178                .unwrap();
8179            let mut req_result = {
8180                let client = &self.hub.client;
8181                dlg.pre_request();
8182                let mut req_builder = hyper::Request::builder()
8183                    .method(hyper::Method::PATCH)
8184                    .uri(url.as_str())
8185                    .header(USER_AGENT, self.hub._user_agent.clone());
8186
8187                if let Some(token) = token.as_ref() {
8188                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8189                }
8190
8191                let request = req_builder
8192                    .header(CONTENT_TYPE, json_mime_type.to_string())
8193                    .header(CONTENT_LENGTH, request_size as u64)
8194                    .body(common::to_body(
8195                        request_value_reader.get_ref().clone().into(),
8196                    ));
8197
8198                client.request(request.unwrap()).await
8199            };
8200
8201            match req_result {
8202                Err(err) => {
8203                    if let common::Retry::After(d) = dlg.http_error(&err) {
8204                        sleep(d).await;
8205                        continue;
8206                    }
8207                    dlg.finished(false);
8208                    return Err(common::Error::HttpError(err));
8209                }
8210                Ok(res) => {
8211                    let (mut parts, body) = res.into_parts();
8212                    let mut body = common::Body::new(body);
8213                    if !parts.status.is_success() {
8214                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8215                        let error = serde_json::from_str(&common::to_string(&bytes));
8216                        let response = common::to_response(parts, bytes.into());
8217
8218                        if let common::Retry::After(d) =
8219                            dlg.http_failure(&response, error.as_ref().ok())
8220                        {
8221                            sleep(d).await;
8222                            continue;
8223                        }
8224
8225                        dlg.finished(false);
8226
8227                        return Err(match error {
8228                            Ok(value) => common::Error::BadRequest(value),
8229                            _ => common::Error::Failure(response),
8230                        });
8231                    }
8232                    let response = {
8233                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8234                        let encoded = common::to_string(&bytes);
8235                        match serde_json::from_str(&encoded) {
8236                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8237                            Err(error) => {
8238                                dlg.response_json_decode_error(&encoded, &error);
8239                                return Err(common::Error::JsonDecodeError(
8240                                    encoded.to_string(),
8241                                    error,
8242                                ));
8243                            }
8244                        }
8245                    };
8246
8247                    dlg.finished(true);
8248                    return Ok(response);
8249                }
8250            }
8251        }
8252    }
8253
8254    ///
8255    /// Sets the *request* property to the given value.
8256    ///
8257    /// Even though the property as already been set when instantiating this call,
8258    /// we provide this method for API completeness.
8259    pub fn request(mut self, new_value: DeviceRegistry) -> ProjectLocationRegistryPatchCall<'a, C> {
8260        self._request = new_value;
8261        self
8262    }
8263    /// The resource path name. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
8264    ///
8265    /// Sets the *name* path property to the given value.
8266    ///
8267    /// Even though the property as already been set when instantiating this call,
8268    /// we provide this method for API completeness.
8269    pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryPatchCall<'a, C> {
8270        self._name = new_value.to_string();
8271        self
8272    }
8273    /// Required. Only updates the `device_registry` fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: `event_notification_config`, `http_config`, `mqtt_config`, and `state_notification_config`.
8274    ///
8275    /// Sets the *update mask* query property to the given value.
8276    pub fn update_mask(
8277        mut self,
8278        new_value: common::FieldMask,
8279    ) -> ProjectLocationRegistryPatchCall<'a, C> {
8280        self._update_mask = Some(new_value);
8281        self
8282    }
8283    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8284    /// while executing the actual API request.
8285    ///
8286    /// ````text
8287    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8288    /// ````
8289    ///
8290    /// Sets the *delegate* property to the given value.
8291    pub fn delegate(
8292        mut self,
8293        new_value: &'a mut dyn common::Delegate,
8294    ) -> ProjectLocationRegistryPatchCall<'a, C> {
8295        self._delegate = Some(new_value);
8296        self
8297    }
8298
8299    /// Set any additional parameter of the query string used in the request.
8300    /// It should be used to set parameters which are not yet available through their own
8301    /// setters.
8302    ///
8303    /// Please note that this method must not be used to set any of the known parameters
8304    /// which have their own setter method. If done anyway, the request will fail.
8305    ///
8306    /// # Additional Parameters
8307    ///
8308    /// * *$.xgafv* (query-string) - V1 error format.
8309    /// * *access_token* (query-string) - OAuth access token.
8310    /// * *alt* (query-string) - Data format for response.
8311    /// * *callback* (query-string) - JSONP
8312    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8313    /// * *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.
8314    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8315    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8316    /// * *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.
8317    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8318    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8319    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryPatchCall<'a, C>
8320    where
8321        T: AsRef<str>,
8322    {
8323        self._additional_params
8324            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8325        self
8326    }
8327
8328    /// Identifies the authorization scope for the method you are building.
8329    ///
8330    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8331    /// [`Scope::CloudPlatform`].
8332    ///
8333    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8334    /// tokens for more than one scope.
8335    ///
8336    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8337    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8338    /// sufficient, a read-write scope will do as well.
8339    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryPatchCall<'a, C>
8340    where
8341        St: AsRef<str>,
8342    {
8343        self._scopes.insert(String::from(scope.as_ref()));
8344        self
8345    }
8346    /// Identifies the authorization scope(s) for the method you are building.
8347    ///
8348    /// See [`Self::add_scope()`] for details.
8349    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryPatchCall<'a, C>
8350    where
8351        I: IntoIterator<Item = St>,
8352        St: AsRef<str>,
8353    {
8354        self._scopes
8355            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8356        self
8357    }
8358
8359    /// Removes all scopes, and no default scope will be used either.
8360    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8361    /// for details).
8362    pub fn clear_scopes(mut self) -> ProjectLocationRegistryPatchCall<'a, C> {
8363        self._scopes.clear();
8364        self
8365    }
8366}
8367
8368/// Sets the access control policy on the specified resource. Replaces any existing policy.
8369///
8370/// A builder for the *locations.registries.setIamPolicy* method supported by a *project* resource.
8371/// It is not used directly, but through a [`ProjectMethods`] instance.
8372///
8373/// # Example
8374///
8375/// Instantiate a resource method builder
8376///
8377/// ```test_harness,no_run
8378/// # extern crate hyper;
8379/// # extern crate hyper_rustls;
8380/// # extern crate google_cloudiot1 as cloudiot1;
8381/// use cloudiot1::api::SetIamPolicyRequest;
8382/// # async fn dox() {
8383/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8384///
8385/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8386/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8387/// #     .with_native_roots()
8388/// #     .unwrap()
8389/// #     .https_only()
8390/// #     .enable_http2()
8391/// #     .build();
8392///
8393/// # let executor = hyper_util::rt::TokioExecutor::new();
8394/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8395/// #     secret,
8396/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8397/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8398/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8399/// #     ),
8400/// # ).build().await.unwrap();
8401///
8402/// # let client = hyper_util::client::legacy::Client::builder(
8403/// #     hyper_util::rt::TokioExecutor::new()
8404/// # )
8405/// # .build(
8406/// #     hyper_rustls::HttpsConnectorBuilder::new()
8407/// #         .with_native_roots()
8408/// #         .unwrap()
8409/// #         .https_or_http()
8410/// #         .enable_http2()
8411/// #         .build()
8412/// # );
8413/// # let mut hub = CloudIot::new(client, auth);
8414/// // As the method needs a request, you would usually fill it with the desired information
8415/// // into the respective structure. Some of the parts shown here might not be applicable !
8416/// // Values shown here are possibly random and not representative !
8417/// let mut req = SetIamPolicyRequest::default();
8418///
8419/// // You can configure optional parameters by calling the respective setters at will, and
8420/// // execute the final call using `doit()`.
8421/// // Values shown here are possibly random and not representative !
8422/// let result = hub.projects().locations_registries_set_iam_policy(req, "resource")
8423///              .doit().await;
8424/// # }
8425/// ```
8426pub struct ProjectLocationRegistrySetIamPolicyCall<'a, C>
8427where
8428    C: 'a,
8429{
8430    hub: &'a CloudIot<C>,
8431    _request: SetIamPolicyRequest,
8432    _resource: String,
8433    _delegate: Option<&'a mut dyn common::Delegate>,
8434    _additional_params: HashMap<String, String>,
8435    _scopes: BTreeSet<String>,
8436}
8437
8438impl<'a, C> common::CallBuilder for ProjectLocationRegistrySetIamPolicyCall<'a, C> {}
8439
8440impl<'a, C> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8441where
8442    C: common::Connector,
8443{
8444    /// Perform the operation you have build so far.
8445    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8446        use std::borrow::Cow;
8447        use std::io::{Read, Seek};
8448
8449        use common::{url::Params, ToParts};
8450        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8451
8452        let mut dd = common::DefaultDelegate;
8453        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8454        dlg.begin(common::MethodInfo {
8455            id: "cloudiot.projects.locations.registries.setIamPolicy",
8456            http_method: hyper::Method::POST,
8457        });
8458
8459        for &field in ["alt", "resource"].iter() {
8460            if self._additional_params.contains_key(field) {
8461                dlg.finished(false);
8462                return Err(common::Error::FieldClash(field));
8463            }
8464        }
8465
8466        let mut params = Params::with_capacity(4 + self._additional_params.len());
8467        params.push("resource", self._resource);
8468
8469        params.extend(self._additional_params.iter());
8470
8471        params.push("alt", "json");
8472        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8473        if self._scopes.is_empty() {
8474            self._scopes
8475                .insert(Scope::CloudPlatform.as_ref().to_string());
8476        }
8477
8478        #[allow(clippy::single_element_loop)]
8479        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8480            url = params.uri_replacement(url, param_name, find_this, true);
8481        }
8482        {
8483            let to_remove = ["resource"];
8484            params.remove_params(&to_remove);
8485        }
8486
8487        let url = params.parse_with_url(&url);
8488
8489        let mut json_mime_type = mime::APPLICATION_JSON;
8490        let mut request_value_reader = {
8491            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8492            common::remove_json_null_values(&mut value);
8493            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8494            serde_json::to_writer(&mut dst, &value).unwrap();
8495            dst
8496        };
8497        let request_size = request_value_reader
8498            .seek(std::io::SeekFrom::End(0))
8499            .unwrap();
8500        request_value_reader
8501            .seek(std::io::SeekFrom::Start(0))
8502            .unwrap();
8503
8504        loop {
8505            let token = match self
8506                .hub
8507                .auth
8508                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8509                .await
8510            {
8511                Ok(token) => token,
8512                Err(e) => match dlg.token(e) {
8513                    Ok(token) => token,
8514                    Err(e) => {
8515                        dlg.finished(false);
8516                        return Err(common::Error::MissingToken(e));
8517                    }
8518                },
8519            };
8520            request_value_reader
8521                .seek(std::io::SeekFrom::Start(0))
8522                .unwrap();
8523            let mut req_result = {
8524                let client = &self.hub.client;
8525                dlg.pre_request();
8526                let mut req_builder = hyper::Request::builder()
8527                    .method(hyper::Method::POST)
8528                    .uri(url.as_str())
8529                    .header(USER_AGENT, self.hub._user_agent.clone());
8530
8531                if let Some(token) = token.as_ref() {
8532                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8533                }
8534
8535                let request = req_builder
8536                    .header(CONTENT_TYPE, json_mime_type.to_string())
8537                    .header(CONTENT_LENGTH, request_size as u64)
8538                    .body(common::to_body(
8539                        request_value_reader.get_ref().clone().into(),
8540                    ));
8541
8542                client.request(request.unwrap()).await
8543            };
8544
8545            match req_result {
8546                Err(err) => {
8547                    if let common::Retry::After(d) = dlg.http_error(&err) {
8548                        sleep(d).await;
8549                        continue;
8550                    }
8551                    dlg.finished(false);
8552                    return Err(common::Error::HttpError(err));
8553                }
8554                Ok(res) => {
8555                    let (mut parts, body) = res.into_parts();
8556                    let mut body = common::Body::new(body);
8557                    if !parts.status.is_success() {
8558                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8559                        let error = serde_json::from_str(&common::to_string(&bytes));
8560                        let response = common::to_response(parts, bytes.into());
8561
8562                        if let common::Retry::After(d) =
8563                            dlg.http_failure(&response, error.as_ref().ok())
8564                        {
8565                            sleep(d).await;
8566                            continue;
8567                        }
8568
8569                        dlg.finished(false);
8570
8571                        return Err(match error {
8572                            Ok(value) => common::Error::BadRequest(value),
8573                            _ => common::Error::Failure(response),
8574                        });
8575                    }
8576                    let response = {
8577                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8578                        let encoded = common::to_string(&bytes);
8579                        match serde_json::from_str(&encoded) {
8580                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8581                            Err(error) => {
8582                                dlg.response_json_decode_error(&encoded, &error);
8583                                return Err(common::Error::JsonDecodeError(
8584                                    encoded.to_string(),
8585                                    error,
8586                                ));
8587                            }
8588                        }
8589                    };
8590
8591                    dlg.finished(true);
8592                    return Ok(response);
8593                }
8594            }
8595        }
8596    }
8597
8598    ///
8599    /// Sets the *request* property to the given value.
8600    ///
8601    /// Even though the property as already been set when instantiating this call,
8602    /// we provide this method for API completeness.
8603    pub fn request(
8604        mut self,
8605        new_value: SetIamPolicyRequest,
8606    ) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8607        self._request = new_value;
8608        self
8609    }
8610    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8611    ///
8612    /// Sets the *resource* path property to the given value.
8613    ///
8614    /// Even though the property as already been set when instantiating this call,
8615    /// we provide this method for API completeness.
8616    pub fn resource(mut self, new_value: &str) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8617        self._resource = new_value.to_string();
8618        self
8619    }
8620    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8621    /// while executing the actual API request.
8622    ///
8623    /// ````text
8624    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8625    /// ````
8626    ///
8627    /// Sets the *delegate* property to the given value.
8628    pub fn delegate(
8629        mut self,
8630        new_value: &'a mut dyn common::Delegate,
8631    ) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8632        self._delegate = Some(new_value);
8633        self
8634    }
8635
8636    /// Set any additional parameter of the query string used in the request.
8637    /// It should be used to set parameters which are not yet available through their own
8638    /// setters.
8639    ///
8640    /// Please note that this method must not be used to set any of the known parameters
8641    /// which have their own setter method. If done anyway, the request will fail.
8642    ///
8643    /// # Additional Parameters
8644    ///
8645    /// * *$.xgafv* (query-string) - V1 error format.
8646    /// * *access_token* (query-string) - OAuth access token.
8647    /// * *alt* (query-string) - Data format for response.
8648    /// * *callback* (query-string) - JSONP
8649    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8650    /// * *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.
8651    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8652    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8653    /// * *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.
8654    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8655    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8656    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8657    where
8658        T: AsRef<str>,
8659    {
8660        self._additional_params
8661            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8662        self
8663    }
8664
8665    /// Identifies the authorization scope for the method you are building.
8666    ///
8667    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8668    /// [`Scope::CloudPlatform`].
8669    ///
8670    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8671    /// tokens for more than one scope.
8672    ///
8673    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8674    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8675    /// sufficient, a read-write scope will do as well.
8676    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8677    where
8678        St: AsRef<str>,
8679    {
8680        self._scopes.insert(String::from(scope.as_ref()));
8681        self
8682    }
8683    /// Identifies the authorization scope(s) for the method you are building.
8684    ///
8685    /// See [`Self::add_scope()`] for details.
8686    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8687    where
8688        I: IntoIterator<Item = St>,
8689        St: AsRef<str>,
8690    {
8691        self._scopes
8692            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8693        self
8694    }
8695
8696    /// Removes all scopes, and no default scope will be used either.
8697    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8698    /// for details).
8699    pub fn clear_scopes(mut self) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8700        self._scopes.clear();
8701        self
8702    }
8703}
8704
8705/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
8706///
8707/// A builder for the *locations.registries.testIamPermissions* method supported by a *project* resource.
8708/// It is not used directly, but through a [`ProjectMethods`] instance.
8709///
8710/// # Example
8711///
8712/// Instantiate a resource method builder
8713///
8714/// ```test_harness,no_run
8715/// # extern crate hyper;
8716/// # extern crate hyper_rustls;
8717/// # extern crate google_cloudiot1 as cloudiot1;
8718/// use cloudiot1::api::TestIamPermissionsRequest;
8719/// # async fn dox() {
8720/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8721///
8722/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8723/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8724/// #     .with_native_roots()
8725/// #     .unwrap()
8726/// #     .https_only()
8727/// #     .enable_http2()
8728/// #     .build();
8729///
8730/// # let executor = hyper_util::rt::TokioExecutor::new();
8731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8732/// #     secret,
8733/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8734/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8735/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8736/// #     ),
8737/// # ).build().await.unwrap();
8738///
8739/// # let client = hyper_util::client::legacy::Client::builder(
8740/// #     hyper_util::rt::TokioExecutor::new()
8741/// # )
8742/// # .build(
8743/// #     hyper_rustls::HttpsConnectorBuilder::new()
8744/// #         .with_native_roots()
8745/// #         .unwrap()
8746/// #         .https_or_http()
8747/// #         .enable_http2()
8748/// #         .build()
8749/// # );
8750/// # let mut hub = CloudIot::new(client, auth);
8751/// // As the method needs a request, you would usually fill it with the desired information
8752/// // into the respective structure. Some of the parts shown here might not be applicable !
8753/// // Values shown here are possibly random and not representative !
8754/// let mut req = TestIamPermissionsRequest::default();
8755///
8756/// // You can configure optional parameters by calling the respective setters at will, and
8757/// // execute the final call using `doit()`.
8758/// // Values shown here are possibly random and not representative !
8759/// let result = hub.projects().locations_registries_test_iam_permissions(req, "resource")
8760///              .doit().await;
8761/// # }
8762/// ```
8763pub struct ProjectLocationRegistryTestIamPermissionCall<'a, C>
8764where
8765    C: 'a,
8766{
8767    hub: &'a CloudIot<C>,
8768    _request: TestIamPermissionsRequest,
8769    _resource: String,
8770    _delegate: Option<&'a mut dyn common::Delegate>,
8771    _additional_params: HashMap<String, String>,
8772    _scopes: BTreeSet<String>,
8773}
8774
8775impl<'a, C> common::CallBuilder for ProjectLocationRegistryTestIamPermissionCall<'a, C> {}
8776
8777impl<'a, C> ProjectLocationRegistryTestIamPermissionCall<'a, C>
8778where
8779    C: common::Connector,
8780{
8781    /// Perform the operation you have build so far.
8782    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8783        use std::borrow::Cow;
8784        use std::io::{Read, Seek};
8785
8786        use common::{url::Params, ToParts};
8787        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8788
8789        let mut dd = common::DefaultDelegate;
8790        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8791        dlg.begin(common::MethodInfo {
8792            id: "cloudiot.projects.locations.registries.testIamPermissions",
8793            http_method: hyper::Method::POST,
8794        });
8795
8796        for &field in ["alt", "resource"].iter() {
8797            if self._additional_params.contains_key(field) {
8798                dlg.finished(false);
8799                return Err(common::Error::FieldClash(field));
8800            }
8801        }
8802
8803        let mut params = Params::with_capacity(4 + self._additional_params.len());
8804        params.push("resource", self._resource);
8805
8806        params.extend(self._additional_params.iter());
8807
8808        params.push("alt", "json");
8809        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
8810        if self._scopes.is_empty() {
8811            self._scopes
8812                .insert(Scope::CloudPlatform.as_ref().to_string());
8813        }
8814
8815        #[allow(clippy::single_element_loop)]
8816        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8817            url = params.uri_replacement(url, param_name, find_this, true);
8818        }
8819        {
8820            let to_remove = ["resource"];
8821            params.remove_params(&to_remove);
8822        }
8823
8824        let url = params.parse_with_url(&url);
8825
8826        let mut json_mime_type = mime::APPLICATION_JSON;
8827        let mut request_value_reader = {
8828            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8829            common::remove_json_null_values(&mut value);
8830            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8831            serde_json::to_writer(&mut dst, &value).unwrap();
8832            dst
8833        };
8834        let request_size = request_value_reader
8835            .seek(std::io::SeekFrom::End(0))
8836            .unwrap();
8837        request_value_reader
8838            .seek(std::io::SeekFrom::Start(0))
8839            .unwrap();
8840
8841        loop {
8842            let token = match self
8843                .hub
8844                .auth
8845                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8846                .await
8847            {
8848                Ok(token) => token,
8849                Err(e) => match dlg.token(e) {
8850                    Ok(token) => token,
8851                    Err(e) => {
8852                        dlg.finished(false);
8853                        return Err(common::Error::MissingToken(e));
8854                    }
8855                },
8856            };
8857            request_value_reader
8858                .seek(std::io::SeekFrom::Start(0))
8859                .unwrap();
8860            let mut req_result = {
8861                let client = &self.hub.client;
8862                dlg.pre_request();
8863                let mut req_builder = hyper::Request::builder()
8864                    .method(hyper::Method::POST)
8865                    .uri(url.as_str())
8866                    .header(USER_AGENT, self.hub._user_agent.clone());
8867
8868                if let Some(token) = token.as_ref() {
8869                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8870                }
8871
8872                let request = req_builder
8873                    .header(CONTENT_TYPE, json_mime_type.to_string())
8874                    .header(CONTENT_LENGTH, request_size as u64)
8875                    .body(common::to_body(
8876                        request_value_reader.get_ref().clone().into(),
8877                    ));
8878
8879                client.request(request.unwrap()).await
8880            };
8881
8882            match req_result {
8883                Err(err) => {
8884                    if let common::Retry::After(d) = dlg.http_error(&err) {
8885                        sleep(d).await;
8886                        continue;
8887                    }
8888                    dlg.finished(false);
8889                    return Err(common::Error::HttpError(err));
8890                }
8891                Ok(res) => {
8892                    let (mut parts, body) = res.into_parts();
8893                    let mut body = common::Body::new(body);
8894                    if !parts.status.is_success() {
8895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8896                        let error = serde_json::from_str(&common::to_string(&bytes));
8897                        let response = common::to_response(parts, bytes.into());
8898
8899                        if let common::Retry::After(d) =
8900                            dlg.http_failure(&response, error.as_ref().ok())
8901                        {
8902                            sleep(d).await;
8903                            continue;
8904                        }
8905
8906                        dlg.finished(false);
8907
8908                        return Err(match error {
8909                            Ok(value) => common::Error::BadRequest(value),
8910                            _ => common::Error::Failure(response),
8911                        });
8912                    }
8913                    let response = {
8914                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8915                        let encoded = common::to_string(&bytes);
8916                        match serde_json::from_str(&encoded) {
8917                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8918                            Err(error) => {
8919                                dlg.response_json_decode_error(&encoded, &error);
8920                                return Err(common::Error::JsonDecodeError(
8921                                    encoded.to_string(),
8922                                    error,
8923                                ));
8924                            }
8925                        }
8926                    };
8927
8928                    dlg.finished(true);
8929                    return Ok(response);
8930                }
8931            }
8932        }
8933    }
8934
8935    ///
8936    /// Sets the *request* property to the given value.
8937    ///
8938    /// Even though the property as already been set when instantiating this call,
8939    /// we provide this method for API completeness.
8940    pub fn request(
8941        mut self,
8942        new_value: TestIamPermissionsRequest,
8943    ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
8944        self._request = new_value;
8945        self
8946    }
8947    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8948    ///
8949    /// Sets the *resource* path property to the given value.
8950    ///
8951    /// Even though the property as already been set when instantiating this call,
8952    /// we provide this method for API completeness.
8953    pub fn resource(
8954        mut self,
8955        new_value: &str,
8956    ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
8957        self._resource = new_value.to_string();
8958        self
8959    }
8960    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8961    /// while executing the actual API request.
8962    ///
8963    /// ````text
8964    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8965    /// ````
8966    ///
8967    /// Sets the *delegate* property to the given value.
8968    pub fn delegate(
8969        mut self,
8970        new_value: &'a mut dyn common::Delegate,
8971    ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
8972        self._delegate = Some(new_value);
8973        self
8974    }
8975
8976    /// Set any additional parameter of the query string used in the request.
8977    /// It should be used to set parameters which are not yet available through their own
8978    /// setters.
8979    ///
8980    /// Please note that this method must not be used to set any of the known parameters
8981    /// which have their own setter method. If done anyway, the request will fail.
8982    ///
8983    /// # Additional Parameters
8984    ///
8985    /// * *$.xgafv* (query-string) - V1 error format.
8986    /// * *access_token* (query-string) - OAuth access token.
8987    /// * *alt* (query-string) - Data format for response.
8988    /// * *callback* (query-string) - JSONP
8989    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8990    /// * *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.
8991    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8992    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8993    /// * *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.
8994    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8995    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8996    pub fn param<T>(
8997        mut self,
8998        name: T,
8999        value: T,
9000    ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C>
9001    where
9002        T: AsRef<str>,
9003    {
9004        self._additional_params
9005            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9006        self
9007    }
9008
9009    /// Identifies the authorization scope for the method you are building.
9010    ///
9011    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9012    /// [`Scope::CloudPlatform`].
9013    ///
9014    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9015    /// tokens for more than one scope.
9016    ///
9017    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9018    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9019    /// sufficient, a read-write scope will do as well.
9020    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryTestIamPermissionCall<'a, C>
9021    where
9022        St: AsRef<str>,
9023    {
9024        self._scopes.insert(String::from(scope.as_ref()));
9025        self
9026    }
9027    /// Identifies the authorization scope(s) for the method you are building.
9028    ///
9029    /// See [`Self::add_scope()`] for details.
9030    pub fn add_scopes<I, St>(
9031        mut self,
9032        scopes: I,
9033    ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C>
9034    where
9035        I: IntoIterator<Item = St>,
9036        St: AsRef<str>,
9037    {
9038        self._scopes
9039            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9040        self
9041    }
9042
9043    /// Removes all scopes, and no default scope will be used either.
9044    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9045    /// for details).
9046    pub fn clear_scopes(mut self) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
9047        self._scopes.clear();
9048        self
9049    }
9050}
9051
9052/// Deletes the association between the device and the gateway.
9053///
9054/// A builder for the *locations.registries.unbindDeviceFromGateway* method supported by a *project* resource.
9055/// It is not used directly, but through a [`ProjectMethods`] instance.
9056///
9057/// # Example
9058///
9059/// Instantiate a resource method builder
9060///
9061/// ```test_harness,no_run
9062/// # extern crate hyper;
9063/// # extern crate hyper_rustls;
9064/// # extern crate google_cloudiot1 as cloudiot1;
9065/// use cloudiot1::api::UnbindDeviceFromGatewayRequest;
9066/// # async fn dox() {
9067/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9068///
9069/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9070/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9071/// #     .with_native_roots()
9072/// #     .unwrap()
9073/// #     .https_only()
9074/// #     .enable_http2()
9075/// #     .build();
9076///
9077/// # let executor = hyper_util::rt::TokioExecutor::new();
9078/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9079/// #     secret,
9080/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9081/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9082/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9083/// #     ),
9084/// # ).build().await.unwrap();
9085///
9086/// # let client = hyper_util::client::legacy::Client::builder(
9087/// #     hyper_util::rt::TokioExecutor::new()
9088/// # )
9089/// # .build(
9090/// #     hyper_rustls::HttpsConnectorBuilder::new()
9091/// #         .with_native_roots()
9092/// #         .unwrap()
9093/// #         .https_or_http()
9094/// #         .enable_http2()
9095/// #         .build()
9096/// # );
9097/// # let mut hub = CloudIot::new(client, auth);
9098/// // As the method needs a request, you would usually fill it with the desired information
9099/// // into the respective structure. Some of the parts shown here might not be applicable !
9100/// // Values shown here are possibly random and not representative !
9101/// let mut req = UnbindDeviceFromGatewayRequest::default();
9102///
9103/// // You can configure optional parameters by calling the respective setters at will, and
9104/// // execute the final call using `doit()`.
9105/// // Values shown here are possibly random and not representative !
9106/// let result = hub.projects().locations_registries_unbind_device_from_gateway(req, "parent")
9107///              .doit().await;
9108/// # }
9109/// ```
9110pub struct ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9111where
9112    C: 'a,
9113{
9114    hub: &'a CloudIot<C>,
9115    _request: UnbindDeviceFromGatewayRequest,
9116    _parent: String,
9117    _delegate: Option<&'a mut dyn common::Delegate>,
9118    _additional_params: HashMap<String, String>,
9119    _scopes: BTreeSet<String>,
9120}
9121
9122impl<'a, C> common::CallBuilder for ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {}
9123
9124impl<'a, C> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9125where
9126    C: common::Connector,
9127{
9128    /// Perform the operation you have build so far.
9129    pub async fn doit(
9130        mut self,
9131    ) -> common::Result<(common::Response, UnbindDeviceFromGatewayResponse)> {
9132        use std::borrow::Cow;
9133        use std::io::{Read, Seek};
9134
9135        use common::{url::Params, ToParts};
9136        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9137
9138        let mut dd = common::DefaultDelegate;
9139        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9140        dlg.begin(common::MethodInfo {
9141            id: "cloudiot.projects.locations.registries.unbindDeviceFromGateway",
9142            http_method: hyper::Method::POST,
9143        });
9144
9145        for &field in ["alt", "parent"].iter() {
9146            if self._additional_params.contains_key(field) {
9147                dlg.finished(false);
9148                return Err(common::Error::FieldClash(field));
9149            }
9150        }
9151
9152        let mut params = Params::with_capacity(4 + self._additional_params.len());
9153        params.push("parent", self._parent);
9154
9155        params.extend(self._additional_params.iter());
9156
9157        params.push("alt", "json");
9158        let mut url = self.hub._base_url.clone() + "v1/{+parent}:unbindDeviceFromGateway";
9159        if self._scopes.is_empty() {
9160            self._scopes
9161                .insert(Scope::CloudPlatform.as_ref().to_string());
9162        }
9163
9164        #[allow(clippy::single_element_loop)]
9165        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9166            url = params.uri_replacement(url, param_name, find_this, true);
9167        }
9168        {
9169            let to_remove = ["parent"];
9170            params.remove_params(&to_remove);
9171        }
9172
9173        let url = params.parse_with_url(&url);
9174
9175        let mut json_mime_type = mime::APPLICATION_JSON;
9176        let mut request_value_reader = {
9177            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9178            common::remove_json_null_values(&mut value);
9179            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9180            serde_json::to_writer(&mut dst, &value).unwrap();
9181            dst
9182        };
9183        let request_size = request_value_reader
9184            .seek(std::io::SeekFrom::End(0))
9185            .unwrap();
9186        request_value_reader
9187            .seek(std::io::SeekFrom::Start(0))
9188            .unwrap();
9189
9190        loop {
9191            let token = match self
9192                .hub
9193                .auth
9194                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9195                .await
9196            {
9197                Ok(token) => token,
9198                Err(e) => match dlg.token(e) {
9199                    Ok(token) => token,
9200                    Err(e) => {
9201                        dlg.finished(false);
9202                        return Err(common::Error::MissingToken(e));
9203                    }
9204                },
9205            };
9206            request_value_reader
9207                .seek(std::io::SeekFrom::Start(0))
9208                .unwrap();
9209            let mut req_result = {
9210                let client = &self.hub.client;
9211                dlg.pre_request();
9212                let mut req_builder = hyper::Request::builder()
9213                    .method(hyper::Method::POST)
9214                    .uri(url.as_str())
9215                    .header(USER_AGENT, self.hub._user_agent.clone());
9216
9217                if let Some(token) = token.as_ref() {
9218                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9219                }
9220
9221                let request = req_builder
9222                    .header(CONTENT_TYPE, json_mime_type.to_string())
9223                    .header(CONTENT_LENGTH, request_size as u64)
9224                    .body(common::to_body(
9225                        request_value_reader.get_ref().clone().into(),
9226                    ));
9227
9228                client.request(request.unwrap()).await
9229            };
9230
9231            match req_result {
9232                Err(err) => {
9233                    if let common::Retry::After(d) = dlg.http_error(&err) {
9234                        sleep(d).await;
9235                        continue;
9236                    }
9237                    dlg.finished(false);
9238                    return Err(common::Error::HttpError(err));
9239                }
9240                Ok(res) => {
9241                    let (mut parts, body) = res.into_parts();
9242                    let mut body = common::Body::new(body);
9243                    if !parts.status.is_success() {
9244                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9245                        let error = serde_json::from_str(&common::to_string(&bytes));
9246                        let response = common::to_response(parts, bytes.into());
9247
9248                        if let common::Retry::After(d) =
9249                            dlg.http_failure(&response, error.as_ref().ok())
9250                        {
9251                            sleep(d).await;
9252                            continue;
9253                        }
9254
9255                        dlg.finished(false);
9256
9257                        return Err(match error {
9258                            Ok(value) => common::Error::BadRequest(value),
9259                            _ => common::Error::Failure(response),
9260                        });
9261                    }
9262                    let response = {
9263                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9264                        let encoded = common::to_string(&bytes);
9265                        match serde_json::from_str(&encoded) {
9266                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9267                            Err(error) => {
9268                                dlg.response_json_decode_error(&encoded, &error);
9269                                return Err(common::Error::JsonDecodeError(
9270                                    encoded.to_string(),
9271                                    error,
9272                                ));
9273                            }
9274                        }
9275                    };
9276
9277                    dlg.finished(true);
9278                    return Ok(response);
9279                }
9280            }
9281        }
9282    }
9283
9284    ///
9285    /// Sets the *request* property to the given value.
9286    ///
9287    /// Even though the property as already been set when instantiating this call,
9288    /// we provide this method for API completeness.
9289    pub fn request(
9290        mut self,
9291        new_value: UnbindDeviceFromGatewayRequest,
9292    ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9293        self._request = new_value;
9294        self
9295    }
9296    /// Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
9297    ///
9298    /// Sets the *parent* path property to the given value.
9299    ///
9300    /// Even though the property as already been set when instantiating this call,
9301    /// we provide this method for API completeness.
9302    pub fn parent(
9303        mut self,
9304        new_value: &str,
9305    ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9306        self._parent = new_value.to_string();
9307        self
9308    }
9309    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9310    /// while executing the actual API request.
9311    ///
9312    /// ````text
9313    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9314    /// ````
9315    ///
9316    /// Sets the *delegate* property to the given value.
9317    pub fn delegate(
9318        mut self,
9319        new_value: &'a mut dyn common::Delegate,
9320    ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9321        self._delegate = Some(new_value);
9322        self
9323    }
9324
9325    /// Set any additional parameter of the query string used in the request.
9326    /// It should be used to set parameters which are not yet available through their own
9327    /// setters.
9328    ///
9329    /// Please note that this method must not be used to set any of the known parameters
9330    /// which have their own setter method. If done anyway, the request will fail.
9331    ///
9332    /// # Additional Parameters
9333    ///
9334    /// * *$.xgafv* (query-string) - V1 error format.
9335    /// * *access_token* (query-string) - OAuth access token.
9336    /// * *alt* (query-string) - Data format for response.
9337    /// * *callback* (query-string) - JSONP
9338    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9339    /// * *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.
9340    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9341    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9342    /// * *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.
9343    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9344    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9345    pub fn param<T>(
9346        mut self,
9347        name: T,
9348        value: T,
9349    ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9350    where
9351        T: AsRef<str>,
9352    {
9353        self._additional_params
9354            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9355        self
9356    }
9357
9358    /// Identifies the authorization scope for the method you are building.
9359    ///
9360    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9361    /// [`Scope::CloudPlatform`].
9362    ///
9363    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9364    /// tokens for more than one scope.
9365    ///
9366    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9367    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9368    /// sufficient, a read-write scope will do as well.
9369    pub fn add_scope<St>(
9370        mut self,
9371        scope: St,
9372    ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9373    where
9374        St: AsRef<str>,
9375    {
9376        self._scopes.insert(String::from(scope.as_ref()));
9377        self
9378    }
9379    /// Identifies the authorization scope(s) for the method you are building.
9380    ///
9381    /// See [`Self::add_scope()`] for details.
9382    pub fn add_scopes<I, St>(
9383        mut self,
9384        scopes: I,
9385    ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9386    where
9387        I: IntoIterator<Item = St>,
9388        St: AsRef<str>,
9389    {
9390        self._scopes
9391            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9392        self
9393    }
9394
9395    /// Removes all scopes, and no default scope will be used either.
9396    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9397    /// for details).
9398    pub fn clear_scopes(mut self) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9399        self._scopes.clear();
9400        self
9401    }
9402}