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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67/// secret,
68/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72/// hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75/// hyper_rustls::HttpsConnectorBuilder::new()
76/// .with_native_roots()
77/// .unwrap()
78/// .https_or_http()
79/// .enable_http1()
80/// .build()
81/// );
82/// let mut hub = CloudIot::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = GetIamPolicyRequest::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.projects().locations_registries_groups_get_iam_policy(req, "resource")
92/// .doit().await;
93///
94/// match result {
95/// Err(e) => match e {
96/// // The Error enum provides details about what exactly happened.
97/// // You can also just use its `Debug`, `Display` or `Error` traits
98/// Error::HttpError(_)
99/// |Error::Io(_)
100/// |Error::MissingAPIKey
101/// |Error::MissingToken(_)
102/// |Error::Cancelled
103/// |Error::UploadSizeLimitExceeded(_, _)
104/// |Error::Failure(_)
105/// |Error::BadRequest(_)
106/// |Error::FieldClash(_)
107/// |Error::JsonDecodeError(_, _) => println!("{}", e),
108/// },
109/// Ok(res) => println!("Success: {:?}", res),
110/// }
111/// # }
112/// ```
113#[derive(Clone)]
114pub struct CloudIot<C> {
115 pub client: common::Client<C>,
116 pub auth: Box<dyn common::GetToken>,
117 _user_agent: String,
118 _base_url: String,
119 _root_url: String,
120}
121
122impl<C> common::Hub for CloudIot<C> {}
123
124impl<'a, C> CloudIot<C> {
125 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudIot<C> {
126 CloudIot {
127 client,
128 auth: Box::new(auth),
129 _user_agent: "google-api-rust-client/6.0.0".to_string(),
130 _base_url: "https://cloudiot.googleapis.com/".to_string(),
131 _root_url: "https://cloudiot.googleapis.com/".to_string(),
132 }
133 }
134
135 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136 ProjectMethods { hub: self }
137 }
138
139 /// Set the user-agent header field to use in all requests to the server.
140 /// It defaults to `google-api-rust-client/6.0.0`.
141 ///
142 /// Returns the previously set user-agent.
143 pub fn user_agent(&mut self, agent_name: String) -> String {
144 std::mem::replace(&mut self._user_agent, agent_name)
145 }
146
147 /// Set the base url to use in all requests to the server.
148 /// It defaults to `https://cloudiot.googleapis.com/`.
149 ///
150 /// Returns the previously set base url.
151 pub fn base_url(&mut self, new_base_url: String) -> String {
152 std::mem::replace(&mut self._base_url, new_base_url)
153 }
154
155 /// Set the root url to use in all requests to the server.
156 /// It defaults to `https://cloudiot.googleapis.com/`.
157 ///
158 /// Returns the previously set root url.
159 pub fn root_url(&mut self, new_root_url: String) -> String {
160 std::mem::replace(&mut self._root_url, new_root_url)
161 }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// Request for `BindDeviceToGateway`.
168///
169/// # Activities
170///
171/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
172/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
173///
174/// * [locations registries bind device to gateway projects](ProjectLocationRegistryBindDeviceToGatewayCall) (request)
175#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
176#[serde_with::serde_as]
177#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
178pub struct BindDeviceToGatewayRequest {
179 /// 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.
180 #[serde(rename = "deviceId")]
181 pub device_id: Option<String>,
182 /// Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.
183 #[serde(rename = "gatewayId")]
184 pub gateway_id: Option<String>,
185}
186
187impl common::RequestValue for BindDeviceToGatewayRequest {}
188
189/// Response for `BindDeviceToGateway`.
190///
191/// # Activities
192///
193/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
194/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
195///
196/// * [locations registries bind device to gateway projects](ProjectLocationRegistryBindDeviceToGatewayCall) (response)
197#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
198#[serde_with::serde_as]
199#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
200pub struct BindDeviceToGatewayResponse {
201 _never_set: Option<bool>,
202}
203
204impl common::ResponseResult for BindDeviceToGatewayResponse {}
205
206/// Associates `members`, or principals, with a `role`.
207///
208/// This type is not used in any activity, and only used as *part* of another schema.
209///
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct Binding {
214 /// 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).
215 pub condition: Option<Expr>,
216 /// 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`.
217 pub members: Option<Vec<String>>,
218 /// 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).
219 pub role: Option<String>,
220}
221
222impl common::Part for Binding {}
223
224/// The device resource.
225///
226/// # Activities
227///
228/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
229/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
230///
231/// * [locations registries devices create projects](ProjectLocationRegistryDeviceCreateCall) (request|response)
232/// * [locations registries devices get projects](ProjectLocationRegistryDeviceGetCall) (response)
233/// * [locations registries devices patch projects](ProjectLocationRegistryDevicePatchCall) (request|response)
234#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
235#[serde_with::serde_as]
236#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
237pub struct Device {
238 /// 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.
239 pub blocked: Option<bool>,
240 /// 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.
241 pub config: Option<DeviceConfig>,
242 /// 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.
243 pub credentials: Option<Vec<DeviceCredential>>,
244 /// Gateway-related configuration and state.
245 #[serde(rename = "gatewayConfig")]
246 pub gateway_config: Option<GatewayConfig>,
247 /// The user-defined device identifier. The device ID must be unique within a device registry.
248 pub id: Option<String>,
249 /// [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.
250 #[serde(rename = "lastConfigAckTime")]
251 pub last_config_ack_time: Option<chrono::DateTime<chrono::offset::Utc>>,
252 /// [Output only] The last time a cloud-to-device config version was sent to the device.
253 #[serde(rename = "lastConfigSendTime")]
254 pub last_config_send_time: Option<chrono::DateTime<chrono::offset::Utc>>,
255 /// [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.
256 #[serde(rename = "lastErrorStatus")]
257 pub last_error_status: Option<Status>,
258 /// [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'.
259 #[serde(rename = "lastErrorTime")]
260 pub last_error_time: Option<chrono::DateTime<chrono::offset::Utc>>,
261 /// [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.
262 #[serde(rename = "lastEventTime")]
263 pub last_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
264 /// [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.
265 #[serde(rename = "lastHeartbeatTime")]
266 pub last_heartbeat_time: Option<chrono::DateTime<chrono::offset::Utc>>,
267 /// [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.
268 #[serde(rename = "lastStateTime")]
269 pub last_state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
270 /// **Beta Feature** The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.
271 #[serde(rename = "logLevel")]
272 pub log_level: Option<String>,
273 /// 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.
274 pub metadata: Option<HashMap<String, String>>,
275 /// 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.
276 pub name: Option<String>,
277 /// [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.
278 #[serde(rename = "numId")]
279 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
280 pub num_id: Option<u64>,
281 /// [Output only] The state most recently received from the device. If no state has been reported, this field is not present.
282 pub state: Option<DeviceState>,
283}
284
285impl common::RequestValue for Device {}
286impl common::ResponseResult for Device {}
287
288/// The device configuration. Eventually delivered to devices.
289///
290/// # Activities
291///
292/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
293/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
294///
295/// * [locations registries devices modify cloud to device config projects](ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall) (response)
296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
297#[serde_with::serde_as]
298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
299pub struct DeviceConfig {
300 /// The device configuration data.
301 #[serde(rename = "binaryData")]
302 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
303 pub binary_data: Option<Vec<u8>>,
304 /// [Output only] The time at which this configuration version was updated in Cloud IoT Core. This timestamp is set by the server.
305 #[serde(rename = "cloudUpdateTime")]
306 pub cloud_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
307 /// [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.
308 #[serde(rename = "deviceAckTime")]
309 pub device_ack_time: Option<chrono::DateTime<chrono::offset::Utc>>,
310 /// [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.
311 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
312 pub version: Option<i64>,
313}
314
315impl common::ResponseResult for DeviceConfig {}
316
317/// A server-stored device credential used for authentication.
318///
319/// This type is not used in any activity, and only used as *part* of another schema.
320///
321#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
322#[serde_with::serde_as]
323#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
324pub struct DeviceCredential {
325 /// [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.
326 #[serde(rename = "expirationTime")]
327 pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
328 /// 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.
329 #[serde(rename = "publicKey")]
330 pub public_key: Option<PublicKeyCredential>,
331}
332
333impl common::Part for DeviceCredential {}
334
335/// A container for a group of devices.
336///
337/// # Activities
338///
339/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
340/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
341///
342/// * [locations registries create projects](ProjectLocationRegistryCreateCall) (request|response)
343/// * [locations registries get projects](ProjectLocationRegistryGetCall) (response)
344/// * [locations registries patch projects](ProjectLocationRegistryPatchCall) (request|response)
345#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
346#[serde_with::serde_as]
347#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
348pub struct DeviceRegistry {
349 /// 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.
350 pub credentials: Option<Vec<RegistryCredential>>,
351 /// 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.
352 #[serde(rename = "eventNotificationConfigs")]
353 pub event_notification_configs: Option<Vec<EventNotificationConfig>>,
354 /// The DeviceService (HTTP) configuration for this device registry.
355 #[serde(rename = "httpConfig")]
356 pub http_config: Option<HttpConfig>,
357 /// The identifier of this device registry. For example, `myRegistry`.
358 pub id: Option<String>,
359 /// **Beta Feature** The default logging verbosity for activity from devices in this registry. The verbosity level can be overridden by Device.log_level.
360 #[serde(rename = "logLevel")]
361 pub log_level: Option<String>,
362 /// The MQTT configuration for this device registry.
363 #[serde(rename = "mqttConfig")]
364 pub mqtt_config: Option<MqttConfig>,
365 /// The resource path name. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
366 pub name: Option<String>,
367 /// 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.
368 #[serde(rename = "stateNotificationConfig")]
369 pub state_notification_config: Option<StateNotificationConfig>,
370}
371
372impl common::RequestValue for DeviceRegistry {}
373impl common::ResponseResult for DeviceRegistry {}
374
375/// The device state, as reported by the device.
376///
377/// This type is not used in any activity, and only used as *part* of another schema.
378///
379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
380#[serde_with::serde_as]
381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
382pub struct DeviceState {
383 /// The device state data.
384 #[serde(rename = "binaryData")]
385 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
386 pub binary_data: Option<Vec<u8>>,
387 /// [Output only] The time at which this state version was updated in Cloud IoT Core.
388 #[serde(rename = "updateTime")]
389 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
390}
391
392impl common::Part for DeviceState {}
393
394/// 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); }
395///
396/// # Activities
397///
398/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
399/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
400///
401/// * [locations registries devices delete projects](ProjectLocationRegistryDeviceDeleteCall) (response)
402/// * [locations registries delete projects](ProjectLocationRegistryDeleteCall) (response)
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct Empty {
407 _never_set: Option<bool>,
408}
409
410impl common::ResponseResult for Empty {}
411
412/// The configuration for forwarding telemetry events.
413///
414/// This type is not used in any activity, and only used as *part* of another schema.
415///
416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
417#[serde_with::serde_as]
418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
419pub struct EventNotificationConfig {
420 /// A Cloud Pub/Sub topic name. For example, `projects/myProject/topics/deviceEvents`.
421 #[serde(rename = "pubsubTopicName")]
422 pub pubsub_topic_name: Option<String>,
423 /// 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.
424 #[serde(rename = "subfolderMatches")]
425 pub subfolder_matches: Option<String>,
426}
427
428impl common::Part for EventNotificationConfig {}
429
430/// 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.
431///
432/// This type is not used in any activity, and only used as *part* of another schema.
433///
434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
435#[serde_with::serde_as]
436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
437pub struct Expr {
438 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
439 pub description: Option<String>,
440 /// Textual representation of an expression in Common Expression Language syntax.
441 pub expression: Option<String>,
442 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
443 pub location: Option<String>,
444 /// 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.
445 pub title: Option<String>,
446}
447
448impl common::Part for Expr {}
449
450/// Gateway-related configuration and state.
451///
452/// This type is not used in any activity, and only used as *part* of another schema.
453///
454#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
455#[serde_with::serde_as]
456#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
457pub struct GatewayConfig {
458 /// Indicates how to authorize and/or authenticate devices to access the gateway.
459 #[serde(rename = "gatewayAuthMethod")]
460 pub gateway_auth_method: Option<String>,
461 /// Indicates whether the device is a gateway.
462 #[serde(rename = "gatewayType")]
463 pub gateway_type: Option<String>,
464 /// [Output only] The ID of the gateway the device accessed most recently.
465 #[serde(rename = "lastAccessedGatewayId")]
466 pub last_accessed_gateway_id: Option<String>,
467 /// [Output only] The most recent time at which the device accessed the gateway specified in `last_accessed_gateway`.
468 #[serde(rename = "lastAccessedGatewayTime")]
469 pub last_accessed_gateway_time: Option<chrono::DateTime<chrono::offset::Utc>>,
470}
471
472impl common::Part for GatewayConfig {}
473
474/// Request message for `GetIamPolicy` method.
475///
476/// # Activities
477///
478/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
479/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
480///
481/// * [locations registries groups get iam policy projects](ProjectLocationRegistryGroupGetIamPolicyCall) (request)
482/// * [locations registries get iam policy projects](ProjectLocationRegistryGetIamPolicyCall) (request)
483#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
484#[serde_with::serde_as]
485#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
486pub struct GetIamPolicyRequest {
487 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
488 pub options: Option<GetPolicyOptions>,
489}
490
491impl common::RequestValue for GetIamPolicyRequest {}
492
493/// Encapsulates settings provided to GetIamPolicy.
494///
495/// This type is not used in any activity, and only used as *part* of another schema.
496///
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct GetPolicyOptions {
501 /// 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).
502 #[serde(rename = "requestedPolicyVersion")]
503 pub requested_policy_version: Option<i32>,
504}
505
506impl common::Part for GetPolicyOptions {}
507
508/// The configuration of the HTTP bridge for a device registry.
509///
510/// This type is not used in any activity, and only used as *part* of another schema.
511///
512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
513#[serde_with::serde_as]
514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
515pub struct HttpConfig {
516 /// If enabled, allows devices to use DeviceService via the HTTP protocol. Otherwise, any requests to DeviceService will fail for this registry.
517 #[serde(rename = "httpEnabledState")]
518 pub http_enabled_state: Option<String>,
519}
520
521impl common::Part for HttpConfig {}
522
523/// Response for `ListDeviceConfigVersions`.
524///
525/// # Activities
526///
527/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
528/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
529///
530/// * [locations registries devices config versions list projects](ProjectLocationRegistryDeviceConfigVersionListCall) (response)
531#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
532#[serde_with::serde_as]
533#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
534pub struct ListDeviceConfigVersionsResponse {
535 /// The device configuration for the last few versions. Versions are listed in decreasing order, starting from the most recent one.
536 #[serde(rename = "deviceConfigs")]
537 pub device_configs: Option<Vec<DeviceConfig>>,
538}
539
540impl common::ResponseResult for ListDeviceConfigVersionsResponse {}
541
542/// Response for `ListDeviceRegistries`.
543///
544/// # Activities
545///
546/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
547/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
548///
549/// * [locations registries list projects](ProjectLocationRegistryListCall) (response)
550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
551#[serde_with::serde_as]
552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
553pub struct ListDeviceRegistriesResponse {
554 /// The registries that matched the query.
555 #[serde(rename = "deviceRegistries")]
556 pub device_registries: Option<Vec<DeviceRegistry>>,
557 /// If not empty, indicates that there may be more registries that match the request; this value should be passed in a new `ListDeviceRegistriesRequest`.
558 #[serde(rename = "nextPageToken")]
559 pub next_page_token: Option<String>,
560}
561
562impl common::ResponseResult for ListDeviceRegistriesResponse {}
563
564/// Response for `ListDeviceStates`.
565///
566/// # Activities
567///
568/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
569/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
570///
571/// * [locations registries devices states list projects](ProjectLocationRegistryDeviceStateListCall) (response)
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct ListDeviceStatesResponse {
576 /// The last few device states. States are listed in descending order of server update time, starting from the most recent one.
577 #[serde(rename = "deviceStates")]
578 pub device_states: Option<Vec<DeviceState>>,
579}
580
581impl common::ResponseResult for ListDeviceStatesResponse {}
582
583/// Response for `ListDevices`.
584///
585/// # Activities
586///
587/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
588/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
589///
590/// * [locations registries devices list projects](ProjectLocationRegistryDeviceListCall) (response)
591/// * [locations registries groups devices list projects](ProjectLocationRegistryGroupDeviceListCall) (response)
592#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
593#[serde_with::serde_as]
594#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
595pub struct ListDevicesResponse {
596 /// The devices that match the request.
597 pub devices: Option<Vec<Device>>,
598 /// If not empty, indicates that there may be more devices that match the request; this value should be passed in a new `ListDevicesRequest`.
599 #[serde(rename = "nextPageToken")]
600 pub next_page_token: Option<String>,
601}
602
603impl common::ResponseResult for ListDevicesResponse {}
604
605/// Request for `ModifyCloudToDeviceConfig`.
606///
607/// # Activities
608///
609/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
610/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
611///
612/// * [locations registries devices modify cloud to device config projects](ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall) (request)
613#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
614#[serde_with::serde_as]
615#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
616pub struct ModifyCloudToDeviceConfigRequest {
617 /// Required. The configuration data for the device.
618 #[serde(rename = "binaryData")]
619 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
620 pub binary_data: Option<Vec<u8>>,
621 /// 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.
622 #[serde(rename = "versionToUpdate")]
623 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
624 pub version_to_update: Option<i64>,
625}
626
627impl common::RequestValue for ModifyCloudToDeviceConfigRequest {}
628
629/// The configuration of MQTT for a device registry.
630///
631/// This type is not used in any activity, and only used as *part* of another schema.
632///
633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
634#[serde_with::serde_as]
635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
636pub struct MqttConfig {
637 /// If enabled, allows connections using the MQTT protocol. Otherwise, MQTT connections to this registry will fail.
638 #[serde(rename = "mqttEnabledState")]
639 pub mqtt_enabled_state: Option<String>,
640}
641
642impl common::Part for MqttConfig {}
643
644/// 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/).
645///
646/// # Activities
647///
648/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
649/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
650///
651/// * [locations registries groups get iam policy projects](ProjectLocationRegistryGroupGetIamPolicyCall) (response)
652/// * [locations registries groups set iam policy projects](ProjectLocationRegistryGroupSetIamPolicyCall) (response)
653/// * [locations registries get iam policy projects](ProjectLocationRegistryGetIamPolicyCall) (response)
654/// * [locations registries set iam policy projects](ProjectLocationRegistrySetIamPolicyCall) (response)
655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
656#[serde_with::serde_as]
657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
658pub struct Policy {
659 /// 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`.
660 pub bindings: Option<Vec<Binding>>,
661 /// `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.
662 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
663 pub etag: Option<Vec<u8>>,
664 /// 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).
665 pub version: Option<i32>,
666}
667
668impl common::ResponseResult for Policy {}
669
670/// A public key certificate format and data.
671///
672/// This type is not used in any activity, and only used as *part* of another schema.
673///
674#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
675#[serde_with::serde_as]
676#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
677pub struct PublicKeyCertificate {
678 /// The certificate data.
679 pub certificate: Option<String>,
680 /// The certificate format.
681 pub format: Option<String>,
682 /// [Output only] The certificate details. Used only for X.509 certificates.
683 #[serde(rename = "x509Details")]
684 pub x509_details: Option<X509CertificateDetails>,
685}
686
687impl common::Part for PublicKeyCertificate {}
688
689/// A public key format and data.
690///
691/// This type is not used in any activity, and only used as *part* of another schema.
692///
693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
694#[serde_with::serde_as]
695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
696pub struct PublicKeyCredential {
697 /// The format of the key.
698 pub format: Option<String>,
699 /// The key data.
700 pub key: Option<String>,
701}
702
703impl common::Part for PublicKeyCredential {}
704
705/// A server-stored registry credential used to validate device credentials.
706///
707/// This type is not used in any activity, and only used as *part* of another schema.
708///
709#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
710#[serde_with::serde_as]
711#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
712pub struct RegistryCredential {
713 /// A public key certificate used to verify the device credentials.
714 #[serde(rename = "publicKeyCertificate")]
715 pub public_key_certificate: Option<PublicKeyCertificate>,
716}
717
718impl common::Part for RegistryCredential {}
719
720/// Request for `SendCommandToDevice`.
721///
722/// # Activities
723///
724/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
725/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
726///
727/// * [locations registries devices send command to device projects](ProjectLocationRegistryDeviceSendCommandToDeviceCall) (request)
728#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
729#[serde_with::serde_as]
730#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
731pub struct SendCommandToDeviceRequest {
732 /// Required. The command data to send to the device.
733 #[serde(rename = "binaryData")]
734 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
735 pub binary_data: Option<Vec<u8>>,
736 /// 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.
737 pub subfolder: Option<String>,
738}
739
740impl common::RequestValue for SendCommandToDeviceRequest {}
741
742/// Response for `SendCommandToDevice`.
743///
744/// # Activities
745///
746/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
747/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
748///
749/// * [locations registries devices send command to device projects](ProjectLocationRegistryDeviceSendCommandToDeviceCall) (response)
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct SendCommandToDeviceResponse {
754 _never_set: Option<bool>,
755}
756
757impl common::ResponseResult for SendCommandToDeviceResponse {}
758
759/// Request message for `SetIamPolicy` method.
760///
761/// # Activities
762///
763/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
764/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
765///
766/// * [locations registries groups set iam policy projects](ProjectLocationRegistryGroupSetIamPolicyCall) (request)
767/// * [locations registries set iam policy projects](ProjectLocationRegistrySetIamPolicyCall) (request)
768#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
769#[serde_with::serde_as]
770#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
771pub struct SetIamPolicyRequest {
772 /// 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.
773 pub policy: Option<Policy>,
774}
775
776impl common::RequestValue for SetIamPolicyRequest {}
777
778/// The configuration for notification of new states received from the device.
779///
780/// This type is not used in any activity, and only used as *part* of another schema.
781///
782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
783#[serde_with::serde_as]
784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
785pub struct StateNotificationConfig {
786 /// A Cloud Pub/Sub topic name. For example, `projects/myProject/topics/deviceEvents`.
787 #[serde(rename = "pubsubTopicName")]
788 pub pubsub_topic_name: Option<String>,
789}
790
791impl common::Part for StateNotificationConfig {}
792
793/// 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).
794///
795/// This type is not used in any activity, and only used as *part* of another schema.
796///
797#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
798#[serde_with::serde_as]
799#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
800pub struct Status {
801 /// The status code, which should be an enum value of google.rpc.Code.
802 pub code: Option<i32>,
803 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
804 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
805 /// 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.
806 pub message: Option<String>,
807}
808
809impl common::Part for Status {}
810
811/// Request message for `TestIamPermissions` method.
812///
813/// # Activities
814///
815/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
816/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
817///
818/// * [locations registries groups test iam permissions projects](ProjectLocationRegistryGroupTestIamPermissionCall) (request)
819/// * [locations registries test iam permissions projects](ProjectLocationRegistryTestIamPermissionCall) (request)
820#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
821#[serde_with::serde_as]
822#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
823pub struct TestIamPermissionsRequest {
824 /// 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).
825 pub permissions: Option<Vec<String>>,
826}
827
828impl common::RequestValue for TestIamPermissionsRequest {}
829
830/// Response message for `TestIamPermissions` method.
831///
832/// # Activities
833///
834/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
835/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
836///
837/// * [locations registries groups test iam permissions projects](ProjectLocationRegistryGroupTestIamPermissionCall) (response)
838/// * [locations registries test iam permissions projects](ProjectLocationRegistryTestIamPermissionCall) (response)
839#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
840#[serde_with::serde_as]
841#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
842pub struct TestIamPermissionsResponse {
843 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
844 pub permissions: Option<Vec<String>>,
845}
846
847impl common::ResponseResult for TestIamPermissionsResponse {}
848
849/// Request for `UnbindDeviceFromGateway`.
850///
851/// # Activities
852///
853/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
854/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
855///
856/// * [locations registries unbind device from gateway projects](ProjectLocationRegistryUnbindDeviceFromGatewayCall) (request)
857#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
858#[serde_with::serde_as]
859#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
860pub struct UnbindDeviceFromGatewayRequest {
861 /// 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.
862 #[serde(rename = "deviceId")]
863 pub device_id: Option<String>,
864 /// Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.
865 #[serde(rename = "gatewayId")]
866 pub gateway_id: Option<String>,
867}
868
869impl common::RequestValue for UnbindDeviceFromGatewayRequest {}
870
871/// Response for `UnbindDeviceFromGateway`.
872///
873/// # Activities
874///
875/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
876/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
877///
878/// * [locations registries unbind device from gateway projects](ProjectLocationRegistryUnbindDeviceFromGatewayCall) (response)
879#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
880#[serde_with::serde_as]
881#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
882pub struct UnbindDeviceFromGatewayResponse {
883 _never_set: Option<bool>,
884}
885
886impl common::ResponseResult for UnbindDeviceFromGatewayResponse {}
887
888/// Details of an X.509 certificate. For informational purposes only.
889///
890/// This type is not used in any activity, and only used as *part* of another schema.
891///
892#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
893#[serde_with::serde_as]
894#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
895pub struct X509CertificateDetails {
896 /// The time the certificate becomes invalid.
897 #[serde(rename = "expiryTime")]
898 pub expiry_time: Option<chrono::DateTime<chrono::offset::Utc>>,
899 /// The entity that signed the certificate.
900 pub issuer: Option<String>,
901 /// The type of public key in the certificate.
902 #[serde(rename = "publicKeyType")]
903 pub public_key_type: Option<String>,
904 /// The algorithm used to sign the certificate.
905 #[serde(rename = "signatureAlgorithm")]
906 pub signature_algorithm: Option<String>,
907 /// The time the certificate becomes valid.
908 #[serde(rename = "startTime")]
909 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
910 /// The entity the certificate and public key belong to.
911 pub subject: Option<String>,
912}
913
914impl common::Part for X509CertificateDetails {}
915
916// ###################
917// MethodBuilders ###
918// #################
919
920/// A builder providing access to all methods supported on *project* resources.
921/// It is not used directly, but through the [`CloudIot`] hub.
922///
923/// # Example
924///
925/// Instantiate a resource builder
926///
927/// ```test_harness,no_run
928/// extern crate hyper;
929/// extern crate hyper_rustls;
930/// extern crate google_cloudiot1 as cloudiot1;
931///
932/// # async fn dox() {
933/// use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
934///
935/// let secret: yup_oauth2::ApplicationSecret = Default::default();
936/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
937/// secret,
938/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
939/// ).build().await.unwrap();
940///
941/// let client = hyper_util::client::legacy::Client::builder(
942/// hyper_util::rt::TokioExecutor::new()
943/// )
944/// .build(
945/// hyper_rustls::HttpsConnectorBuilder::new()
946/// .with_native_roots()
947/// .unwrap()
948/// .https_or_http()
949/// .enable_http1()
950/// .build()
951/// );
952/// let mut hub = CloudIot::new(client, auth);
953/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
954/// // 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(...)`
955/// // to build up your call.
956/// let rb = hub.projects();
957/// # }
958/// ```
959pub struct ProjectMethods<'a, C>
960where
961 C: 'a,
962{
963 hub: &'a CloudIot<C>,
964}
965
966impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
967
968impl<'a, C> ProjectMethods<'a, C> {
969 /// Create a builder to help you perform the following task:
970 ///
971 /// Lists the last few versions of the device configuration in descending order (i.e.: newest first).
972 ///
973 /// # Arguments
974 ///
975 /// * `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}`.
976 pub fn locations_registries_devices_config_versions_list(
977 &self,
978 name: &str,
979 ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
980 ProjectLocationRegistryDeviceConfigVersionListCall {
981 hub: self.hub,
982 _name: name.to_string(),
983 _num_versions: Default::default(),
984 _delegate: Default::default(),
985 _additional_params: Default::default(),
986 _scopes: Default::default(),
987 }
988 }
989
990 /// Create a builder to help you perform the following task:
991 ///
992 /// Lists the last few versions of the device state in descending order (i.e.: newest first).
993 ///
994 /// # Arguments
995 ///
996 /// * `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}`.
997 pub fn locations_registries_devices_states_list(
998 &self,
999 name: &str,
1000 ) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
1001 ProjectLocationRegistryDeviceStateListCall {
1002 hub: self.hub,
1003 _name: name.to_string(),
1004 _num_states: Default::default(),
1005 _delegate: Default::default(),
1006 _additional_params: Default::default(),
1007 _scopes: Default::default(),
1008 }
1009 }
1010
1011 /// Create a builder to help you perform the following task:
1012 ///
1013 /// Creates a device in a device registry.
1014 ///
1015 /// # Arguments
1016 ///
1017 /// * `request` - No description provided.
1018 /// * `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`.
1019 pub fn locations_registries_devices_create(
1020 &self,
1021 request: Device,
1022 parent: &str,
1023 ) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
1024 ProjectLocationRegistryDeviceCreateCall {
1025 hub: self.hub,
1026 _request: request,
1027 _parent: parent.to_string(),
1028 _delegate: Default::default(),
1029 _additional_params: Default::default(),
1030 _scopes: Default::default(),
1031 }
1032 }
1033
1034 /// Create a builder to help you perform the following task:
1035 ///
1036 /// Deletes a device.
1037 ///
1038 /// # Arguments
1039 ///
1040 /// * `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}`.
1041 pub fn locations_registries_devices_delete(
1042 &self,
1043 name: &str,
1044 ) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
1045 ProjectLocationRegistryDeviceDeleteCall {
1046 hub: self.hub,
1047 _name: name.to_string(),
1048 _delegate: Default::default(),
1049 _additional_params: Default::default(),
1050 _scopes: Default::default(),
1051 }
1052 }
1053
1054 /// Create a builder to help you perform the following task:
1055 ///
1056 /// Gets details about a device.
1057 ///
1058 /// # Arguments
1059 ///
1060 /// * `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}`.
1061 pub fn locations_registries_devices_get(
1062 &self,
1063 name: &str,
1064 ) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
1065 ProjectLocationRegistryDeviceGetCall {
1066 hub: self.hub,
1067 _name: name.to_string(),
1068 _field_mask: Default::default(),
1069 _delegate: Default::default(),
1070 _additional_params: Default::default(),
1071 _scopes: Default::default(),
1072 }
1073 }
1074
1075 /// Create a builder to help you perform the following task:
1076 ///
1077 /// List devices in a device registry.
1078 ///
1079 /// # Arguments
1080 ///
1081 /// * `parent` - Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
1082 pub fn locations_registries_devices_list(
1083 &self,
1084 parent: &str,
1085 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
1086 ProjectLocationRegistryDeviceListCall {
1087 hub: self.hub,
1088 _parent: parent.to_string(),
1089 _page_token: Default::default(),
1090 _page_size: Default::default(),
1091 _gateway_list_options_gateway_type: Default::default(),
1092 _gateway_list_options_associations_gateway_id: Default::default(),
1093 _gateway_list_options_associations_device_id: Default::default(),
1094 _field_mask: Default::default(),
1095 _device_num_ids: Default::default(),
1096 _device_ids: Default::default(),
1097 _delegate: Default::default(),
1098 _additional_params: Default::default(),
1099 _scopes: Default::default(),
1100 }
1101 }
1102
1103 /// Create a builder to help you perform the following task:
1104 ///
1105 /// Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.
1106 ///
1107 /// # Arguments
1108 ///
1109 /// * `request` - No description provided.
1110 /// * `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}`.
1111 pub fn locations_registries_devices_modify_cloud_to_device_config(
1112 &self,
1113 request: ModifyCloudToDeviceConfigRequest,
1114 name: &str,
1115 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
1116 ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall {
1117 hub: self.hub,
1118 _request: request,
1119 _name: name.to_string(),
1120 _delegate: Default::default(),
1121 _additional_params: Default::default(),
1122 _scopes: Default::default(),
1123 }
1124 }
1125
1126 /// Create a builder to help you perform the following task:
1127 ///
1128 /// Updates a device.
1129 ///
1130 /// # Arguments
1131 ///
1132 /// * `request` - No description provided.
1133 /// * `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.
1134 pub fn locations_registries_devices_patch(
1135 &self,
1136 request: Device,
1137 name: &str,
1138 ) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
1139 ProjectLocationRegistryDevicePatchCall {
1140 hub: self.hub,
1141 _request: request,
1142 _name: name.to_string(),
1143 _update_mask: Default::default(),
1144 _delegate: Default::default(),
1145 _additional_params: Default::default(),
1146 _scopes: Default::default(),
1147 }
1148 }
1149
1150 /// Create a builder to help you perform the following task:
1151 ///
1152 /// 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.
1153 ///
1154 /// # Arguments
1155 ///
1156 /// * `request` - No description provided.
1157 /// * `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}`.
1158 pub fn locations_registries_devices_send_command_to_device(
1159 &self,
1160 request: SendCommandToDeviceRequest,
1161 name: &str,
1162 ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
1163 ProjectLocationRegistryDeviceSendCommandToDeviceCall {
1164 hub: self.hub,
1165 _request: request,
1166 _name: name.to_string(),
1167 _delegate: Default::default(),
1168 _additional_params: Default::default(),
1169 _scopes: Default::default(),
1170 }
1171 }
1172
1173 /// Create a builder to help you perform the following task:
1174 ///
1175 /// List devices in a device registry.
1176 ///
1177 /// # Arguments
1178 ///
1179 /// * `parent` - Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
1180 pub fn locations_registries_groups_devices_list(
1181 &self,
1182 parent: &str,
1183 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
1184 ProjectLocationRegistryGroupDeviceListCall {
1185 hub: self.hub,
1186 _parent: parent.to_string(),
1187 _page_token: Default::default(),
1188 _page_size: Default::default(),
1189 _gateway_list_options_gateway_type: Default::default(),
1190 _gateway_list_options_associations_gateway_id: Default::default(),
1191 _gateway_list_options_associations_device_id: Default::default(),
1192 _field_mask: Default::default(),
1193 _device_num_ids: Default::default(),
1194 _device_ids: Default::default(),
1195 _delegate: Default::default(),
1196 _additional_params: Default::default(),
1197 _scopes: Default::default(),
1198 }
1199 }
1200
1201 /// Create a builder to help you perform the following task:
1202 ///
1203 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1204 ///
1205 /// # Arguments
1206 ///
1207 /// * `request` - No description provided.
1208 /// * `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.
1209 pub fn locations_registries_groups_get_iam_policy(
1210 &self,
1211 request: GetIamPolicyRequest,
1212 resource: &str,
1213 ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
1214 ProjectLocationRegistryGroupGetIamPolicyCall {
1215 hub: self.hub,
1216 _request: request,
1217 _resource: resource.to_string(),
1218 _delegate: Default::default(),
1219 _additional_params: Default::default(),
1220 _scopes: Default::default(),
1221 }
1222 }
1223
1224 /// Create a builder to help you perform the following task:
1225 ///
1226 /// Sets the access control policy on the specified resource. Replaces any existing policy.
1227 ///
1228 /// # Arguments
1229 ///
1230 /// * `request` - No description provided.
1231 /// * `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.
1232 pub fn locations_registries_groups_set_iam_policy(
1233 &self,
1234 request: SetIamPolicyRequest,
1235 resource: &str,
1236 ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
1237 ProjectLocationRegistryGroupSetIamPolicyCall {
1238 hub: self.hub,
1239 _request: request,
1240 _resource: resource.to_string(),
1241 _delegate: Default::default(),
1242 _additional_params: Default::default(),
1243 _scopes: Default::default(),
1244 }
1245 }
1246
1247 /// Create a builder to help you perform the following task:
1248 ///
1249 /// 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.
1250 ///
1251 /// # Arguments
1252 ///
1253 /// * `request` - No description provided.
1254 /// * `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.
1255 pub fn locations_registries_groups_test_iam_permissions(
1256 &self,
1257 request: TestIamPermissionsRequest,
1258 resource: &str,
1259 ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
1260 ProjectLocationRegistryGroupTestIamPermissionCall {
1261 hub: self.hub,
1262 _request: request,
1263 _resource: resource.to_string(),
1264 _delegate: Default::default(),
1265 _additional_params: Default::default(),
1266 _scopes: Default::default(),
1267 }
1268 }
1269
1270 /// Create a builder to help you perform the following task:
1271 ///
1272 /// Associates the device with the gateway.
1273 ///
1274 /// # Arguments
1275 ///
1276 /// * `request` - No description provided.
1277 /// * `parent` - Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1278 pub fn locations_registries_bind_device_to_gateway(
1279 &self,
1280 request: BindDeviceToGatewayRequest,
1281 parent: &str,
1282 ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
1283 ProjectLocationRegistryBindDeviceToGatewayCall {
1284 hub: self.hub,
1285 _request: request,
1286 _parent: parent.to_string(),
1287 _delegate: Default::default(),
1288 _additional_params: Default::default(),
1289 _scopes: Default::default(),
1290 }
1291 }
1292
1293 /// Create a builder to help you perform the following task:
1294 ///
1295 /// Creates a device registry that contains devices.
1296 ///
1297 /// # Arguments
1298 ///
1299 /// * `request` - No description provided.
1300 /// * `parent` - Required. The project and cloud region where this device registry must be created. For example, `projects/example-project/locations/us-central1`.
1301 pub fn locations_registries_create(
1302 &self,
1303 request: DeviceRegistry,
1304 parent: &str,
1305 ) -> ProjectLocationRegistryCreateCall<'a, C> {
1306 ProjectLocationRegistryCreateCall {
1307 hub: self.hub,
1308 _request: request,
1309 _parent: parent.to_string(),
1310 _delegate: Default::default(),
1311 _additional_params: Default::default(),
1312 _scopes: Default::default(),
1313 }
1314 }
1315
1316 /// Create a builder to help you perform the following task:
1317 ///
1318 /// Deletes a device registry configuration.
1319 ///
1320 /// # Arguments
1321 ///
1322 /// * `name` - Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1323 pub fn locations_registries_delete(
1324 &self,
1325 name: &str,
1326 ) -> ProjectLocationRegistryDeleteCall<'a, C> {
1327 ProjectLocationRegistryDeleteCall {
1328 hub: self.hub,
1329 _name: name.to_string(),
1330 _delegate: Default::default(),
1331 _additional_params: Default::default(),
1332 _scopes: Default::default(),
1333 }
1334 }
1335
1336 /// Create a builder to help you perform the following task:
1337 ///
1338 /// Gets a device registry configuration.
1339 ///
1340 /// # Arguments
1341 ///
1342 /// * `name` - Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1343 pub fn locations_registries_get(&self, name: &str) -> ProjectLocationRegistryGetCall<'a, C> {
1344 ProjectLocationRegistryGetCall {
1345 hub: self.hub,
1346 _name: name.to_string(),
1347 _delegate: Default::default(),
1348 _additional_params: Default::default(),
1349 _scopes: Default::default(),
1350 }
1351 }
1352
1353 /// Create a builder to help you perform the following task:
1354 ///
1355 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1356 ///
1357 /// # Arguments
1358 ///
1359 /// * `request` - No description provided.
1360 /// * `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.
1361 pub fn locations_registries_get_iam_policy(
1362 &self,
1363 request: GetIamPolicyRequest,
1364 resource: &str,
1365 ) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
1366 ProjectLocationRegistryGetIamPolicyCall {
1367 hub: self.hub,
1368 _request: request,
1369 _resource: resource.to_string(),
1370 _delegate: Default::default(),
1371 _additional_params: Default::default(),
1372 _scopes: Default::default(),
1373 }
1374 }
1375
1376 /// Create a builder to help you perform the following task:
1377 ///
1378 /// Lists device registries.
1379 ///
1380 /// # Arguments
1381 ///
1382 /// * `parent` - Required. The project and cloud region path. For example, `projects/example-project/locations/us-central1`.
1383 pub fn locations_registries_list(
1384 &self,
1385 parent: &str,
1386 ) -> ProjectLocationRegistryListCall<'a, C> {
1387 ProjectLocationRegistryListCall {
1388 hub: self.hub,
1389 _parent: parent.to_string(),
1390 _page_token: Default::default(),
1391 _page_size: Default::default(),
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 /// Updates a device registry configuration.
1401 ///
1402 /// # Arguments
1403 ///
1404 /// * `request` - No description provided.
1405 /// * `name` - The resource path name. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1406 pub fn locations_registries_patch(
1407 &self,
1408 request: DeviceRegistry,
1409 name: &str,
1410 ) -> ProjectLocationRegistryPatchCall<'a, C> {
1411 ProjectLocationRegistryPatchCall {
1412 hub: self.hub,
1413 _request: request,
1414 _name: name.to_string(),
1415 _update_mask: Default::default(),
1416 _delegate: Default::default(),
1417 _additional_params: Default::default(),
1418 _scopes: Default::default(),
1419 }
1420 }
1421
1422 /// Create a builder to help you perform the following task:
1423 ///
1424 /// Sets the access control policy on the specified resource. Replaces any existing policy.
1425 ///
1426 /// # Arguments
1427 ///
1428 /// * `request` - No description provided.
1429 /// * `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.
1430 pub fn locations_registries_set_iam_policy(
1431 &self,
1432 request: SetIamPolicyRequest,
1433 resource: &str,
1434 ) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
1435 ProjectLocationRegistrySetIamPolicyCall {
1436 hub: self.hub,
1437 _request: request,
1438 _resource: resource.to_string(),
1439 _delegate: Default::default(),
1440 _additional_params: Default::default(),
1441 _scopes: Default::default(),
1442 }
1443 }
1444
1445 /// Create a builder to help you perform the following task:
1446 ///
1447 /// 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.
1448 ///
1449 /// # Arguments
1450 ///
1451 /// * `request` - No description provided.
1452 /// * `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.
1453 pub fn locations_registries_test_iam_permissions(
1454 &self,
1455 request: TestIamPermissionsRequest,
1456 resource: &str,
1457 ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
1458 ProjectLocationRegistryTestIamPermissionCall {
1459 hub: self.hub,
1460 _request: request,
1461 _resource: resource.to_string(),
1462 _delegate: Default::default(),
1463 _additional_params: Default::default(),
1464 _scopes: Default::default(),
1465 }
1466 }
1467
1468 /// Create a builder to help you perform the following task:
1469 ///
1470 /// Deletes the association between the device and the gateway.
1471 ///
1472 /// # Arguments
1473 ///
1474 /// * `request` - No description provided.
1475 /// * `parent` - Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
1476 pub fn locations_registries_unbind_device_from_gateway(
1477 &self,
1478 request: UnbindDeviceFromGatewayRequest,
1479 parent: &str,
1480 ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
1481 ProjectLocationRegistryUnbindDeviceFromGatewayCall {
1482 hub: self.hub,
1483 _request: request,
1484 _parent: parent.to_string(),
1485 _delegate: Default::default(),
1486 _additional_params: Default::default(),
1487 _scopes: Default::default(),
1488 }
1489 }
1490}
1491
1492// ###################
1493// CallBuilders ###
1494// #################
1495
1496/// Lists the last few versions of the device configuration in descending order (i.e.: newest first).
1497///
1498/// A builder for the *locations.registries.devices.configVersions.list* method supported by a *project* resource.
1499/// It is not used directly, but through a [`ProjectMethods`] instance.
1500///
1501/// # Example
1502///
1503/// Instantiate a resource method builder
1504///
1505/// ```test_harness,no_run
1506/// # extern crate hyper;
1507/// # extern crate hyper_rustls;
1508/// # extern crate google_cloudiot1 as cloudiot1;
1509/// # async fn dox() {
1510/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1511///
1512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1513/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1514/// # secret,
1515/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1516/// # ).build().await.unwrap();
1517///
1518/// # let client = hyper_util::client::legacy::Client::builder(
1519/// # hyper_util::rt::TokioExecutor::new()
1520/// # )
1521/// # .build(
1522/// # hyper_rustls::HttpsConnectorBuilder::new()
1523/// # .with_native_roots()
1524/// # .unwrap()
1525/// # .https_or_http()
1526/// # .enable_http1()
1527/// # .build()
1528/// # );
1529/// # let mut hub = CloudIot::new(client, auth);
1530/// // You can configure optional parameters by calling the respective setters at will, and
1531/// // execute the final call using `doit()`.
1532/// // Values shown here are possibly random and not representative !
1533/// let result = hub.projects().locations_registries_devices_config_versions_list("name")
1534/// .num_versions(-28)
1535/// .doit().await;
1536/// # }
1537/// ```
1538pub struct ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1539where
1540 C: 'a,
1541{
1542 hub: &'a CloudIot<C>,
1543 _name: String,
1544 _num_versions: Option<i32>,
1545 _delegate: Option<&'a mut dyn common::Delegate>,
1546 _additional_params: HashMap<String, String>,
1547 _scopes: BTreeSet<String>,
1548}
1549
1550impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {}
1551
1552impl<'a, C> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1553where
1554 C: common::Connector,
1555{
1556 /// Perform the operation you have build so far.
1557 pub async fn doit(
1558 mut self,
1559 ) -> common::Result<(common::Response, ListDeviceConfigVersionsResponse)> {
1560 use std::borrow::Cow;
1561 use std::io::{Read, Seek};
1562
1563 use common::{url::Params, ToParts};
1564 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1565
1566 let mut dd = common::DefaultDelegate;
1567 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1568 dlg.begin(common::MethodInfo {
1569 id: "cloudiot.projects.locations.registries.devices.configVersions.list",
1570 http_method: hyper::Method::GET,
1571 });
1572
1573 for &field in ["alt", "name", "numVersions"].iter() {
1574 if self._additional_params.contains_key(field) {
1575 dlg.finished(false);
1576 return Err(common::Error::FieldClash(field));
1577 }
1578 }
1579
1580 let mut params = Params::with_capacity(4 + self._additional_params.len());
1581 params.push("name", self._name);
1582 if let Some(value) = self._num_versions.as_ref() {
1583 params.push("numVersions", value.to_string());
1584 }
1585
1586 params.extend(self._additional_params.iter());
1587
1588 params.push("alt", "json");
1589 let mut url = self.hub._base_url.clone() + "v1/{+name}/configVersions";
1590 if self._scopes.is_empty() {
1591 self._scopes
1592 .insert(Scope::CloudPlatform.as_ref().to_string());
1593 }
1594
1595 #[allow(clippy::single_element_loop)]
1596 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1597 url = params.uri_replacement(url, param_name, find_this, true);
1598 }
1599 {
1600 let to_remove = ["name"];
1601 params.remove_params(&to_remove);
1602 }
1603
1604 let url = params.parse_with_url(&url);
1605
1606 loop {
1607 let token = match self
1608 .hub
1609 .auth
1610 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1611 .await
1612 {
1613 Ok(token) => token,
1614 Err(e) => match dlg.token(e) {
1615 Ok(token) => token,
1616 Err(e) => {
1617 dlg.finished(false);
1618 return Err(common::Error::MissingToken(e));
1619 }
1620 },
1621 };
1622 let mut req_result = {
1623 let client = &self.hub.client;
1624 dlg.pre_request();
1625 let mut req_builder = hyper::Request::builder()
1626 .method(hyper::Method::GET)
1627 .uri(url.as_str())
1628 .header(USER_AGENT, self.hub._user_agent.clone());
1629
1630 if let Some(token) = token.as_ref() {
1631 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1632 }
1633
1634 let request = req_builder
1635 .header(CONTENT_LENGTH, 0_u64)
1636 .body(common::to_body::<String>(None));
1637
1638 client.request(request.unwrap()).await
1639 };
1640
1641 match req_result {
1642 Err(err) => {
1643 if let common::Retry::After(d) = dlg.http_error(&err) {
1644 sleep(d).await;
1645 continue;
1646 }
1647 dlg.finished(false);
1648 return Err(common::Error::HttpError(err));
1649 }
1650 Ok(res) => {
1651 let (mut parts, body) = res.into_parts();
1652 let mut body = common::Body::new(body);
1653 if !parts.status.is_success() {
1654 let bytes = common::to_bytes(body).await.unwrap_or_default();
1655 let error = serde_json::from_str(&common::to_string(&bytes));
1656 let response = common::to_response(parts, bytes.into());
1657
1658 if let common::Retry::After(d) =
1659 dlg.http_failure(&response, error.as_ref().ok())
1660 {
1661 sleep(d).await;
1662 continue;
1663 }
1664
1665 dlg.finished(false);
1666
1667 return Err(match error {
1668 Ok(value) => common::Error::BadRequest(value),
1669 _ => common::Error::Failure(response),
1670 });
1671 }
1672 let response = {
1673 let bytes = common::to_bytes(body).await.unwrap_or_default();
1674 let encoded = common::to_string(&bytes);
1675 match serde_json::from_str(&encoded) {
1676 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1677 Err(error) => {
1678 dlg.response_json_decode_error(&encoded, &error);
1679 return Err(common::Error::JsonDecodeError(
1680 encoded.to_string(),
1681 error,
1682 ));
1683 }
1684 }
1685 };
1686
1687 dlg.finished(true);
1688 return Ok(response);
1689 }
1690 }
1691 }
1692 }
1693
1694 /// 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}`.
1695 ///
1696 /// Sets the *name* path property to the given value.
1697 ///
1698 /// Even though the property as already been set when instantiating this call,
1699 /// we provide this method for API completeness.
1700 pub fn name(
1701 mut self,
1702 new_value: &str,
1703 ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1704 self._name = new_value.to_string();
1705 self
1706 }
1707 /// 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.
1708 ///
1709 /// Sets the *num versions* query property to the given value.
1710 pub fn num_versions(
1711 mut self,
1712 new_value: i32,
1713 ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1714 self._num_versions = Some(new_value);
1715 self
1716 }
1717 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1718 /// while executing the actual API request.
1719 ///
1720 /// ````text
1721 /// It should be used to handle progress information, and to implement a certain level of resilience.
1722 /// ````
1723 ///
1724 /// Sets the *delegate* property to the given value.
1725 pub fn delegate(
1726 mut self,
1727 new_value: &'a mut dyn common::Delegate,
1728 ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1729 self._delegate = Some(new_value);
1730 self
1731 }
1732
1733 /// Set any additional parameter of the query string used in the request.
1734 /// It should be used to set parameters which are not yet available through their own
1735 /// setters.
1736 ///
1737 /// Please note that this method must not be used to set any of the known parameters
1738 /// which have their own setter method. If done anyway, the request will fail.
1739 ///
1740 /// # Additional Parameters
1741 ///
1742 /// * *$.xgafv* (query-string) - V1 error format.
1743 /// * *access_token* (query-string) - OAuth access token.
1744 /// * *alt* (query-string) - Data format for response.
1745 /// * *callback* (query-string) - JSONP
1746 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1747 /// * *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.
1748 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1749 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1750 /// * *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.
1751 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1752 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1753 pub fn param<T>(
1754 mut self,
1755 name: T,
1756 value: T,
1757 ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1758 where
1759 T: AsRef<str>,
1760 {
1761 self._additional_params
1762 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1763 self
1764 }
1765
1766 /// Identifies the authorization scope for the method you are building.
1767 ///
1768 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1769 /// [`Scope::CloudPlatform`].
1770 ///
1771 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1772 /// tokens for more than one scope.
1773 ///
1774 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1775 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1776 /// sufficient, a read-write scope will do as well.
1777 pub fn add_scope<St>(
1778 mut self,
1779 scope: St,
1780 ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1781 where
1782 St: AsRef<str>,
1783 {
1784 self._scopes.insert(String::from(scope.as_ref()));
1785 self
1786 }
1787 /// Identifies the authorization scope(s) for the method you are building.
1788 ///
1789 /// See [`Self::add_scope()`] for details.
1790 pub fn add_scopes<I, St>(
1791 mut self,
1792 scopes: I,
1793 ) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C>
1794 where
1795 I: IntoIterator<Item = St>,
1796 St: AsRef<str>,
1797 {
1798 self._scopes
1799 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1800 self
1801 }
1802
1803 /// Removes all scopes, and no default scope will be used either.
1804 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1805 /// for details).
1806 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceConfigVersionListCall<'a, C> {
1807 self._scopes.clear();
1808 self
1809 }
1810}
1811
1812/// Lists the last few versions of the device state in descending order (i.e.: newest first).
1813///
1814/// A builder for the *locations.registries.devices.states.list* method supported by a *project* resource.
1815/// It is not used directly, but through a [`ProjectMethods`] instance.
1816///
1817/// # Example
1818///
1819/// Instantiate a resource method builder
1820///
1821/// ```test_harness,no_run
1822/// # extern crate hyper;
1823/// # extern crate hyper_rustls;
1824/// # extern crate google_cloudiot1 as cloudiot1;
1825/// # async fn dox() {
1826/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1827///
1828/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1829/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1830/// # secret,
1831/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1832/// # ).build().await.unwrap();
1833///
1834/// # let client = hyper_util::client::legacy::Client::builder(
1835/// # hyper_util::rt::TokioExecutor::new()
1836/// # )
1837/// # .build(
1838/// # hyper_rustls::HttpsConnectorBuilder::new()
1839/// # .with_native_roots()
1840/// # .unwrap()
1841/// # .https_or_http()
1842/// # .enable_http1()
1843/// # .build()
1844/// # );
1845/// # let mut hub = CloudIot::new(client, auth);
1846/// // You can configure optional parameters by calling the respective setters at will, and
1847/// // execute the final call using `doit()`.
1848/// // Values shown here are possibly random and not representative !
1849/// let result = hub.projects().locations_registries_devices_states_list("name")
1850/// .num_states(-8)
1851/// .doit().await;
1852/// # }
1853/// ```
1854pub struct ProjectLocationRegistryDeviceStateListCall<'a, C>
1855where
1856 C: 'a,
1857{
1858 hub: &'a CloudIot<C>,
1859 _name: String,
1860 _num_states: Option<i32>,
1861 _delegate: Option<&'a mut dyn common::Delegate>,
1862 _additional_params: HashMap<String, String>,
1863 _scopes: BTreeSet<String>,
1864}
1865
1866impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceStateListCall<'a, C> {}
1867
1868impl<'a, C> ProjectLocationRegistryDeviceStateListCall<'a, C>
1869where
1870 C: common::Connector,
1871{
1872 /// Perform the operation you have build so far.
1873 pub async fn doit(mut self) -> common::Result<(common::Response, ListDeviceStatesResponse)> {
1874 use std::borrow::Cow;
1875 use std::io::{Read, Seek};
1876
1877 use common::{url::Params, ToParts};
1878 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1879
1880 let mut dd = common::DefaultDelegate;
1881 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1882 dlg.begin(common::MethodInfo {
1883 id: "cloudiot.projects.locations.registries.devices.states.list",
1884 http_method: hyper::Method::GET,
1885 });
1886
1887 for &field in ["alt", "name", "numStates"].iter() {
1888 if self._additional_params.contains_key(field) {
1889 dlg.finished(false);
1890 return Err(common::Error::FieldClash(field));
1891 }
1892 }
1893
1894 let mut params = Params::with_capacity(4 + self._additional_params.len());
1895 params.push("name", self._name);
1896 if let Some(value) = self._num_states.as_ref() {
1897 params.push("numStates", value.to_string());
1898 }
1899
1900 params.extend(self._additional_params.iter());
1901
1902 params.push("alt", "json");
1903 let mut url = self.hub._base_url.clone() + "v1/{+name}/states";
1904 if self._scopes.is_empty() {
1905 self._scopes
1906 .insert(Scope::CloudPlatform.as_ref().to_string());
1907 }
1908
1909 #[allow(clippy::single_element_loop)]
1910 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1911 url = params.uri_replacement(url, param_name, find_this, true);
1912 }
1913 {
1914 let to_remove = ["name"];
1915 params.remove_params(&to_remove);
1916 }
1917
1918 let url = params.parse_with_url(&url);
1919
1920 loop {
1921 let token = match self
1922 .hub
1923 .auth
1924 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1925 .await
1926 {
1927 Ok(token) => token,
1928 Err(e) => match dlg.token(e) {
1929 Ok(token) => token,
1930 Err(e) => {
1931 dlg.finished(false);
1932 return Err(common::Error::MissingToken(e));
1933 }
1934 },
1935 };
1936 let mut req_result = {
1937 let client = &self.hub.client;
1938 dlg.pre_request();
1939 let mut req_builder = hyper::Request::builder()
1940 .method(hyper::Method::GET)
1941 .uri(url.as_str())
1942 .header(USER_AGENT, self.hub._user_agent.clone());
1943
1944 if let Some(token) = token.as_ref() {
1945 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1946 }
1947
1948 let request = req_builder
1949 .header(CONTENT_LENGTH, 0_u64)
1950 .body(common::to_body::<String>(None));
1951
1952 client.request(request.unwrap()).await
1953 };
1954
1955 match req_result {
1956 Err(err) => {
1957 if let common::Retry::After(d) = dlg.http_error(&err) {
1958 sleep(d).await;
1959 continue;
1960 }
1961 dlg.finished(false);
1962 return Err(common::Error::HttpError(err));
1963 }
1964 Ok(res) => {
1965 let (mut parts, body) = res.into_parts();
1966 let mut body = common::Body::new(body);
1967 if !parts.status.is_success() {
1968 let bytes = common::to_bytes(body).await.unwrap_or_default();
1969 let error = serde_json::from_str(&common::to_string(&bytes));
1970 let response = common::to_response(parts, bytes.into());
1971
1972 if let common::Retry::After(d) =
1973 dlg.http_failure(&response, error.as_ref().ok())
1974 {
1975 sleep(d).await;
1976 continue;
1977 }
1978
1979 dlg.finished(false);
1980
1981 return Err(match error {
1982 Ok(value) => common::Error::BadRequest(value),
1983 _ => common::Error::Failure(response),
1984 });
1985 }
1986 let response = {
1987 let bytes = common::to_bytes(body).await.unwrap_or_default();
1988 let encoded = common::to_string(&bytes);
1989 match serde_json::from_str(&encoded) {
1990 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1991 Err(error) => {
1992 dlg.response_json_decode_error(&encoded, &error);
1993 return Err(common::Error::JsonDecodeError(
1994 encoded.to_string(),
1995 error,
1996 ));
1997 }
1998 }
1999 };
2000
2001 dlg.finished(true);
2002 return Ok(response);
2003 }
2004 }
2005 }
2006 }
2007
2008 /// 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}`.
2009 ///
2010 /// Sets the *name* path property to the given value.
2011 ///
2012 /// Even though the property as already been set when instantiating this call,
2013 /// we provide this method for API completeness.
2014 pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2015 self._name = new_value.to_string();
2016 self
2017 }
2018 /// 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.
2019 ///
2020 /// Sets the *num states* query property to the given value.
2021 pub fn num_states(
2022 mut self,
2023 new_value: i32,
2024 ) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2025 self._num_states = Some(new_value);
2026 self
2027 }
2028 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2029 /// while executing the actual API request.
2030 ///
2031 /// ````text
2032 /// It should be used to handle progress information, and to implement a certain level of resilience.
2033 /// ````
2034 ///
2035 /// Sets the *delegate* property to the given value.
2036 pub fn delegate(
2037 mut self,
2038 new_value: &'a mut dyn common::Delegate,
2039 ) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2040 self._delegate = Some(new_value);
2041 self
2042 }
2043
2044 /// Set any additional parameter of the query string used in the request.
2045 /// It should be used to set parameters which are not yet available through their own
2046 /// setters.
2047 ///
2048 /// Please note that this method must not be used to set any of the known parameters
2049 /// which have their own setter method. If done anyway, the request will fail.
2050 ///
2051 /// # Additional Parameters
2052 ///
2053 /// * *$.xgafv* (query-string) - V1 error format.
2054 /// * *access_token* (query-string) - OAuth access token.
2055 /// * *alt* (query-string) - Data format for response.
2056 /// * *callback* (query-string) - JSONP
2057 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2058 /// * *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.
2059 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2060 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2061 /// * *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.
2062 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2063 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2064 pub fn param<T>(
2065 mut self,
2066 name: T,
2067 value: T,
2068 ) -> ProjectLocationRegistryDeviceStateListCall<'a, C>
2069 where
2070 T: AsRef<str>,
2071 {
2072 self._additional_params
2073 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2074 self
2075 }
2076
2077 /// Identifies the authorization scope for the method you are building.
2078 ///
2079 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2080 /// [`Scope::CloudPlatform`].
2081 ///
2082 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2083 /// tokens for more than one scope.
2084 ///
2085 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2086 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2087 /// sufficient, a read-write scope will do as well.
2088 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceStateListCall<'a, C>
2089 where
2090 St: AsRef<str>,
2091 {
2092 self._scopes.insert(String::from(scope.as_ref()));
2093 self
2094 }
2095 /// Identifies the authorization scope(s) for the method you are building.
2096 ///
2097 /// See [`Self::add_scope()`] for details.
2098 pub fn add_scopes<I, St>(
2099 mut self,
2100 scopes: I,
2101 ) -> ProjectLocationRegistryDeviceStateListCall<'a, C>
2102 where
2103 I: IntoIterator<Item = St>,
2104 St: AsRef<str>,
2105 {
2106 self._scopes
2107 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2108 self
2109 }
2110
2111 /// Removes all scopes, and no default scope will be used either.
2112 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2113 /// for details).
2114 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceStateListCall<'a, C> {
2115 self._scopes.clear();
2116 self
2117 }
2118}
2119
2120/// Creates a device in a device registry.
2121///
2122/// A builder for the *locations.registries.devices.create* method supported by a *project* resource.
2123/// It is not used directly, but through a [`ProjectMethods`] instance.
2124///
2125/// # Example
2126///
2127/// Instantiate a resource method builder
2128///
2129/// ```test_harness,no_run
2130/// # extern crate hyper;
2131/// # extern crate hyper_rustls;
2132/// # extern crate google_cloudiot1 as cloudiot1;
2133/// use cloudiot1::api::Device;
2134/// # async fn dox() {
2135/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2136///
2137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2138/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2139/// # secret,
2140/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2141/// # ).build().await.unwrap();
2142///
2143/// # let client = hyper_util::client::legacy::Client::builder(
2144/// # hyper_util::rt::TokioExecutor::new()
2145/// # )
2146/// # .build(
2147/// # hyper_rustls::HttpsConnectorBuilder::new()
2148/// # .with_native_roots()
2149/// # .unwrap()
2150/// # .https_or_http()
2151/// # .enable_http1()
2152/// # .build()
2153/// # );
2154/// # let mut hub = CloudIot::new(client, auth);
2155/// // As the method needs a request, you would usually fill it with the desired information
2156/// // into the respective structure. Some of the parts shown here might not be applicable !
2157/// // Values shown here are possibly random and not representative !
2158/// let mut req = Device::default();
2159///
2160/// // You can configure optional parameters by calling the respective setters at will, and
2161/// // execute the final call using `doit()`.
2162/// // Values shown here are possibly random and not representative !
2163/// let result = hub.projects().locations_registries_devices_create(req, "parent")
2164/// .doit().await;
2165/// # }
2166/// ```
2167pub struct ProjectLocationRegistryDeviceCreateCall<'a, C>
2168where
2169 C: 'a,
2170{
2171 hub: &'a CloudIot<C>,
2172 _request: Device,
2173 _parent: String,
2174 _delegate: Option<&'a mut dyn common::Delegate>,
2175 _additional_params: HashMap<String, String>,
2176 _scopes: BTreeSet<String>,
2177}
2178
2179impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceCreateCall<'a, C> {}
2180
2181impl<'a, C> ProjectLocationRegistryDeviceCreateCall<'a, C>
2182where
2183 C: common::Connector,
2184{
2185 /// Perform the operation you have build so far.
2186 pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
2187 use std::borrow::Cow;
2188 use std::io::{Read, Seek};
2189
2190 use common::{url::Params, ToParts};
2191 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2192
2193 let mut dd = common::DefaultDelegate;
2194 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2195 dlg.begin(common::MethodInfo {
2196 id: "cloudiot.projects.locations.registries.devices.create",
2197 http_method: hyper::Method::POST,
2198 });
2199
2200 for &field in ["alt", "parent"].iter() {
2201 if self._additional_params.contains_key(field) {
2202 dlg.finished(false);
2203 return Err(common::Error::FieldClash(field));
2204 }
2205 }
2206
2207 let mut params = Params::with_capacity(4 + self._additional_params.len());
2208 params.push("parent", self._parent);
2209
2210 params.extend(self._additional_params.iter());
2211
2212 params.push("alt", "json");
2213 let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
2214 if self._scopes.is_empty() {
2215 self._scopes
2216 .insert(Scope::CloudPlatform.as_ref().to_string());
2217 }
2218
2219 #[allow(clippy::single_element_loop)]
2220 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2221 url = params.uri_replacement(url, param_name, find_this, true);
2222 }
2223 {
2224 let to_remove = ["parent"];
2225 params.remove_params(&to_remove);
2226 }
2227
2228 let url = params.parse_with_url(&url);
2229
2230 let mut json_mime_type = mime::APPLICATION_JSON;
2231 let mut request_value_reader = {
2232 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2233 common::remove_json_null_values(&mut value);
2234 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2235 serde_json::to_writer(&mut dst, &value).unwrap();
2236 dst
2237 };
2238 let request_size = request_value_reader
2239 .seek(std::io::SeekFrom::End(0))
2240 .unwrap();
2241 request_value_reader
2242 .seek(std::io::SeekFrom::Start(0))
2243 .unwrap();
2244
2245 loop {
2246 let token = match self
2247 .hub
2248 .auth
2249 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2250 .await
2251 {
2252 Ok(token) => token,
2253 Err(e) => match dlg.token(e) {
2254 Ok(token) => token,
2255 Err(e) => {
2256 dlg.finished(false);
2257 return Err(common::Error::MissingToken(e));
2258 }
2259 },
2260 };
2261 request_value_reader
2262 .seek(std::io::SeekFrom::Start(0))
2263 .unwrap();
2264 let mut req_result = {
2265 let client = &self.hub.client;
2266 dlg.pre_request();
2267 let mut req_builder = hyper::Request::builder()
2268 .method(hyper::Method::POST)
2269 .uri(url.as_str())
2270 .header(USER_AGENT, self.hub._user_agent.clone());
2271
2272 if let Some(token) = token.as_ref() {
2273 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2274 }
2275
2276 let request = req_builder
2277 .header(CONTENT_TYPE, json_mime_type.to_string())
2278 .header(CONTENT_LENGTH, request_size as u64)
2279 .body(common::to_body(
2280 request_value_reader.get_ref().clone().into(),
2281 ));
2282
2283 client.request(request.unwrap()).await
2284 };
2285
2286 match req_result {
2287 Err(err) => {
2288 if let common::Retry::After(d) = dlg.http_error(&err) {
2289 sleep(d).await;
2290 continue;
2291 }
2292 dlg.finished(false);
2293 return Err(common::Error::HttpError(err));
2294 }
2295 Ok(res) => {
2296 let (mut parts, body) = res.into_parts();
2297 let mut body = common::Body::new(body);
2298 if !parts.status.is_success() {
2299 let bytes = common::to_bytes(body).await.unwrap_or_default();
2300 let error = serde_json::from_str(&common::to_string(&bytes));
2301 let response = common::to_response(parts, bytes.into());
2302
2303 if let common::Retry::After(d) =
2304 dlg.http_failure(&response, error.as_ref().ok())
2305 {
2306 sleep(d).await;
2307 continue;
2308 }
2309
2310 dlg.finished(false);
2311
2312 return Err(match error {
2313 Ok(value) => common::Error::BadRequest(value),
2314 _ => common::Error::Failure(response),
2315 });
2316 }
2317 let response = {
2318 let bytes = common::to_bytes(body).await.unwrap_or_default();
2319 let encoded = common::to_string(&bytes);
2320 match serde_json::from_str(&encoded) {
2321 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2322 Err(error) => {
2323 dlg.response_json_decode_error(&encoded, &error);
2324 return Err(common::Error::JsonDecodeError(
2325 encoded.to_string(),
2326 error,
2327 ));
2328 }
2329 }
2330 };
2331
2332 dlg.finished(true);
2333 return Ok(response);
2334 }
2335 }
2336 }
2337 }
2338
2339 ///
2340 /// Sets the *request* property to the given value.
2341 ///
2342 /// Even though the property as already been set when instantiating this call,
2343 /// we provide this method for API completeness.
2344 pub fn request(mut self, new_value: Device) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2345 self._request = new_value;
2346 self
2347 }
2348 /// Required. The name of the device registry where this device should be created. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
2349 ///
2350 /// Sets the *parent* path property to the given value.
2351 ///
2352 /// Even though the property as already been set when instantiating this call,
2353 /// we provide this method for API completeness.
2354 pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2355 self._parent = new_value.to_string();
2356 self
2357 }
2358 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2359 /// while executing the actual API request.
2360 ///
2361 /// ````text
2362 /// It should be used to handle progress information, and to implement a certain level of resilience.
2363 /// ````
2364 ///
2365 /// Sets the *delegate* property to the given value.
2366 pub fn delegate(
2367 mut self,
2368 new_value: &'a mut dyn common::Delegate,
2369 ) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2370 self._delegate = Some(new_value);
2371 self
2372 }
2373
2374 /// Set any additional parameter of the query string used in the request.
2375 /// It should be used to set parameters which are not yet available through their own
2376 /// setters.
2377 ///
2378 /// Please note that this method must not be used to set any of the known parameters
2379 /// which have their own setter method. If done anyway, the request will fail.
2380 ///
2381 /// # Additional Parameters
2382 ///
2383 /// * *$.xgafv* (query-string) - V1 error format.
2384 /// * *access_token* (query-string) - OAuth access token.
2385 /// * *alt* (query-string) - Data format for response.
2386 /// * *callback* (query-string) - JSONP
2387 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2388 /// * *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.
2389 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2390 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2391 /// * *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.
2392 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2393 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2394 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceCreateCall<'a, C>
2395 where
2396 T: AsRef<str>,
2397 {
2398 self._additional_params
2399 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2400 self
2401 }
2402
2403 /// Identifies the authorization scope for the method you are building.
2404 ///
2405 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2406 /// [`Scope::CloudPlatform`].
2407 ///
2408 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2409 /// tokens for more than one scope.
2410 ///
2411 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2412 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2413 /// sufficient, a read-write scope will do as well.
2414 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceCreateCall<'a, C>
2415 where
2416 St: AsRef<str>,
2417 {
2418 self._scopes.insert(String::from(scope.as_ref()));
2419 self
2420 }
2421 /// Identifies the authorization scope(s) for the method you are building.
2422 ///
2423 /// See [`Self::add_scope()`] for details.
2424 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceCreateCall<'a, C>
2425 where
2426 I: IntoIterator<Item = St>,
2427 St: AsRef<str>,
2428 {
2429 self._scopes
2430 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2431 self
2432 }
2433
2434 /// Removes all scopes, and no default scope will be used either.
2435 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2436 /// for details).
2437 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceCreateCall<'a, C> {
2438 self._scopes.clear();
2439 self
2440 }
2441}
2442
2443/// Deletes a device.
2444///
2445/// A builder for the *locations.registries.devices.delete* method supported by a *project* resource.
2446/// It is not used directly, but through a [`ProjectMethods`] instance.
2447///
2448/// # Example
2449///
2450/// Instantiate a resource method builder
2451///
2452/// ```test_harness,no_run
2453/// # extern crate hyper;
2454/// # extern crate hyper_rustls;
2455/// # extern crate google_cloudiot1 as cloudiot1;
2456/// # async fn dox() {
2457/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2458///
2459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2460/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2461/// # secret,
2462/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2463/// # ).build().await.unwrap();
2464///
2465/// # let client = hyper_util::client::legacy::Client::builder(
2466/// # hyper_util::rt::TokioExecutor::new()
2467/// # )
2468/// # .build(
2469/// # hyper_rustls::HttpsConnectorBuilder::new()
2470/// # .with_native_roots()
2471/// # .unwrap()
2472/// # .https_or_http()
2473/// # .enable_http1()
2474/// # .build()
2475/// # );
2476/// # let mut hub = CloudIot::new(client, auth);
2477/// // You can configure optional parameters by calling the respective setters at will, and
2478/// // execute the final call using `doit()`.
2479/// // Values shown here are possibly random and not representative !
2480/// let result = hub.projects().locations_registries_devices_delete("name")
2481/// .doit().await;
2482/// # }
2483/// ```
2484pub struct ProjectLocationRegistryDeviceDeleteCall<'a, C>
2485where
2486 C: 'a,
2487{
2488 hub: &'a CloudIot<C>,
2489 _name: String,
2490 _delegate: Option<&'a mut dyn common::Delegate>,
2491 _additional_params: HashMap<String, String>,
2492 _scopes: BTreeSet<String>,
2493}
2494
2495impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceDeleteCall<'a, C> {}
2496
2497impl<'a, C> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2498where
2499 C: common::Connector,
2500{
2501 /// Perform the operation you have build so far.
2502 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2503 use std::borrow::Cow;
2504 use std::io::{Read, Seek};
2505
2506 use common::{url::Params, ToParts};
2507 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2508
2509 let mut dd = common::DefaultDelegate;
2510 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2511 dlg.begin(common::MethodInfo {
2512 id: "cloudiot.projects.locations.registries.devices.delete",
2513 http_method: hyper::Method::DELETE,
2514 });
2515
2516 for &field in ["alt", "name"].iter() {
2517 if self._additional_params.contains_key(field) {
2518 dlg.finished(false);
2519 return Err(common::Error::FieldClash(field));
2520 }
2521 }
2522
2523 let mut params = Params::with_capacity(3 + self._additional_params.len());
2524 params.push("name", self._name);
2525
2526 params.extend(self._additional_params.iter());
2527
2528 params.push("alt", "json");
2529 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2530 if self._scopes.is_empty() {
2531 self._scopes
2532 .insert(Scope::CloudPlatform.as_ref().to_string());
2533 }
2534
2535 #[allow(clippy::single_element_loop)]
2536 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2537 url = params.uri_replacement(url, param_name, find_this, true);
2538 }
2539 {
2540 let to_remove = ["name"];
2541 params.remove_params(&to_remove);
2542 }
2543
2544 let url = params.parse_with_url(&url);
2545
2546 loop {
2547 let token = match self
2548 .hub
2549 .auth
2550 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2551 .await
2552 {
2553 Ok(token) => token,
2554 Err(e) => match dlg.token(e) {
2555 Ok(token) => token,
2556 Err(e) => {
2557 dlg.finished(false);
2558 return Err(common::Error::MissingToken(e));
2559 }
2560 },
2561 };
2562 let mut req_result = {
2563 let client = &self.hub.client;
2564 dlg.pre_request();
2565 let mut req_builder = hyper::Request::builder()
2566 .method(hyper::Method::DELETE)
2567 .uri(url.as_str())
2568 .header(USER_AGENT, self.hub._user_agent.clone());
2569
2570 if let Some(token) = token.as_ref() {
2571 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2572 }
2573
2574 let request = req_builder
2575 .header(CONTENT_LENGTH, 0_u64)
2576 .body(common::to_body::<String>(None));
2577
2578 client.request(request.unwrap()).await
2579 };
2580
2581 match req_result {
2582 Err(err) => {
2583 if let common::Retry::After(d) = dlg.http_error(&err) {
2584 sleep(d).await;
2585 continue;
2586 }
2587 dlg.finished(false);
2588 return Err(common::Error::HttpError(err));
2589 }
2590 Ok(res) => {
2591 let (mut parts, body) = res.into_parts();
2592 let mut body = common::Body::new(body);
2593 if !parts.status.is_success() {
2594 let bytes = common::to_bytes(body).await.unwrap_or_default();
2595 let error = serde_json::from_str(&common::to_string(&bytes));
2596 let response = common::to_response(parts, bytes.into());
2597
2598 if let common::Retry::After(d) =
2599 dlg.http_failure(&response, error.as_ref().ok())
2600 {
2601 sleep(d).await;
2602 continue;
2603 }
2604
2605 dlg.finished(false);
2606
2607 return Err(match error {
2608 Ok(value) => common::Error::BadRequest(value),
2609 _ => common::Error::Failure(response),
2610 });
2611 }
2612 let response = {
2613 let bytes = common::to_bytes(body).await.unwrap_or_default();
2614 let encoded = common::to_string(&bytes);
2615 match serde_json::from_str(&encoded) {
2616 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2617 Err(error) => {
2618 dlg.response_json_decode_error(&encoded, &error);
2619 return Err(common::Error::JsonDecodeError(
2620 encoded.to_string(),
2621 error,
2622 ));
2623 }
2624 }
2625 };
2626
2627 dlg.finished(true);
2628 return Ok(response);
2629 }
2630 }
2631 }
2632 }
2633
2634 /// 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}`.
2635 ///
2636 /// Sets the *name* path property to the given value.
2637 ///
2638 /// Even though the property as already been set when instantiating this call,
2639 /// we provide this method for API completeness.
2640 pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
2641 self._name = new_value.to_string();
2642 self
2643 }
2644 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2645 /// while executing the actual API request.
2646 ///
2647 /// ````text
2648 /// It should be used to handle progress information, and to implement a certain level of resilience.
2649 /// ````
2650 ///
2651 /// Sets the *delegate* property to the given value.
2652 pub fn delegate(
2653 mut self,
2654 new_value: &'a mut dyn common::Delegate,
2655 ) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
2656 self._delegate = Some(new_value);
2657 self
2658 }
2659
2660 /// Set any additional parameter of the query string used in the request.
2661 /// It should be used to set parameters which are not yet available through their own
2662 /// setters.
2663 ///
2664 /// Please note that this method must not be used to set any of the known parameters
2665 /// which have their own setter method. If done anyway, the request will fail.
2666 ///
2667 /// # Additional Parameters
2668 ///
2669 /// * *$.xgafv* (query-string) - V1 error format.
2670 /// * *access_token* (query-string) - OAuth access token.
2671 /// * *alt* (query-string) - Data format for response.
2672 /// * *callback* (query-string) - JSONP
2673 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2674 /// * *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.
2675 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2676 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2677 /// * *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.
2678 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2679 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2680 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2681 where
2682 T: AsRef<str>,
2683 {
2684 self._additional_params
2685 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2686 self
2687 }
2688
2689 /// Identifies the authorization scope for the method you are building.
2690 ///
2691 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2692 /// [`Scope::CloudPlatform`].
2693 ///
2694 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2695 /// tokens for more than one scope.
2696 ///
2697 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2698 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2699 /// sufficient, a read-write scope will do as well.
2700 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2701 where
2702 St: AsRef<str>,
2703 {
2704 self._scopes.insert(String::from(scope.as_ref()));
2705 self
2706 }
2707 /// Identifies the authorization scope(s) for the method you are building.
2708 ///
2709 /// See [`Self::add_scope()`] for details.
2710 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceDeleteCall<'a, C>
2711 where
2712 I: IntoIterator<Item = St>,
2713 St: AsRef<str>,
2714 {
2715 self._scopes
2716 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2717 self
2718 }
2719
2720 /// Removes all scopes, and no default scope will be used either.
2721 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2722 /// for details).
2723 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceDeleteCall<'a, C> {
2724 self._scopes.clear();
2725 self
2726 }
2727}
2728
2729/// Gets details about a device.
2730///
2731/// A builder for the *locations.registries.devices.get* method supported by a *project* resource.
2732/// It is not used directly, but through a [`ProjectMethods`] instance.
2733///
2734/// # Example
2735///
2736/// Instantiate a resource method builder
2737///
2738/// ```test_harness,no_run
2739/// # extern crate hyper;
2740/// # extern crate hyper_rustls;
2741/// # extern crate google_cloudiot1 as cloudiot1;
2742/// # async fn dox() {
2743/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2744///
2745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2747/// # secret,
2748/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2749/// # ).build().await.unwrap();
2750///
2751/// # let client = hyper_util::client::legacy::Client::builder(
2752/// # hyper_util::rt::TokioExecutor::new()
2753/// # )
2754/// # .build(
2755/// # hyper_rustls::HttpsConnectorBuilder::new()
2756/// # .with_native_roots()
2757/// # .unwrap()
2758/// # .https_or_http()
2759/// # .enable_http1()
2760/// # .build()
2761/// # );
2762/// # let mut hub = CloudIot::new(client, auth);
2763/// // You can configure optional parameters by calling the respective setters at will, and
2764/// // execute the final call using `doit()`.
2765/// // Values shown here are possibly random and not representative !
2766/// let result = hub.projects().locations_registries_devices_get("name")
2767/// .field_mask(FieldMask::new::<&str>(&[]))
2768/// .doit().await;
2769/// # }
2770/// ```
2771pub struct ProjectLocationRegistryDeviceGetCall<'a, C>
2772where
2773 C: 'a,
2774{
2775 hub: &'a CloudIot<C>,
2776 _name: String,
2777 _field_mask: Option<common::FieldMask>,
2778 _delegate: Option<&'a mut dyn common::Delegate>,
2779 _additional_params: HashMap<String, String>,
2780 _scopes: BTreeSet<String>,
2781}
2782
2783impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceGetCall<'a, C> {}
2784
2785impl<'a, C> ProjectLocationRegistryDeviceGetCall<'a, C>
2786where
2787 C: common::Connector,
2788{
2789 /// Perform the operation you have build so far.
2790 pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
2791 use std::borrow::Cow;
2792 use std::io::{Read, Seek};
2793
2794 use common::{url::Params, ToParts};
2795 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2796
2797 let mut dd = common::DefaultDelegate;
2798 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2799 dlg.begin(common::MethodInfo {
2800 id: "cloudiot.projects.locations.registries.devices.get",
2801 http_method: hyper::Method::GET,
2802 });
2803
2804 for &field in ["alt", "name", "fieldMask"].iter() {
2805 if self._additional_params.contains_key(field) {
2806 dlg.finished(false);
2807 return Err(common::Error::FieldClash(field));
2808 }
2809 }
2810
2811 let mut params = Params::with_capacity(4 + self._additional_params.len());
2812 params.push("name", self._name);
2813 if let Some(value) = self._field_mask.as_ref() {
2814 params.push("fieldMask", value.to_string());
2815 }
2816
2817 params.extend(self._additional_params.iter());
2818
2819 params.push("alt", "json");
2820 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2821 if self._scopes.is_empty() {
2822 self._scopes
2823 .insert(Scope::CloudPlatform.as_ref().to_string());
2824 }
2825
2826 #[allow(clippy::single_element_loop)]
2827 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2828 url = params.uri_replacement(url, param_name, find_this, true);
2829 }
2830 {
2831 let to_remove = ["name"];
2832 params.remove_params(&to_remove);
2833 }
2834
2835 let url = params.parse_with_url(&url);
2836
2837 loop {
2838 let token = match self
2839 .hub
2840 .auth
2841 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2842 .await
2843 {
2844 Ok(token) => token,
2845 Err(e) => match dlg.token(e) {
2846 Ok(token) => token,
2847 Err(e) => {
2848 dlg.finished(false);
2849 return Err(common::Error::MissingToken(e));
2850 }
2851 },
2852 };
2853 let mut req_result = {
2854 let client = &self.hub.client;
2855 dlg.pre_request();
2856 let mut req_builder = hyper::Request::builder()
2857 .method(hyper::Method::GET)
2858 .uri(url.as_str())
2859 .header(USER_AGENT, self.hub._user_agent.clone());
2860
2861 if let Some(token) = token.as_ref() {
2862 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2863 }
2864
2865 let request = req_builder
2866 .header(CONTENT_LENGTH, 0_u64)
2867 .body(common::to_body::<String>(None));
2868
2869 client.request(request.unwrap()).await
2870 };
2871
2872 match req_result {
2873 Err(err) => {
2874 if let common::Retry::After(d) = dlg.http_error(&err) {
2875 sleep(d).await;
2876 continue;
2877 }
2878 dlg.finished(false);
2879 return Err(common::Error::HttpError(err));
2880 }
2881 Ok(res) => {
2882 let (mut parts, body) = res.into_parts();
2883 let mut body = common::Body::new(body);
2884 if !parts.status.is_success() {
2885 let bytes = common::to_bytes(body).await.unwrap_or_default();
2886 let error = serde_json::from_str(&common::to_string(&bytes));
2887 let response = common::to_response(parts, bytes.into());
2888
2889 if let common::Retry::After(d) =
2890 dlg.http_failure(&response, error.as_ref().ok())
2891 {
2892 sleep(d).await;
2893 continue;
2894 }
2895
2896 dlg.finished(false);
2897
2898 return Err(match error {
2899 Ok(value) => common::Error::BadRequest(value),
2900 _ => common::Error::Failure(response),
2901 });
2902 }
2903 let response = {
2904 let bytes = common::to_bytes(body).await.unwrap_or_default();
2905 let encoded = common::to_string(&bytes);
2906 match serde_json::from_str(&encoded) {
2907 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2908 Err(error) => {
2909 dlg.response_json_decode_error(&encoded, &error);
2910 return Err(common::Error::JsonDecodeError(
2911 encoded.to_string(),
2912 error,
2913 ));
2914 }
2915 }
2916 };
2917
2918 dlg.finished(true);
2919 return Ok(response);
2920 }
2921 }
2922 }
2923 }
2924
2925 /// 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}`.
2926 ///
2927 /// Sets the *name* path property to the given value.
2928 ///
2929 /// Even though the property as already been set when instantiating this call,
2930 /// we provide this method for API completeness.
2931 pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
2932 self._name = new_value.to_string();
2933 self
2934 }
2935 /// 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`.
2936 ///
2937 /// Sets the *field mask* query property to the given value.
2938 pub fn field_mask(
2939 mut self,
2940 new_value: common::FieldMask,
2941 ) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
2942 self._field_mask = Some(new_value);
2943 self
2944 }
2945 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2946 /// while executing the actual API request.
2947 ///
2948 /// ````text
2949 /// It should be used to handle progress information, and to implement a certain level of resilience.
2950 /// ````
2951 ///
2952 /// Sets the *delegate* property to the given value.
2953 pub fn delegate(
2954 mut self,
2955 new_value: &'a mut dyn common::Delegate,
2956 ) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
2957 self._delegate = Some(new_value);
2958 self
2959 }
2960
2961 /// Set any additional parameter of the query string used in the request.
2962 /// It should be used to set parameters which are not yet available through their own
2963 /// setters.
2964 ///
2965 /// Please note that this method must not be used to set any of the known parameters
2966 /// which have their own setter method. If done anyway, the request will fail.
2967 ///
2968 /// # Additional Parameters
2969 ///
2970 /// * *$.xgafv* (query-string) - V1 error format.
2971 /// * *access_token* (query-string) - OAuth access token.
2972 /// * *alt* (query-string) - Data format for response.
2973 /// * *callback* (query-string) - JSONP
2974 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2975 /// * *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.
2976 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2977 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2978 /// * *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.
2979 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2980 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2981 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceGetCall<'a, C>
2982 where
2983 T: AsRef<str>,
2984 {
2985 self._additional_params
2986 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2987 self
2988 }
2989
2990 /// Identifies the authorization scope for the method you are building.
2991 ///
2992 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2993 /// [`Scope::CloudPlatform`].
2994 ///
2995 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2996 /// tokens for more than one scope.
2997 ///
2998 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2999 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3000 /// sufficient, a read-write scope will do as well.
3001 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceGetCall<'a, C>
3002 where
3003 St: AsRef<str>,
3004 {
3005 self._scopes.insert(String::from(scope.as_ref()));
3006 self
3007 }
3008 /// Identifies the authorization scope(s) for the method you are building.
3009 ///
3010 /// See [`Self::add_scope()`] for details.
3011 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceGetCall<'a, C>
3012 where
3013 I: IntoIterator<Item = St>,
3014 St: AsRef<str>,
3015 {
3016 self._scopes
3017 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3018 self
3019 }
3020
3021 /// Removes all scopes, and no default scope will be used either.
3022 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3023 /// for details).
3024 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceGetCall<'a, C> {
3025 self._scopes.clear();
3026 self
3027 }
3028}
3029
3030/// List devices in a device registry.
3031///
3032/// A builder for the *locations.registries.devices.list* method supported by a *project* resource.
3033/// It is not used directly, but through a [`ProjectMethods`] instance.
3034///
3035/// # Example
3036///
3037/// Instantiate a resource method builder
3038///
3039/// ```test_harness,no_run
3040/// # extern crate hyper;
3041/// # extern crate hyper_rustls;
3042/// # extern crate google_cloudiot1 as cloudiot1;
3043/// # async fn dox() {
3044/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3045///
3046/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3047/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3048/// # secret,
3049/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3050/// # ).build().await.unwrap();
3051///
3052/// # let client = hyper_util::client::legacy::Client::builder(
3053/// # hyper_util::rt::TokioExecutor::new()
3054/// # )
3055/// # .build(
3056/// # hyper_rustls::HttpsConnectorBuilder::new()
3057/// # .with_native_roots()
3058/// # .unwrap()
3059/// # .https_or_http()
3060/// # .enable_http1()
3061/// # .build()
3062/// # );
3063/// # let mut hub = CloudIot::new(client, auth);
3064/// // You can configure optional parameters by calling the respective setters at will, and
3065/// // execute the final call using `doit()`.
3066/// // Values shown here are possibly random and not representative !
3067/// let result = hub.projects().locations_registries_devices_list("parent")
3068/// .page_token("duo")
3069/// .page_size(-55)
3070/// .gateway_list_options_gateway_type("gubergren")
3071/// .gateway_list_options_associations_gateway_id("Lorem")
3072/// .gateway_list_options_associations_device_id("gubergren")
3073/// .field_mask(FieldMask::new::<&str>(&[]))
3074/// .add_device_num_ids(26)
3075/// .add_device_ids("dolor")
3076/// .doit().await;
3077/// # }
3078/// ```
3079pub struct ProjectLocationRegistryDeviceListCall<'a, C>
3080where
3081 C: 'a,
3082{
3083 hub: &'a CloudIot<C>,
3084 _parent: String,
3085 _page_token: Option<String>,
3086 _page_size: Option<i32>,
3087 _gateway_list_options_gateway_type: Option<String>,
3088 _gateway_list_options_associations_gateway_id: Option<String>,
3089 _gateway_list_options_associations_device_id: Option<String>,
3090 _field_mask: Option<common::FieldMask>,
3091 _device_num_ids: Vec<u64>,
3092 _device_ids: Vec<String>,
3093 _delegate: Option<&'a mut dyn common::Delegate>,
3094 _additional_params: HashMap<String, String>,
3095 _scopes: BTreeSet<String>,
3096}
3097
3098impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceListCall<'a, C> {}
3099
3100impl<'a, C> ProjectLocationRegistryDeviceListCall<'a, C>
3101where
3102 C: common::Connector,
3103{
3104 /// Perform the operation you have build so far.
3105 pub async fn doit(mut self) -> common::Result<(common::Response, ListDevicesResponse)> {
3106 use std::borrow::Cow;
3107 use std::io::{Read, Seek};
3108
3109 use common::{url::Params, ToParts};
3110 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3111
3112 let mut dd = common::DefaultDelegate;
3113 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3114 dlg.begin(common::MethodInfo {
3115 id: "cloudiot.projects.locations.registries.devices.list",
3116 http_method: hyper::Method::GET,
3117 });
3118
3119 for &field in [
3120 "alt",
3121 "parent",
3122 "pageToken",
3123 "pageSize",
3124 "gatewayListOptions.gatewayType",
3125 "gatewayListOptions.associationsGatewayId",
3126 "gatewayListOptions.associationsDeviceId",
3127 "fieldMask",
3128 "deviceNumIds",
3129 "deviceIds",
3130 ]
3131 .iter()
3132 {
3133 if self._additional_params.contains_key(field) {
3134 dlg.finished(false);
3135 return Err(common::Error::FieldClash(field));
3136 }
3137 }
3138
3139 let mut params = Params::with_capacity(11 + self._additional_params.len());
3140 params.push("parent", self._parent);
3141 if let Some(value) = self._page_token.as_ref() {
3142 params.push("pageToken", value);
3143 }
3144 if let Some(value) = self._page_size.as_ref() {
3145 params.push("pageSize", value.to_string());
3146 }
3147 if let Some(value) = self._gateway_list_options_gateway_type.as_ref() {
3148 params.push("gatewayListOptions.gatewayType", value);
3149 }
3150 if let Some(value) = self._gateway_list_options_associations_gateway_id.as_ref() {
3151 params.push("gatewayListOptions.associationsGatewayId", value);
3152 }
3153 if let Some(value) = self._gateway_list_options_associations_device_id.as_ref() {
3154 params.push("gatewayListOptions.associationsDeviceId", value);
3155 }
3156 if let Some(value) = self._field_mask.as_ref() {
3157 params.push("fieldMask", value.to_string());
3158 }
3159 if !self._device_num_ids.is_empty() {
3160 for f in self._device_num_ids.iter() {
3161 params.push("deviceNumIds", f.to_string());
3162 }
3163 }
3164 if !self._device_ids.is_empty() {
3165 for f in self._device_ids.iter() {
3166 params.push("deviceIds", f);
3167 }
3168 }
3169
3170 params.extend(self._additional_params.iter());
3171
3172 params.push("alt", "json");
3173 let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
3174 if self._scopes.is_empty() {
3175 self._scopes
3176 .insert(Scope::CloudPlatform.as_ref().to_string());
3177 }
3178
3179 #[allow(clippy::single_element_loop)]
3180 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3181 url = params.uri_replacement(url, param_name, find_this, true);
3182 }
3183 {
3184 let to_remove = ["parent"];
3185 params.remove_params(&to_remove);
3186 }
3187
3188 let url = params.parse_with_url(&url);
3189
3190 loop {
3191 let token = match self
3192 .hub
3193 .auth
3194 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3195 .await
3196 {
3197 Ok(token) => token,
3198 Err(e) => match dlg.token(e) {
3199 Ok(token) => token,
3200 Err(e) => {
3201 dlg.finished(false);
3202 return Err(common::Error::MissingToken(e));
3203 }
3204 },
3205 };
3206 let mut req_result = {
3207 let client = &self.hub.client;
3208 dlg.pre_request();
3209 let mut req_builder = hyper::Request::builder()
3210 .method(hyper::Method::GET)
3211 .uri(url.as_str())
3212 .header(USER_AGENT, self.hub._user_agent.clone());
3213
3214 if let Some(token) = token.as_ref() {
3215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3216 }
3217
3218 let request = req_builder
3219 .header(CONTENT_LENGTH, 0_u64)
3220 .body(common::to_body::<String>(None));
3221
3222 client.request(request.unwrap()).await
3223 };
3224
3225 match req_result {
3226 Err(err) => {
3227 if let common::Retry::After(d) = dlg.http_error(&err) {
3228 sleep(d).await;
3229 continue;
3230 }
3231 dlg.finished(false);
3232 return Err(common::Error::HttpError(err));
3233 }
3234 Ok(res) => {
3235 let (mut parts, body) = res.into_parts();
3236 let mut body = common::Body::new(body);
3237 if !parts.status.is_success() {
3238 let bytes = common::to_bytes(body).await.unwrap_or_default();
3239 let error = serde_json::from_str(&common::to_string(&bytes));
3240 let response = common::to_response(parts, bytes.into());
3241
3242 if let common::Retry::After(d) =
3243 dlg.http_failure(&response, error.as_ref().ok())
3244 {
3245 sleep(d).await;
3246 continue;
3247 }
3248
3249 dlg.finished(false);
3250
3251 return Err(match error {
3252 Ok(value) => common::Error::BadRequest(value),
3253 _ => common::Error::Failure(response),
3254 });
3255 }
3256 let response = {
3257 let bytes = common::to_bytes(body).await.unwrap_or_default();
3258 let encoded = common::to_string(&bytes);
3259 match serde_json::from_str(&encoded) {
3260 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3261 Err(error) => {
3262 dlg.response_json_decode_error(&encoded, &error);
3263 return Err(common::Error::JsonDecodeError(
3264 encoded.to_string(),
3265 error,
3266 ));
3267 }
3268 }
3269 };
3270
3271 dlg.finished(true);
3272 return Ok(response);
3273 }
3274 }
3275 }
3276 }
3277
3278 /// Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
3279 ///
3280 /// Sets the *parent* path property to the given value.
3281 ///
3282 /// Even though the property as already been set when instantiating this call,
3283 /// we provide this method for API completeness.
3284 pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3285 self._parent = new_value.to_string();
3286 self
3287 }
3288 /// 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.
3289 ///
3290 /// Sets the *page token* query property to the given value.
3291 pub fn page_token(mut self, new_value: &str) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3292 self._page_token = Some(new_value.to_string());
3293 self
3294 }
3295 /// 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.
3296 ///
3297 /// Sets the *page size* query property to the given value.
3298 pub fn page_size(mut self, new_value: i32) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3299 self._page_size = Some(new_value);
3300 self
3301 }
3302 /// 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.
3303 ///
3304 /// Sets the *gateway list options.gateway type* query property to the given value.
3305 pub fn gateway_list_options_gateway_type(
3306 mut self,
3307 new_value: &str,
3308 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3309 self._gateway_list_options_gateway_type = Some(new_value.to_string());
3310 self
3311 }
3312 /// 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.
3313 ///
3314 /// Sets the *gateway list options.associations gateway id* query property to the given value.
3315 pub fn gateway_list_options_associations_gateway_id(
3316 mut self,
3317 new_value: &str,
3318 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3319 self._gateway_list_options_associations_gateway_id = Some(new_value.to_string());
3320 self
3321 }
3322 /// 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.
3323 ///
3324 /// Sets the *gateway list options.associations device id* query property to the given value.
3325 pub fn gateway_list_options_associations_device_id(
3326 mut self,
3327 new_value: &str,
3328 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3329 self._gateway_list_options_associations_device_id = Some(new_value.to_string());
3330 self
3331 }
3332 /// 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`.
3333 ///
3334 /// Sets the *field mask* query property to the given value.
3335 pub fn field_mask(
3336 mut self,
3337 new_value: common::FieldMask,
3338 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3339 self._field_mask = Some(new_value);
3340 self
3341 }
3342 /// A list of device numeric IDs. If empty, this field is ignored. Maximum IDs: 10,000.
3343 ///
3344 /// Append the given value to the *device num ids* query property.
3345 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3346 pub fn add_device_num_ids(
3347 mut self,
3348 new_value: u64,
3349 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3350 self._device_num_ids.push(new_value);
3351 self
3352 }
3353 /// A list of device string IDs. For example, `['device0', 'device12']`. If empty, this field is ignored. Maximum IDs: 10,000
3354 ///
3355 /// Append the given value to the *device ids* query property.
3356 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3357 pub fn add_device_ids(
3358 mut self,
3359 new_value: &str,
3360 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3361 self._device_ids.push(new_value.to_string());
3362 self
3363 }
3364 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3365 /// while executing the actual API request.
3366 ///
3367 /// ````text
3368 /// It should be used to handle progress information, and to implement a certain level of resilience.
3369 /// ````
3370 ///
3371 /// Sets the *delegate* property to the given value.
3372 pub fn delegate(
3373 mut self,
3374 new_value: &'a mut dyn common::Delegate,
3375 ) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3376 self._delegate = Some(new_value);
3377 self
3378 }
3379
3380 /// Set any additional parameter of the query string used in the request.
3381 /// It should be used to set parameters which are not yet available through their own
3382 /// setters.
3383 ///
3384 /// Please note that this method must not be used to set any of the known parameters
3385 /// which have their own setter method. If done anyway, the request will fail.
3386 ///
3387 /// # Additional Parameters
3388 ///
3389 /// * *$.xgafv* (query-string) - V1 error format.
3390 /// * *access_token* (query-string) - OAuth access token.
3391 /// * *alt* (query-string) - Data format for response.
3392 /// * *callback* (query-string) - JSONP
3393 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3394 /// * *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.
3395 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3396 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3397 /// * *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.
3398 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3399 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3400 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeviceListCall<'a, C>
3401 where
3402 T: AsRef<str>,
3403 {
3404 self._additional_params
3405 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3406 self
3407 }
3408
3409 /// Identifies the authorization scope for the method you are building.
3410 ///
3411 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3412 /// [`Scope::CloudPlatform`].
3413 ///
3414 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3415 /// tokens for more than one scope.
3416 ///
3417 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3418 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3419 /// sufficient, a read-write scope will do as well.
3420 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeviceListCall<'a, C>
3421 where
3422 St: AsRef<str>,
3423 {
3424 self._scopes.insert(String::from(scope.as_ref()));
3425 self
3426 }
3427 /// Identifies the authorization scope(s) for the method you are building.
3428 ///
3429 /// See [`Self::add_scope()`] for details.
3430 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeviceListCall<'a, C>
3431 where
3432 I: IntoIterator<Item = St>,
3433 St: AsRef<str>,
3434 {
3435 self._scopes
3436 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3437 self
3438 }
3439
3440 /// Removes all scopes, and no default scope will be used either.
3441 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3442 /// for details).
3443 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceListCall<'a, C> {
3444 self._scopes.clear();
3445 self
3446 }
3447}
3448
3449/// Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.
3450///
3451/// A builder for the *locations.registries.devices.modifyCloudToDeviceConfig* method supported by a *project* resource.
3452/// It is not used directly, but through a [`ProjectMethods`] instance.
3453///
3454/// # Example
3455///
3456/// Instantiate a resource method builder
3457///
3458/// ```test_harness,no_run
3459/// # extern crate hyper;
3460/// # extern crate hyper_rustls;
3461/// # extern crate google_cloudiot1 as cloudiot1;
3462/// use cloudiot1::api::ModifyCloudToDeviceConfigRequest;
3463/// # async fn dox() {
3464/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3465///
3466/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3467/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3468/// # secret,
3469/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3470/// # ).build().await.unwrap();
3471///
3472/// # let client = hyper_util::client::legacy::Client::builder(
3473/// # hyper_util::rt::TokioExecutor::new()
3474/// # )
3475/// # .build(
3476/// # hyper_rustls::HttpsConnectorBuilder::new()
3477/// # .with_native_roots()
3478/// # .unwrap()
3479/// # .https_or_http()
3480/// # .enable_http1()
3481/// # .build()
3482/// # );
3483/// # let mut hub = CloudIot::new(client, auth);
3484/// // As the method needs a request, you would usually fill it with the desired information
3485/// // into the respective structure. Some of the parts shown here might not be applicable !
3486/// // Values shown here are possibly random and not representative !
3487/// let mut req = ModifyCloudToDeviceConfigRequest::default();
3488///
3489/// // You can configure optional parameters by calling the respective setters at will, and
3490/// // execute the final call using `doit()`.
3491/// // Values shown here are possibly random and not representative !
3492/// let result = hub.projects().locations_registries_devices_modify_cloud_to_device_config(req, "name")
3493/// .doit().await;
3494/// # }
3495/// ```
3496pub struct ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3497where
3498 C: 'a,
3499{
3500 hub: &'a CloudIot<C>,
3501 _request: ModifyCloudToDeviceConfigRequest,
3502 _name: String,
3503 _delegate: Option<&'a mut dyn common::Delegate>,
3504 _additional_params: HashMap<String, String>,
3505 _scopes: BTreeSet<String>,
3506}
3507
3508impl<'a, C> common::CallBuilder
3509 for ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3510{
3511}
3512
3513impl<'a, C> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3514where
3515 C: common::Connector,
3516{
3517 /// Perform the operation you have build so far.
3518 pub async fn doit(mut self) -> common::Result<(common::Response, DeviceConfig)> {
3519 use std::borrow::Cow;
3520 use std::io::{Read, Seek};
3521
3522 use common::{url::Params, ToParts};
3523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3524
3525 let mut dd = common::DefaultDelegate;
3526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3527 dlg.begin(common::MethodInfo {
3528 id: "cloudiot.projects.locations.registries.devices.modifyCloudToDeviceConfig",
3529 http_method: hyper::Method::POST,
3530 });
3531
3532 for &field in ["alt", "name"].iter() {
3533 if self._additional_params.contains_key(field) {
3534 dlg.finished(false);
3535 return Err(common::Error::FieldClash(field));
3536 }
3537 }
3538
3539 let mut params = Params::with_capacity(4 + self._additional_params.len());
3540 params.push("name", self._name);
3541
3542 params.extend(self._additional_params.iter());
3543
3544 params.push("alt", "json");
3545 let mut url = self.hub._base_url.clone() + "v1/{+name}:modifyCloudToDeviceConfig";
3546 if self._scopes.is_empty() {
3547 self._scopes
3548 .insert(Scope::CloudPlatform.as_ref().to_string());
3549 }
3550
3551 #[allow(clippy::single_element_loop)]
3552 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3553 url = params.uri_replacement(url, param_name, find_this, true);
3554 }
3555 {
3556 let to_remove = ["name"];
3557 params.remove_params(&to_remove);
3558 }
3559
3560 let url = params.parse_with_url(&url);
3561
3562 let mut json_mime_type = mime::APPLICATION_JSON;
3563 let mut request_value_reader = {
3564 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3565 common::remove_json_null_values(&mut value);
3566 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3567 serde_json::to_writer(&mut dst, &value).unwrap();
3568 dst
3569 };
3570 let request_size = request_value_reader
3571 .seek(std::io::SeekFrom::End(0))
3572 .unwrap();
3573 request_value_reader
3574 .seek(std::io::SeekFrom::Start(0))
3575 .unwrap();
3576
3577 loop {
3578 let token = match self
3579 .hub
3580 .auth
3581 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3582 .await
3583 {
3584 Ok(token) => token,
3585 Err(e) => match dlg.token(e) {
3586 Ok(token) => token,
3587 Err(e) => {
3588 dlg.finished(false);
3589 return Err(common::Error::MissingToken(e));
3590 }
3591 },
3592 };
3593 request_value_reader
3594 .seek(std::io::SeekFrom::Start(0))
3595 .unwrap();
3596 let mut req_result = {
3597 let client = &self.hub.client;
3598 dlg.pre_request();
3599 let mut req_builder = hyper::Request::builder()
3600 .method(hyper::Method::POST)
3601 .uri(url.as_str())
3602 .header(USER_AGENT, self.hub._user_agent.clone());
3603
3604 if let Some(token) = token.as_ref() {
3605 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3606 }
3607
3608 let request = req_builder
3609 .header(CONTENT_TYPE, json_mime_type.to_string())
3610 .header(CONTENT_LENGTH, request_size as u64)
3611 .body(common::to_body(
3612 request_value_reader.get_ref().clone().into(),
3613 ));
3614
3615 client.request(request.unwrap()).await
3616 };
3617
3618 match req_result {
3619 Err(err) => {
3620 if let common::Retry::After(d) = dlg.http_error(&err) {
3621 sleep(d).await;
3622 continue;
3623 }
3624 dlg.finished(false);
3625 return Err(common::Error::HttpError(err));
3626 }
3627 Ok(res) => {
3628 let (mut parts, body) = res.into_parts();
3629 let mut body = common::Body::new(body);
3630 if !parts.status.is_success() {
3631 let bytes = common::to_bytes(body).await.unwrap_or_default();
3632 let error = serde_json::from_str(&common::to_string(&bytes));
3633 let response = common::to_response(parts, bytes.into());
3634
3635 if let common::Retry::After(d) =
3636 dlg.http_failure(&response, error.as_ref().ok())
3637 {
3638 sleep(d).await;
3639 continue;
3640 }
3641
3642 dlg.finished(false);
3643
3644 return Err(match error {
3645 Ok(value) => common::Error::BadRequest(value),
3646 _ => common::Error::Failure(response),
3647 });
3648 }
3649 let response = {
3650 let bytes = common::to_bytes(body).await.unwrap_or_default();
3651 let encoded = common::to_string(&bytes);
3652 match serde_json::from_str(&encoded) {
3653 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3654 Err(error) => {
3655 dlg.response_json_decode_error(&encoded, &error);
3656 return Err(common::Error::JsonDecodeError(
3657 encoded.to_string(),
3658 error,
3659 ));
3660 }
3661 }
3662 };
3663
3664 dlg.finished(true);
3665 return Ok(response);
3666 }
3667 }
3668 }
3669 }
3670
3671 ///
3672 /// Sets the *request* property to the given value.
3673 ///
3674 /// Even though the property as already been set when instantiating this call,
3675 /// we provide this method for API completeness.
3676 pub fn request(
3677 mut self,
3678 new_value: ModifyCloudToDeviceConfigRequest,
3679 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3680 self._request = new_value;
3681 self
3682 }
3683 /// 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}`.
3684 ///
3685 /// Sets the *name* path property to the given value.
3686 ///
3687 /// Even though the property as already been set when instantiating this call,
3688 /// we provide this method for API completeness.
3689 pub fn name(
3690 mut self,
3691 new_value: &str,
3692 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3693 self._name = new_value.to_string();
3694 self
3695 }
3696 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3697 /// while executing the actual API request.
3698 ///
3699 /// ````text
3700 /// It should be used to handle progress information, and to implement a certain level of resilience.
3701 /// ````
3702 ///
3703 /// Sets the *delegate* property to the given value.
3704 pub fn delegate(
3705 mut self,
3706 new_value: &'a mut dyn common::Delegate,
3707 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3708 self._delegate = Some(new_value);
3709 self
3710 }
3711
3712 /// Set any additional parameter of the query string used in the request.
3713 /// It should be used to set parameters which are not yet available through their own
3714 /// setters.
3715 ///
3716 /// Please note that this method must not be used to set any of the known parameters
3717 /// which have their own setter method. If done anyway, the request will fail.
3718 ///
3719 /// # Additional Parameters
3720 ///
3721 /// * *$.xgafv* (query-string) - V1 error format.
3722 /// * *access_token* (query-string) - OAuth access token.
3723 /// * *alt* (query-string) - Data format for response.
3724 /// * *callback* (query-string) - JSONP
3725 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3726 /// * *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.
3727 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3728 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3729 /// * *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.
3730 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3731 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3732 pub fn param<T>(
3733 mut self,
3734 name: T,
3735 value: T,
3736 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3737 where
3738 T: AsRef<str>,
3739 {
3740 self._additional_params
3741 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3742 self
3743 }
3744
3745 /// Identifies the authorization scope for the method you are building.
3746 ///
3747 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3748 /// [`Scope::CloudPlatform`].
3749 ///
3750 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3751 /// tokens for more than one scope.
3752 ///
3753 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3754 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3755 /// sufficient, a read-write scope will do as well.
3756 pub fn add_scope<St>(
3757 mut self,
3758 scope: St,
3759 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3760 where
3761 St: AsRef<str>,
3762 {
3763 self._scopes.insert(String::from(scope.as_ref()));
3764 self
3765 }
3766 /// Identifies the authorization scope(s) for the method you are building.
3767 ///
3768 /// See [`Self::add_scope()`] for details.
3769 pub fn add_scopes<I, St>(
3770 mut self,
3771 scopes: I,
3772 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C>
3773 where
3774 I: IntoIterator<Item = St>,
3775 St: AsRef<str>,
3776 {
3777 self._scopes
3778 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3779 self
3780 }
3781
3782 /// Removes all scopes, and no default scope will be used either.
3783 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3784 /// for details).
3785 pub fn clear_scopes(
3786 mut self,
3787 ) -> ProjectLocationRegistryDeviceModifyCloudToDeviceConfigCall<'a, C> {
3788 self._scopes.clear();
3789 self
3790 }
3791}
3792
3793/// Updates a device.
3794///
3795/// A builder for the *locations.registries.devices.patch* method supported by a *project* resource.
3796/// It is not used directly, but through a [`ProjectMethods`] instance.
3797///
3798/// # Example
3799///
3800/// Instantiate a resource method builder
3801///
3802/// ```test_harness,no_run
3803/// # extern crate hyper;
3804/// # extern crate hyper_rustls;
3805/// # extern crate google_cloudiot1 as cloudiot1;
3806/// use cloudiot1::api::Device;
3807/// # async fn dox() {
3808/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3809///
3810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3811/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3812/// # secret,
3813/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3814/// # ).build().await.unwrap();
3815///
3816/// # let client = hyper_util::client::legacy::Client::builder(
3817/// # hyper_util::rt::TokioExecutor::new()
3818/// # )
3819/// # .build(
3820/// # hyper_rustls::HttpsConnectorBuilder::new()
3821/// # .with_native_roots()
3822/// # .unwrap()
3823/// # .https_or_http()
3824/// # .enable_http1()
3825/// # .build()
3826/// # );
3827/// # let mut hub = CloudIot::new(client, auth);
3828/// // As the method needs a request, you would usually fill it with the desired information
3829/// // into the respective structure. Some of the parts shown here might not be applicable !
3830/// // Values shown here are possibly random and not representative !
3831/// let mut req = Device::default();
3832///
3833/// // You can configure optional parameters by calling the respective setters at will, and
3834/// // execute the final call using `doit()`.
3835/// // Values shown here are possibly random and not representative !
3836/// let result = hub.projects().locations_registries_devices_patch(req, "name")
3837/// .update_mask(FieldMask::new::<&str>(&[]))
3838/// .doit().await;
3839/// # }
3840/// ```
3841pub struct ProjectLocationRegistryDevicePatchCall<'a, C>
3842where
3843 C: 'a,
3844{
3845 hub: &'a CloudIot<C>,
3846 _request: Device,
3847 _name: String,
3848 _update_mask: Option<common::FieldMask>,
3849 _delegate: Option<&'a mut dyn common::Delegate>,
3850 _additional_params: HashMap<String, String>,
3851 _scopes: BTreeSet<String>,
3852}
3853
3854impl<'a, C> common::CallBuilder for ProjectLocationRegistryDevicePatchCall<'a, C> {}
3855
3856impl<'a, C> ProjectLocationRegistryDevicePatchCall<'a, C>
3857where
3858 C: common::Connector,
3859{
3860 /// Perform the operation you have build so far.
3861 pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
3862 use std::borrow::Cow;
3863 use std::io::{Read, Seek};
3864
3865 use common::{url::Params, ToParts};
3866 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3867
3868 let mut dd = common::DefaultDelegate;
3869 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3870 dlg.begin(common::MethodInfo {
3871 id: "cloudiot.projects.locations.registries.devices.patch",
3872 http_method: hyper::Method::PATCH,
3873 });
3874
3875 for &field in ["alt", "name", "updateMask"].iter() {
3876 if self._additional_params.contains_key(field) {
3877 dlg.finished(false);
3878 return Err(common::Error::FieldClash(field));
3879 }
3880 }
3881
3882 let mut params = Params::with_capacity(5 + self._additional_params.len());
3883 params.push("name", self._name);
3884 if let Some(value) = self._update_mask.as_ref() {
3885 params.push("updateMask", value.to_string());
3886 }
3887
3888 params.extend(self._additional_params.iter());
3889
3890 params.push("alt", "json");
3891 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3892 if self._scopes.is_empty() {
3893 self._scopes
3894 .insert(Scope::CloudPlatform.as_ref().to_string());
3895 }
3896
3897 #[allow(clippy::single_element_loop)]
3898 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3899 url = params.uri_replacement(url, param_name, find_this, true);
3900 }
3901 {
3902 let to_remove = ["name"];
3903 params.remove_params(&to_remove);
3904 }
3905
3906 let url = params.parse_with_url(&url);
3907
3908 let mut json_mime_type = mime::APPLICATION_JSON;
3909 let mut request_value_reader = {
3910 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3911 common::remove_json_null_values(&mut value);
3912 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3913 serde_json::to_writer(&mut dst, &value).unwrap();
3914 dst
3915 };
3916 let request_size = request_value_reader
3917 .seek(std::io::SeekFrom::End(0))
3918 .unwrap();
3919 request_value_reader
3920 .seek(std::io::SeekFrom::Start(0))
3921 .unwrap();
3922
3923 loop {
3924 let token = match self
3925 .hub
3926 .auth
3927 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3928 .await
3929 {
3930 Ok(token) => token,
3931 Err(e) => match dlg.token(e) {
3932 Ok(token) => token,
3933 Err(e) => {
3934 dlg.finished(false);
3935 return Err(common::Error::MissingToken(e));
3936 }
3937 },
3938 };
3939 request_value_reader
3940 .seek(std::io::SeekFrom::Start(0))
3941 .unwrap();
3942 let mut req_result = {
3943 let client = &self.hub.client;
3944 dlg.pre_request();
3945 let mut req_builder = hyper::Request::builder()
3946 .method(hyper::Method::PATCH)
3947 .uri(url.as_str())
3948 .header(USER_AGENT, self.hub._user_agent.clone());
3949
3950 if let Some(token) = token.as_ref() {
3951 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3952 }
3953
3954 let request = req_builder
3955 .header(CONTENT_TYPE, json_mime_type.to_string())
3956 .header(CONTENT_LENGTH, request_size as u64)
3957 .body(common::to_body(
3958 request_value_reader.get_ref().clone().into(),
3959 ));
3960
3961 client.request(request.unwrap()).await
3962 };
3963
3964 match req_result {
3965 Err(err) => {
3966 if let common::Retry::After(d) = dlg.http_error(&err) {
3967 sleep(d).await;
3968 continue;
3969 }
3970 dlg.finished(false);
3971 return Err(common::Error::HttpError(err));
3972 }
3973 Ok(res) => {
3974 let (mut parts, body) = res.into_parts();
3975 let mut body = common::Body::new(body);
3976 if !parts.status.is_success() {
3977 let bytes = common::to_bytes(body).await.unwrap_or_default();
3978 let error = serde_json::from_str(&common::to_string(&bytes));
3979 let response = common::to_response(parts, bytes.into());
3980
3981 if let common::Retry::After(d) =
3982 dlg.http_failure(&response, error.as_ref().ok())
3983 {
3984 sleep(d).await;
3985 continue;
3986 }
3987
3988 dlg.finished(false);
3989
3990 return Err(match error {
3991 Ok(value) => common::Error::BadRequest(value),
3992 _ => common::Error::Failure(response),
3993 });
3994 }
3995 let response = {
3996 let bytes = common::to_bytes(body).await.unwrap_or_default();
3997 let encoded = common::to_string(&bytes);
3998 match serde_json::from_str(&encoded) {
3999 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4000 Err(error) => {
4001 dlg.response_json_decode_error(&encoded, &error);
4002 return Err(common::Error::JsonDecodeError(
4003 encoded.to_string(),
4004 error,
4005 ));
4006 }
4007 }
4008 };
4009
4010 dlg.finished(true);
4011 return Ok(response);
4012 }
4013 }
4014 }
4015 }
4016
4017 ///
4018 /// Sets the *request* property to the given value.
4019 ///
4020 /// Even though the property as already been set when instantiating this call,
4021 /// we provide this method for API completeness.
4022 pub fn request(mut self, new_value: Device) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4023 self._request = new_value;
4024 self
4025 }
4026 /// 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.
4027 ///
4028 /// Sets the *name* path property to the given value.
4029 ///
4030 /// Even though the property as already been set when instantiating this call,
4031 /// we provide this method for API completeness.
4032 pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4033 self._name = new_value.to_string();
4034 self
4035 }
4036 /// 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`
4037 ///
4038 /// Sets the *update mask* query property to the given value.
4039 pub fn update_mask(
4040 mut self,
4041 new_value: common::FieldMask,
4042 ) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4043 self._update_mask = Some(new_value);
4044 self
4045 }
4046 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4047 /// while executing the actual API request.
4048 ///
4049 /// ````text
4050 /// It should be used to handle progress information, and to implement a certain level of resilience.
4051 /// ````
4052 ///
4053 /// Sets the *delegate* property to the given value.
4054 pub fn delegate(
4055 mut self,
4056 new_value: &'a mut dyn common::Delegate,
4057 ) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4058 self._delegate = Some(new_value);
4059 self
4060 }
4061
4062 /// Set any additional parameter of the query string used in the request.
4063 /// It should be used to set parameters which are not yet available through their own
4064 /// setters.
4065 ///
4066 /// Please note that this method must not be used to set any of the known parameters
4067 /// which have their own setter method. If done anyway, the request will fail.
4068 ///
4069 /// # Additional Parameters
4070 ///
4071 /// * *$.xgafv* (query-string) - V1 error format.
4072 /// * *access_token* (query-string) - OAuth access token.
4073 /// * *alt* (query-string) - Data format for response.
4074 /// * *callback* (query-string) - JSONP
4075 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4076 /// * *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.
4077 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4078 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4079 /// * *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.
4080 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4081 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4082 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDevicePatchCall<'a, C>
4083 where
4084 T: AsRef<str>,
4085 {
4086 self._additional_params
4087 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4088 self
4089 }
4090
4091 /// Identifies the authorization scope for the method you are building.
4092 ///
4093 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4094 /// [`Scope::CloudPlatform`].
4095 ///
4096 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4097 /// tokens for more than one scope.
4098 ///
4099 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4100 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4101 /// sufficient, a read-write scope will do as well.
4102 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDevicePatchCall<'a, C>
4103 where
4104 St: AsRef<str>,
4105 {
4106 self._scopes.insert(String::from(scope.as_ref()));
4107 self
4108 }
4109 /// Identifies the authorization scope(s) for the method you are building.
4110 ///
4111 /// See [`Self::add_scope()`] for details.
4112 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDevicePatchCall<'a, C>
4113 where
4114 I: IntoIterator<Item = St>,
4115 St: AsRef<str>,
4116 {
4117 self._scopes
4118 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4119 self
4120 }
4121
4122 /// Removes all scopes, and no default scope will be used either.
4123 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4124 /// for details).
4125 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDevicePatchCall<'a, C> {
4126 self._scopes.clear();
4127 self
4128 }
4129}
4130
4131/// 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.
4132///
4133/// A builder for the *locations.registries.devices.sendCommandToDevice* method supported by a *project* resource.
4134/// It is not used directly, but through a [`ProjectMethods`] instance.
4135///
4136/// # Example
4137///
4138/// Instantiate a resource method builder
4139///
4140/// ```test_harness,no_run
4141/// # extern crate hyper;
4142/// # extern crate hyper_rustls;
4143/// # extern crate google_cloudiot1 as cloudiot1;
4144/// use cloudiot1::api::SendCommandToDeviceRequest;
4145/// # async fn dox() {
4146/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4147///
4148/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4149/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4150/// # secret,
4151/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4152/// # ).build().await.unwrap();
4153///
4154/// # let client = hyper_util::client::legacy::Client::builder(
4155/// # hyper_util::rt::TokioExecutor::new()
4156/// # )
4157/// # .build(
4158/// # hyper_rustls::HttpsConnectorBuilder::new()
4159/// # .with_native_roots()
4160/// # .unwrap()
4161/// # .https_or_http()
4162/// # .enable_http1()
4163/// # .build()
4164/// # );
4165/// # let mut hub = CloudIot::new(client, auth);
4166/// // As the method needs a request, you would usually fill it with the desired information
4167/// // into the respective structure. Some of the parts shown here might not be applicable !
4168/// // Values shown here are possibly random and not representative !
4169/// let mut req = SendCommandToDeviceRequest::default();
4170///
4171/// // You can configure optional parameters by calling the respective setters at will, and
4172/// // execute the final call using `doit()`.
4173/// // Values shown here are possibly random and not representative !
4174/// let result = hub.projects().locations_registries_devices_send_command_to_device(req, "name")
4175/// .doit().await;
4176/// # }
4177/// ```
4178pub struct ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4179where
4180 C: 'a,
4181{
4182 hub: &'a CloudIot<C>,
4183 _request: SendCommandToDeviceRequest,
4184 _name: String,
4185 _delegate: Option<&'a mut dyn common::Delegate>,
4186 _additional_params: HashMap<String, String>,
4187 _scopes: BTreeSet<String>,
4188}
4189
4190impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {}
4191
4192impl<'a, C> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4193where
4194 C: common::Connector,
4195{
4196 /// Perform the operation you have build so far.
4197 pub async fn doit(mut self) -> common::Result<(common::Response, SendCommandToDeviceResponse)> {
4198 use std::borrow::Cow;
4199 use std::io::{Read, Seek};
4200
4201 use common::{url::Params, ToParts};
4202 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4203
4204 let mut dd = common::DefaultDelegate;
4205 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4206 dlg.begin(common::MethodInfo {
4207 id: "cloudiot.projects.locations.registries.devices.sendCommandToDevice",
4208 http_method: hyper::Method::POST,
4209 });
4210
4211 for &field in ["alt", "name"].iter() {
4212 if self._additional_params.contains_key(field) {
4213 dlg.finished(false);
4214 return Err(common::Error::FieldClash(field));
4215 }
4216 }
4217
4218 let mut params = Params::with_capacity(4 + self._additional_params.len());
4219 params.push("name", self._name);
4220
4221 params.extend(self._additional_params.iter());
4222
4223 params.push("alt", "json");
4224 let mut url = self.hub._base_url.clone() + "v1/{+name}:sendCommandToDevice";
4225 if self._scopes.is_empty() {
4226 self._scopes
4227 .insert(Scope::CloudPlatform.as_ref().to_string());
4228 }
4229
4230 #[allow(clippy::single_element_loop)]
4231 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4232 url = params.uri_replacement(url, param_name, find_this, true);
4233 }
4234 {
4235 let to_remove = ["name"];
4236 params.remove_params(&to_remove);
4237 }
4238
4239 let url = params.parse_with_url(&url);
4240
4241 let mut json_mime_type = mime::APPLICATION_JSON;
4242 let mut request_value_reader = {
4243 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4244 common::remove_json_null_values(&mut value);
4245 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4246 serde_json::to_writer(&mut dst, &value).unwrap();
4247 dst
4248 };
4249 let request_size = request_value_reader
4250 .seek(std::io::SeekFrom::End(0))
4251 .unwrap();
4252 request_value_reader
4253 .seek(std::io::SeekFrom::Start(0))
4254 .unwrap();
4255
4256 loop {
4257 let token = match self
4258 .hub
4259 .auth
4260 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4261 .await
4262 {
4263 Ok(token) => token,
4264 Err(e) => match dlg.token(e) {
4265 Ok(token) => token,
4266 Err(e) => {
4267 dlg.finished(false);
4268 return Err(common::Error::MissingToken(e));
4269 }
4270 },
4271 };
4272 request_value_reader
4273 .seek(std::io::SeekFrom::Start(0))
4274 .unwrap();
4275 let mut req_result = {
4276 let client = &self.hub.client;
4277 dlg.pre_request();
4278 let mut req_builder = hyper::Request::builder()
4279 .method(hyper::Method::POST)
4280 .uri(url.as_str())
4281 .header(USER_AGENT, self.hub._user_agent.clone());
4282
4283 if let Some(token) = token.as_ref() {
4284 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4285 }
4286
4287 let request = req_builder
4288 .header(CONTENT_TYPE, json_mime_type.to_string())
4289 .header(CONTENT_LENGTH, request_size as u64)
4290 .body(common::to_body(
4291 request_value_reader.get_ref().clone().into(),
4292 ));
4293
4294 client.request(request.unwrap()).await
4295 };
4296
4297 match req_result {
4298 Err(err) => {
4299 if let common::Retry::After(d) = dlg.http_error(&err) {
4300 sleep(d).await;
4301 continue;
4302 }
4303 dlg.finished(false);
4304 return Err(common::Error::HttpError(err));
4305 }
4306 Ok(res) => {
4307 let (mut parts, body) = res.into_parts();
4308 let mut body = common::Body::new(body);
4309 if !parts.status.is_success() {
4310 let bytes = common::to_bytes(body).await.unwrap_or_default();
4311 let error = serde_json::from_str(&common::to_string(&bytes));
4312 let response = common::to_response(parts, bytes.into());
4313
4314 if let common::Retry::After(d) =
4315 dlg.http_failure(&response, error.as_ref().ok())
4316 {
4317 sleep(d).await;
4318 continue;
4319 }
4320
4321 dlg.finished(false);
4322
4323 return Err(match error {
4324 Ok(value) => common::Error::BadRequest(value),
4325 _ => common::Error::Failure(response),
4326 });
4327 }
4328 let response = {
4329 let bytes = common::to_bytes(body).await.unwrap_or_default();
4330 let encoded = common::to_string(&bytes);
4331 match serde_json::from_str(&encoded) {
4332 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4333 Err(error) => {
4334 dlg.response_json_decode_error(&encoded, &error);
4335 return Err(common::Error::JsonDecodeError(
4336 encoded.to_string(),
4337 error,
4338 ));
4339 }
4340 }
4341 };
4342
4343 dlg.finished(true);
4344 return Ok(response);
4345 }
4346 }
4347 }
4348 }
4349
4350 ///
4351 /// Sets the *request* property to the given value.
4352 ///
4353 /// Even though the property as already been set when instantiating this call,
4354 /// we provide this method for API completeness.
4355 pub fn request(
4356 mut self,
4357 new_value: SendCommandToDeviceRequest,
4358 ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4359 self._request = new_value;
4360 self
4361 }
4362 /// 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}`.
4363 ///
4364 /// Sets the *name* path property to the given value.
4365 ///
4366 /// Even though the property as already been set when instantiating this call,
4367 /// we provide this method for API completeness.
4368 pub fn name(
4369 mut self,
4370 new_value: &str,
4371 ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4372 self._name = new_value.to_string();
4373 self
4374 }
4375 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4376 /// while executing the actual API request.
4377 ///
4378 /// ````text
4379 /// It should be used to handle progress information, and to implement a certain level of resilience.
4380 /// ````
4381 ///
4382 /// Sets the *delegate* property to the given value.
4383 pub fn delegate(
4384 mut self,
4385 new_value: &'a mut dyn common::Delegate,
4386 ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4387 self._delegate = Some(new_value);
4388 self
4389 }
4390
4391 /// Set any additional parameter of the query string used in the request.
4392 /// It should be used to set parameters which are not yet available through their own
4393 /// setters.
4394 ///
4395 /// Please note that this method must not be used to set any of the known parameters
4396 /// which have their own setter method. If done anyway, the request will fail.
4397 ///
4398 /// # Additional Parameters
4399 ///
4400 /// * *$.xgafv* (query-string) - V1 error format.
4401 /// * *access_token* (query-string) - OAuth access token.
4402 /// * *alt* (query-string) - Data format for response.
4403 /// * *callback* (query-string) - JSONP
4404 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4405 /// * *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.
4406 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4407 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4408 /// * *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.
4409 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4410 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4411 pub fn param<T>(
4412 mut self,
4413 name: T,
4414 value: T,
4415 ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4416 where
4417 T: AsRef<str>,
4418 {
4419 self._additional_params
4420 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4421 self
4422 }
4423
4424 /// Identifies the authorization scope for the method you are building.
4425 ///
4426 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4427 /// [`Scope::CloudPlatform`].
4428 ///
4429 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4430 /// tokens for more than one scope.
4431 ///
4432 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4433 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4434 /// sufficient, a read-write scope will do as well.
4435 pub fn add_scope<St>(
4436 mut self,
4437 scope: St,
4438 ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4439 where
4440 St: AsRef<str>,
4441 {
4442 self._scopes.insert(String::from(scope.as_ref()));
4443 self
4444 }
4445 /// Identifies the authorization scope(s) for the method you are building.
4446 ///
4447 /// See [`Self::add_scope()`] for details.
4448 pub fn add_scopes<I, St>(
4449 mut self,
4450 scopes: I,
4451 ) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C>
4452 where
4453 I: IntoIterator<Item = St>,
4454 St: AsRef<str>,
4455 {
4456 self._scopes
4457 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4458 self
4459 }
4460
4461 /// Removes all scopes, and no default scope will be used either.
4462 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4463 /// for details).
4464 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeviceSendCommandToDeviceCall<'a, C> {
4465 self._scopes.clear();
4466 self
4467 }
4468}
4469
4470/// List devices in a device registry.
4471///
4472/// A builder for the *locations.registries.groups.devices.list* method supported by a *project* resource.
4473/// It is not used directly, but through a [`ProjectMethods`] instance.
4474///
4475/// # Example
4476///
4477/// Instantiate a resource method builder
4478///
4479/// ```test_harness,no_run
4480/// # extern crate hyper;
4481/// # extern crate hyper_rustls;
4482/// # extern crate google_cloudiot1 as cloudiot1;
4483/// # async fn dox() {
4484/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4485///
4486/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4487/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4488/// # secret,
4489/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4490/// # ).build().await.unwrap();
4491///
4492/// # let client = hyper_util::client::legacy::Client::builder(
4493/// # hyper_util::rt::TokioExecutor::new()
4494/// # )
4495/// # .build(
4496/// # hyper_rustls::HttpsConnectorBuilder::new()
4497/// # .with_native_roots()
4498/// # .unwrap()
4499/// # .https_or_http()
4500/// # .enable_http1()
4501/// # .build()
4502/// # );
4503/// # let mut hub = CloudIot::new(client, auth);
4504/// // You can configure optional parameters by calling the respective setters at will, and
4505/// // execute the final call using `doit()`.
4506/// // Values shown here are possibly random and not representative !
4507/// let result = hub.projects().locations_registries_groups_devices_list("parent")
4508/// .page_token("duo")
4509/// .page_size(-50)
4510/// .gateway_list_options_gateway_type("sed")
4511/// .gateway_list_options_associations_gateway_id("ut")
4512/// .gateway_list_options_associations_device_id("gubergren")
4513/// .field_mask(FieldMask::new::<&str>(&[]))
4514/// .add_device_num_ids(85)
4515/// .add_device_ids("est")
4516/// .doit().await;
4517/// # }
4518/// ```
4519pub struct ProjectLocationRegistryGroupDeviceListCall<'a, C>
4520where
4521 C: 'a,
4522{
4523 hub: &'a CloudIot<C>,
4524 _parent: String,
4525 _page_token: Option<String>,
4526 _page_size: Option<i32>,
4527 _gateway_list_options_gateway_type: Option<String>,
4528 _gateway_list_options_associations_gateway_id: Option<String>,
4529 _gateway_list_options_associations_device_id: Option<String>,
4530 _field_mask: Option<common::FieldMask>,
4531 _device_num_ids: Vec<u64>,
4532 _device_ids: Vec<String>,
4533 _delegate: Option<&'a mut dyn common::Delegate>,
4534 _additional_params: HashMap<String, String>,
4535 _scopes: BTreeSet<String>,
4536}
4537
4538impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupDeviceListCall<'a, C> {}
4539
4540impl<'a, C> ProjectLocationRegistryGroupDeviceListCall<'a, C>
4541where
4542 C: common::Connector,
4543{
4544 /// Perform the operation you have build so far.
4545 pub async fn doit(mut self) -> common::Result<(common::Response, ListDevicesResponse)> {
4546 use std::borrow::Cow;
4547 use std::io::{Read, Seek};
4548
4549 use common::{url::Params, ToParts};
4550 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4551
4552 let mut dd = common::DefaultDelegate;
4553 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4554 dlg.begin(common::MethodInfo {
4555 id: "cloudiot.projects.locations.registries.groups.devices.list",
4556 http_method: hyper::Method::GET,
4557 });
4558
4559 for &field in [
4560 "alt",
4561 "parent",
4562 "pageToken",
4563 "pageSize",
4564 "gatewayListOptions.gatewayType",
4565 "gatewayListOptions.associationsGatewayId",
4566 "gatewayListOptions.associationsDeviceId",
4567 "fieldMask",
4568 "deviceNumIds",
4569 "deviceIds",
4570 ]
4571 .iter()
4572 {
4573 if self._additional_params.contains_key(field) {
4574 dlg.finished(false);
4575 return Err(common::Error::FieldClash(field));
4576 }
4577 }
4578
4579 let mut params = Params::with_capacity(11 + self._additional_params.len());
4580 params.push("parent", self._parent);
4581 if let Some(value) = self._page_token.as_ref() {
4582 params.push("pageToken", value);
4583 }
4584 if let Some(value) = self._page_size.as_ref() {
4585 params.push("pageSize", value.to_string());
4586 }
4587 if let Some(value) = self._gateway_list_options_gateway_type.as_ref() {
4588 params.push("gatewayListOptions.gatewayType", value);
4589 }
4590 if let Some(value) = self._gateway_list_options_associations_gateway_id.as_ref() {
4591 params.push("gatewayListOptions.associationsGatewayId", value);
4592 }
4593 if let Some(value) = self._gateway_list_options_associations_device_id.as_ref() {
4594 params.push("gatewayListOptions.associationsDeviceId", value);
4595 }
4596 if let Some(value) = self._field_mask.as_ref() {
4597 params.push("fieldMask", value.to_string());
4598 }
4599 if !self._device_num_ids.is_empty() {
4600 for f in self._device_num_ids.iter() {
4601 params.push("deviceNumIds", f.to_string());
4602 }
4603 }
4604 if !self._device_ids.is_empty() {
4605 for f in self._device_ids.iter() {
4606 params.push("deviceIds", f);
4607 }
4608 }
4609
4610 params.extend(self._additional_params.iter());
4611
4612 params.push("alt", "json");
4613 let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
4614 if self._scopes.is_empty() {
4615 self._scopes
4616 .insert(Scope::CloudPlatform.as_ref().to_string());
4617 }
4618
4619 #[allow(clippy::single_element_loop)]
4620 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4621 url = params.uri_replacement(url, param_name, find_this, true);
4622 }
4623 {
4624 let to_remove = ["parent"];
4625 params.remove_params(&to_remove);
4626 }
4627
4628 let url = params.parse_with_url(&url);
4629
4630 loop {
4631 let token = match self
4632 .hub
4633 .auth
4634 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4635 .await
4636 {
4637 Ok(token) => token,
4638 Err(e) => match dlg.token(e) {
4639 Ok(token) => token,
4640 Err(e) => {
4641 dlg.finished(false);
4642 return Err(common::Error::MissingToken(e));
4643 }
4644 },
4645 };
4646 let mut req_result = {
4647 let client = &self.hub.client;
4648 dlg.pre_request();
4649 let mut req_builder = hyper::Request::builder()
4650 .method(hyper::Method::GET)
4651 .uri(url.as_str())
4652 .header(USER_AGENT, self.hub._user_agent.clone());
4653
4654 if let Some(token) = token.as_ref() {
4655 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4656 }
4657
4658 let request = req_builder
4659 .header(CONTENT_LENGTH, 0_u64)
4660 .body(common::to_body::<String>(None));
4661
4662 client.request(request.unwrap()).await
4663 };
4664
4665 match req_result {
4666 Err(err) => {
4667 if let common::Retry::After(d) = dlg.http_error(&err) {
4668 sleep(d).await;
4669 continue;
4670 }
4671 dlg.finished(false);
4672 return Err(common::Error::HttpError(err));
4673 }
4674 Ok(res) => {
4675 let (mut parts, body) = res.into_parts();
4676 let mut body = common::Body::new(body);
4677 if !parts.status.is_success() {
4678 let bytes = common::to_bytes(body).await.unwrap_or_default();
4679 let error = serde_json::from_str(&common::to_string(&bytes));
4680 let response = common::to_response(parts, bytes.into());
4681
4682 if let common::Retry::After(d) =
4683 dlg.http_failure(&response, error.as_ref().ok())
4684 {
4685 sleep(d).await;
4686 continue;
4687 }
4688
4689 dlg.finished(false);
4690
4691 return Err(match error {
4692 Ok(value) => common::Error::BadRequest(value),
4693 _ => common::Error::Failure(response),
4694 });
4695 }
4696 let response = {
4697 let bytes = common::to_bytes(body).await.unwrap_or_default();
4698 let encoded = common::to_string(&bytes);
4699 match serde_json::from_str(&encoded) {
4700 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4701 Err(error) => {
4702 dlg.response_json_decode_error(&encoded, &error);
4703 return Err(common::Error::JsonDecodeError(
4704 encoded.to_string(),
4705 error,
4706 ));
4707 }
4708 }
4709 };
4710
4711 dlg.finished(true);
4712 return Ok(response);
4713 }
4714 }
4715 }
4716 }
4717
4718 /// Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.
4719 ///
4720 /// Sets the *parent* path property to the given value.
4721 ///
4722 /// Even though the property as already been set when instantiating this call,
4723 /// we provide this method for API completeness.
4724 pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4725 self._parent = new_value.to_string();
4726 self
4727 }
4728 /// 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.
4729 ///
4730 /// Sets the *page token* query property to the given value.
4731 pub fn page_token(
4732 mut self,
4733 new_value: &str,
4734 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4735 self._page_token = Some(new_value.to_string());
4736 self
4737 }
4738 /// 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.
4739 ///
4740 /// Sets the *page size* query property to the given value.
4741 pub fn page_size(
4742 mut self,
4743 new_value: i32,
4744 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4745 self._page_size = Some(new_value);
4746 self
4747 }
4748 /// 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.
4749 ///
4750 /// Sets the *gateway list options.gateway type* query property to the given value.
4751 pub fn gateway_list_options_gateway_type(
4752 mut self,
4753 new_value: &str,
4754 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4755 self._gateway_list_options_gateway_type = Some(new_value.to_string());
4756 self
4757 }
4758 /// 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.
4759 ///
4760 /// Sets the *gateway list options.associations gateway id* query property to the given value.
4761 pub fn gateway_list_options_associations_gateway_id(
4762 mut self,
4763 new_value: &str,
4764 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4765 self._gateway_list_options_associations_gateway_id = Some(new_value.to_string());
4766 self
4767 }
4768 /// 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.
4769 ///
4770 /// Sets the *gateway list options.associations device id* query property to the given value.
4771 pub fn gateway_list_options_associations_device_id(
4772 mut self,
4773 new_value: &str,
4774 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4775 self._gateway_list_options_associations_device_id = Some(new_value.to_string());
4776 self
4777 }
4778 /// 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`.
4779 ///
4780 /// Sets the *field mask* query property to the given value.
4781 pub fn field_mask(
4782 mut self,
4783 new_value: common::FieldMask,
4784 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4785 self._field_mask = Some(new_value);
4786 self
4787 }
4788 /// A list of device numeric IDs. If empty, this field is ignored. Maximum IDs: 10,000.
4789 ///
4790 /// Append the given value to the *device num ids* query property.
4791 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4792 pub fn add_device_num_ids(
4793 mut self,
4794 new_value: u64,
4795 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4796 self._device_num_ids.push(new_value);
4797 self
4798 }
4799 /// A list of device string IDs. For example, `['device0', 'device12']`. If empty, this field is ignored. Maximum IDs: 10,000
4800 ///
4801 /// Append the given value to the *device ids* query property.
4802 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4803 pub fn add_device_ids(
4804 mut self,
4805 new_value: &str,
4806 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4807 self._device_ids.push(new_value.to_string());
4808 self
4809 }
4810 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4811 /// while executing the actual API request.
4812 ///
4813 /// ````text
4814 /// It should be used to handle progress information, and to implement a certain level of resilience.
4815 /// ````
4816 ///
4817 /// Sets the *delegate* property to the given value.
4818 pub fn delegate(
4819 mut self,
4820 new_value: &'a mut dyn common::Delegate,
4821 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4822 self._delegate = Some(new_value);
4823 self
4824 }
4825
4826 /// Set any additional parameter of the query string used in the request.
4827 /// It should be used to set parameters which are not yet available through their own
4828 /// setters.
4829 ///
4830 /// Please note that this method must not be used to set any of the known parameters
4831 /// which have their own setter method. If done anyway, the request will fail.
4832 ///
4833 /// # Additional Parameters
4834 ///
4835 /// * *$.xgafv* (query-string) - V1 error format.
4836 /// * *access_token* (query-string) - OAuth access token.
4837 /// * *alt* (query-string) - Data format for response.
4838 /// * *callback* (query-string) - JSONP
4839 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4840 /// * *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.
4841 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4842 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4843 /// * *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.
4844 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4845 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4846 pub fn param<T>(
4847 mut self,
4848 name: T,
4849 value: T,
4850 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C>
4851 where
4852 T: AsRef<str>,
4853 {
4854 self._additional_params
4855 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4856 self
4857 }
4858
4859 /// Identifies the authorization scope for the method you are building.
4860 ///
4861 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4862 /// [`Scope::CloudPlatform`].
4863 ///
4864 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4865 /// tokens for more than one scope.
4866 ///
4867 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4868 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4869 /// sufficient, a read-write scope will do as well.
4870 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGroupDeviceListCall<'a, C>
4871 where
4872 St: AsRef<str>,
4873 {
4874 self._scopes.insert(String::from(scope.as_ref()));
4875 self
4876 }
4877 /// Identifies the authorization scope(s) for the method you are building.
4878 ///
4879 /// See [`Self::add_scope()`] for details.
4880 pub fn add_scopes<I, St>(
4881 mut self,
4882 scopes: I,
4883 ) -> ProjectLocationRegistryGroupDeviceListCall<'a, C>
4884 where
4885 I: IntoIterator<Item = St>,
4886 St: AsRef<str>,
4887 {
4888 self._scopes
4889 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4890 self
4891 }
4892
4893 /// Removes all scopes, and no default scope will be used either.
4894 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4895 /// for details).
4896 pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupDeviceListCall<'a, C> {
4897 self._scopes.clear();
4898 self
4899 }
4900}
4901
4902/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
4903///
4904/// A builder for the *locations.registries.groups.getIamPolicy* method supported by a *project* resource.
4905/// It is not used directly, but through a [`ProjectMethods`] instance.
4906///
4907/// # Example
4908///
4909/// Instantiate a resource method builder
4910///
4911/// ```test_harness,no_run
4912/// # extern crate hyper;
4913/// # extern crate hyper_rustls;
4914/// # extern crate google_cloudiot1 as cloudiot1;
4915/// use cloudiot1::api::GetIamPolicyRequest;
4916/// # async fn dox() {
4917/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4918///
4919/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4920/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4921/// # secret,
4922/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4923/// # ).build().await.unwrap();
4924///
4925/// # let client = hyper_util::client::legacy::Client::builder(
4926/// # hyper_util::rt::TokioExecutor::new()
4927/// # )
4928/// # .build(
4929/// # hyper_rustls::HttpsConnectorBuilder::new()
4930/// # .with_native_roots()
4931/// # .unwrap()
4932/// # .https_or_http()
4933/// # .enable_http1()
4934/// # .build()
4935/// # );
4936/// # let mut hub = CloudIot::new(client, auth);
4937/// // As the method needs a request, you would usually fill it with the desired information
4938/// // into the respective structure. Some of the parts shown here might not be applicable !
4939/// // Values shown here are possibly random and not representative !
4940/// let mut req = GetIamPolicyRequest::default();
4941///
4942/// // You can configure optional parameters by calling the respective setters at will, and
4943/// // execute the final call using `doit()`.
4944/// // Values shown here are possibly random and not representative !
4945/// let result = hub.projects().locations_registries_groups_get_iam_policy(req, "resource")
4946/// .doit().await;
4947/// # }
4948/// ```
4949pub struct ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
4950where
4951 C: 'a,
4952{
4953 hub: &'a CloudIot<C>,
4954 _request: GetIamPolicyRequest,
4955 _resource: String,
4956 _delegate: Option<&'a mut dyn common::Delegate>,
4957 _additional_params: HashMap<String, String>,
4958 _scopes: BTreeSet<String>,
4959}
4960
4961impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {}
4962
4963impl<'a, C> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
4964where
4965 C: common::Connector,
4966{
4967 /// Perform the operation you have build so far.
4968 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4969 use std::borrow::Cow;
4970 use std::io::{Read, Seek};
4971
4972 use common::{url::Params, ToParts};
4973 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4974
4975 let mut dd = common::DefaultDelegate;
4976 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4977 dlg.begin(common::MethodInfo {
4978 id: "cloudiot.projects.locations.registries.groups.getIamPolicy",
4979 http_method: hyper::Method::POST,
4980 });
4981
4982 for &field in ["alt", "resource"].iter() {
4983 if self._additional_params.contains_key(field) {
4984 dlg.finished(false);
4985 return Err(common::Error::FieldClash(field));
4986 }
4987 }
4988
4989 let mut params = Params::with_capacity(4 + self._additional_params.len());
4990 params.push("resource", self._resource);
4991
4992 params.extend(self._additional_params.iter());
4993
4994 params.push("alt", "json");
4995 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
4996 if self._scopes.is_empty() {
4997 self._scopes
4998 .insert(Scope::CloudPlatform.as_ref().to_string());
4999 }
5000
5001 #[allow(clippy::single_element_loop)]
5002 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5003 url = params.uri_replacement(url, param_name, find_this, true);
5004 }
5005 {
5006 let to_remove = ["resource"];
5007 params.remove_params(&to_remove);
5008 }
5009
5010 let url = params.parse_with_url(&url);
5011
5012 let mut json_mime_type = mime::APPLICATION_JSON;
5013 let mut request_value_reader = {
5014 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5015 common::remove_json_null_values(&mut value);
5016 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5017 serde_json::to_writer(&mut dst, &value).unwrap();
5018 dst
5019 };
5020 let request_size = request_value_reader
5021 .seek(std::io::SeekFrom::End(0))
5022 .unwrap();
5023 request_value_reader
5024 .seek(std::io::SeekFrom::Start(0))
5025 .unwrap();
5026
5027 loop {
5028 let token = match self
5029 .hub
5030 .auth
5031 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5032 .await
5033 {
5034 Ok(token) => token,
5035 Err(e) => match dlg.token(e) {
5036 Ok(token) => token,
5037 Err(e) => {
5038 dlg.finished(false);
5039 return Err(common::Error::MissingToken(e));
5040 }
5041 },
5042 };
5043 request_value_reader
5044 .seek(std::io::SeekFrom::Start(0))
5045 .unwrap();
5046 let mut req_result = {
5047 let client = &self.hub.client;
5048 dlg.pre_request();
5049 let mut req_builder = hyper::Request::builder()
5050 .method(hyper::Method::POST)
5051 .uri(url.as_str())
5052 .header(USER_AGENT, self.hub._user_agent.clone());
5053
5054 if let Some(token) = token.as_ref() {
5055 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5056 }
5057
5058 let request = req_builder
5059 .header(CONTENT_TYPE, json_mime_type.to_string())
5060 .header(CONTENT_LENGTH, request_size as u64)
5061 .body(common::to_body(
5062 request_value_reader.get_ref().clone().into(),
5063 ));
5064
5065 client.request(request.unwrap()).await
5066 };
5067
5068 match req_result {
5069 Err(err) => {
5070 if let common::Retry::After(d) = dlg.http_error(&err) {
5071 sleep(d).await;
5072 continue;
5073 }
5074 dlg.finished(false);
5075 return Err(common::Error::HttpError(err));
5076 }
5077 Ok(res) => {
5078 let (mut parts, body) = res.into_parts();
5079 let mut body = common::Body::new(body);
5080 if !parts.status.is_success() {
5081 let bytes = common::to_bytes(body).await.unwrap_or_default();
5082 let error = serde_json::from_str(&common::to_string(&bytes));
5083 let response = common::to_response(parts, bytes.into());
5084
5085 if let common::Retry::After(d) =
5086 dlg.http_failure(&response, error.as_ref().ok())
5087 {
5088 sleep(d).await;
5089 continue;
5090 }
5091
5092 dlg.finished(false);
5093
5094 return Err(match error {
5095 Ok(value) => common::Error::BadRequest(value),
5096 _ => common::Error::Failure(response),
5097 });
5098 }
5099 let response = {
5100 let bytes = common::to_bytes(body).await.unwrap_or_default();
5101 let encoded = common::to_string(&bytes);
5102 match serde_json::from_str(&encoded) {
5103 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5104 Err(error) => {
5105 dlg.response_json_decode_error(&encoded, &error);
5106 return Err(common::Error::JsonDecodeError(
5107 encoded.to_string(),
5108 error,
5109 ));
5110 }
5111 }
5112 };
5113
5114 dlg.finished(true);
5115 return Ok(response);
5116 }
5117 }
5118 }
5119 }
5120
5121 ///
5122 /// Sets the *request* property to the given value.
5123 ///
5124 /// Even though the property as already been set when instantiating this call,
5125 /// we provide this method for API completeness.
5126 pub fn request(
5127 mut self,
5128 new_value: GetIamPolicyRequest,
5129 ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5130 self._request = new_value;
5131 self
5132 }
5133 /// 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.
5134 ///
5135 /// Sets the *resource* path property to the given value.
5136 ///
5137 /// Even though the property as already been set when instantiating this call,
5138 /// we provide this method for API completeness.
5139 pub fn resource(
5140 mut self,
5141 new_value: &str,
5142 ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5143 self._resource = new_value.to_string();
5144 self
5145 }
5146 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5147 /// while executing the actual API request.
5148 ///
5149 /// ````text
5150 /// It should be used to handle progress information, and to implement a certain level of resilience.
5151 /// ````
5152 ///
5153 /// Sets the *delegate* property to the given value.
5154 pub fn delegate(
5155 mut self,
5156 new_value: &'a mut dyn common::Delegate,
5157 ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5158 self._delegate = Some(new_value);
5159 self
5160 }
5161
5162 /// Set any additional parameter of the query string used in the request.
5163 /// It should be used to set parameters which are not yet available through their own
5164 /// setters.
5165 ///
5166 /// Please note that this method must not be used to set any of the known parameters
5167 /// which have their own setter method. If done anyway, the request will fail.
5168 ///
5169 /// # Additional Parameters
5170 ///
5171 /// * *$.xgafv* (query-string) - V1 error format.
5172 /// * *access_token* (query-string) - OAuth access token.
5173 /// * *alt* (query-string) - Data format for response.
5174 /// * *callback* (query-string) - JSONP
5175 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5176 /// * *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.
5177 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5178 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5179 /// * *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.
5180 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5181 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5182 pub fn param<T>(
5183 mut self,
5184 name: T,
5185 value: T,
5186 ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5187 where
5188 T: AsRef<str>,
5189 {
5190 self._additional_params
5191 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5192 self
5193 }
5194
5195 /// Identifies the authorization scope for the method you are building.
5196 ///
5197 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5198 /// [`Scope::CloudPlatform`].
5199 ///
5200 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5201 /// tokens for more than one scope.
5202 ///
5203 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5204 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5205 /// sufficient, a read-write scope will do as well.
5206 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5207 where
5208 St: AsRef<str>,
5209 {
5210 self._scopes.insert(String::from(scope.as_ref()));
5211 self
5212 }
5213 /// Identifies the authorization scope(s) for the method you are building.
5214 ///
5215 /// See [`Self::add_scope()`] for details.
5216 pub fn add_scopes<I, St>(
5217 mut self,
5218 scopes: I,
5219 ) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C>
5220 where
5221 I: IntoIterator<Item = St>,
5222 St: AsRef<str>,
5223 {
5224 self._scopes
5225 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5226 self
5227 }
5228
5229 /// Removes all scopes, and no default scope will be used either.
5230 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5231 /// for details).
5232 pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupGetIamPolicyCall<'a, C> {
5233 self._scopes.clear();
5234 self
5235 }
5236}
5237
5238/// Sets the access control policy on the specified resource. Replaces any existing policy.
5239///
5240/// A builder for the *locations.registries.groups.setIamPolicy* method supported by a *project* resource.
5241/// It is not used directly, but through a [`ProjectMethods`] instance.
5242///
5243/// # Example
5244///
5245/// Instantiate a resource method builder
5246///
5247/// ```test_harness,no_run
5248/// # extern crate hyper;
5249/// # extern crate hyper_rustls;
5250/// # extern crate google_cloudiot1 as cloudiot1;
5251/// use cloudiot1::api::SetIamPolicyRequest;
5252/// # async fn dox() {
5253/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5254///
5255/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5256/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5257/// # secret,
5258/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5259/// # ).build().await.unwrap();
5260///
5261/// # let client = hyper_util::client::legacy::Client::builder(
5262/// # hyper_util::rt::TokioExecutor::new()
5263/// # )
5264/// # .build(
5265/// # hyper_rustls::HttpsConnectorBuilder::new()
5266/// # .with_native_roots()
5267/// # .unwrap()
5268/// # .https_or_http()
5269/// # .enable_http1()
5270/// # .build()
5271/// # );
5272/// # let mut hub = CloudIot::new(client, auth);
5273/// // As the method needs a request, you would usually fill it with the desired information
5274/// // into the respective structure. Some of the parts shown here might not be applicable !
5275/// // Values shown here are possibly random and not representative !
5276/// let mut req = SetIamPolicyRequest::default();
5277///
5278/// // You can configure optional parameters by calling the respective setters at will, and
5279/// // execute the final call using `doit()`.
5280/// // Values shown here are possibly random and not representative !
5281/// let result = hub.projects().locations_registries_groups_set_iam_policy(req, "resource")
5282/// .doit().await;
5283/// # }
5284/// ```
5285pub struct ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5286where
5287 C: 'a,
5288{
5289 hub: &'a CloudIot<C>,
5290 _request: SetIamPolicyRequest,
5291 _resource: String,
5292 _delegate: Option<&'a mut dyn common::Delegate>,
5293 _additional_params: HashMap<String, String>,
5294 _scopes: BTreeSet<String>,
5295}
5296
5297impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {}
5298
5299impl<'a, C> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5300where
5301 C: common::Connector,
5302{
5303 /// Perform the operation you have build so far.
5304 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5305 use std::borrow::Cow;
5306 use std::io::{Read, Seek};
5307
5308 use common::{url::Params, ToParts};
5309 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5310
5311 let mut dd = common::DefaultDelegate;
5312 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5313 dlg.begin(common::MethodInfo {
5314 id: "cloudiot.projects.locations.registries.groups.setIamPolicy",
5315 http_method: hyper::Method::POST,
5316 });
5317
5318 for &field in ["alt", "resource"].iter() {
5319 if self._additional_params.contains_key(field) {
5320 dlg.finished(false);
5321 return Err(common::Error::FieldClash(field));
5322 }
5323 }
5324
5325 let mut params = Params::with_capacity(4 + self._additional_params.len());
5326 params.push("resource", self._resource);
5327
5328 params.extend(self._additional_params.iter());
5329
5330 params.push("alt", "json");
5331 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
5332 if self._scopes.is_empty() {
5333 self._scopes
5334 .insert(Scope::CloudPlatform.as_ref().to_string());
5335 }
5336
5337 #[allow(clippy::single_element_loop)]
5338 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5339 url = params.uri_replacement(url, param_name, find_this, true);
5340 }
5341 {
5342 let to_remove = ["resource"];
5343 params.remove_params(&to_remove);
5344 }
5345
5346 let url = params.parse_with_url(&url);
5347
5348 let mut json_mime_type = mime::APPLICATION_JSON;
5349 let mut request_value_reader = {
5350 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5351 common::remove_json_null_values(&mut value);
5352 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5353 serde_json::to_writer(&mut dst, &value).unwrap();
5354 dst
5355 };
5356 let request_size = request_value_reader
5357 .seek(std::io::SeekFrom::End(0))
5358 .unwrap();
5359 request_value_reader
5360 .seek(std::io::SeekFrom::Start(0))
5361 .unwrap();
5362
5363 loop {
5364 let token = match self
5365 .hub
5366 .auth
5367 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5368 .await
5369 {
5370 Ok(token) => token,
5371 Err(e) => match dlg.token(e) {
5372 Ok(token) => token,
5373 Err(e) => {
5374 dlg.finished(false);
5375 return Err(common::Error::MissingToken(e));
5376 }
5377 },
5378 };
5379 request_value_reader
5380 .seek(std::io::SeekFrom::Start(0))
5381 .unwrap();
5382 let mut req_result = {
5383 let client = &self.hub.client;
5384 dlg.pre_request();
5385 let mut req_builder = hyper::Request::builder()
5386 .method(hyper::Method::POST)
5387 .uri(url.as_str())
5388 .header(USER_AGENT, self.hub._user_agent.clone());
5389
5390 if let Some(token) = token.as_ref() {
5391 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5392 }
5393
5394 let request = req_builder
5395 .header(CONTENT_TYPE, json_mime_type.to_string())
5396 .header(CONTENT_LENGTH, request_size as u64)
5397 .body(common::to_body(
5398 request_value_reader.get_ref().clone().into(),
5399 ));
5400
5401 client.request(request.unwrap()).await
5402 };
5403
5404 match req_result {
5405 Err(err) => {
5406 if let common::Retry::After(d) = dlg.http_error(&err) {
5407 sleep(d).await;
5408 continue;
5409 }
5410 dlg.finished(false);
5411 return Err(common::Error::HttpError(err));
5412 }
5413 Ok(res) => {
5414 let (mut parts, body) = res.into_parts();
5415 let mut body = common::Body::new(body);
5416 if !parts.status.is_success() {
5417 let bytes = common::to_bytes(body).await.unwrap_or_default();
5418 let error = serde_json::from_str(&common::to_string(&bytes));
5419 let response = common::to_response(parts, bytes.into());
5420
5421 if let common::Retry::After(d) =
5422 dlg.http_failure(&response, error.as_ref().ok())
5423 {
5424 sleep(d).await;
5425 continue;
5426 }
5427
5428 dlg.finished(false);
5429
5430 return Err(match error {
5431 Ok(value) => common::Error::BadRequest(value),
5432 _ => common::Error::Failure(response),
5433 });
5434 }
5435 let response = {
5436 let bytes = common::to_bytes(body).await.unwrap_or_default();
5437 let encoded = common::to_string(&bytes);
5438 match serde_json::from_str(&encoded) {
5439 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5440 Err(error) => {
5441 dlg.response_json_decode_error(&encoded, &error);
5442 return Err(common::Error::JsonDecodeError(
5443 encoded.to_string(),
5444 error,
5445 ));
5446 }
5447 }
5448 };
5449
5450 dlg.finished(true);
5451 return Ok(response);
5452 }
5453 }
5454 }
5455 }
5456
5457 ///
5458 /// Sets the *request* property to the given value.
5459 ///
5460 /// Even though the property as already been set when instantiating this call,
5461 /// we provide this method for API completeness.
5462 pub fn request(
5463 mut self,
5464 new_value: SetIamPolicyRequest,
5465 ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5466 self._request = new_value;
5467 self
5468 }
5469 /// 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.
5470 ///
5471 /// Sets the *resource* path property to the given value.
5472 ///
5473 /// Even though the property as already been set when instantiating this call,
5474 /// we provide this method for API completeness.
5475 pub fn resource(
5476 mut self,
5477 new_value: &str,
5478 ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5479 self._resource = new_value.to_string();
5480 self
5481 }
5482 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5483 /// while executing the actual API request.
5484 ///
5485 /// ````text
5486 /// It should be used to handle progress information, and to implement a certain level of resilience.
5487 /// ````
5488 ///
5489 /// Sets the *delegate* property to the given value.
5490 pub fn delegate(
5491 mut self,
5492 new_value: &'a mut dyn common::Delegate,
5493 ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5494 self._delegate = Some(new_value);
5495 self
5496 }
5497
5498 /// Set any additional parameter of the query string used in the request.
5499 /// It should be used to set parameters which are not yet available through their own
5500 /// setters.
5501 ///
5502 /// Please note that this method must not be used to set any of the known parameters
5503 /// which have their own setter method. If done anyway, the request will fail.
5504 ///
5505 /// # Additional Parameters
5506 ///
5507 /// * *$.xgafv* (query-string) - V1 error format.
5508 /// * *access_token* (query-string) - OAuth access token.
5509 /// * *alt* (query-string) - Data format for response.
5510 /// * *callback* (query-string) - JSONP
5511 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5512 /// * *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.
5513 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5514 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5515 /// * *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.
5516 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5517 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5518 pub fn param<T>(
5519 mut self,
5520 name: T,
5521 value: T,
5522 ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5523 where
5524 T: AsRef<str>,
5525 {
5526 self._additional_params
5527 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5528 self
5529 }
5530
5531 /// Identifies the authorization scope for the method you are building.
5532 ///
5533 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5534 /// [`Scope::CloudPlatform`].
5535 ///
5536 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5537 /// tokens for more than one scope.
5538 ///
5539 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5540 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5541 /// sufficient, a read-write scope will do as well.
5542 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5543 where
5544 St: AsRef<str>,
5545 {
5546 self._scopes.insert(String::from(scope.as_ref()));
5547 self
5548 }
5549 /// Identifies the authorization scope(s) for the method you are building.
5550 ///
5551 /// See [`Self::add_scope()`] for details.
5552 pub fn add_scopes<I, St>(
5553 mut self,
5554 scopes: I,
5555 ) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C>
5556 where
5557 I: IntoIterator<Item = St>,
5558 St: AsRef<str>,
5559 {
5560 self._scopes
5561 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5562 self
5563 }
5564
5565 /// Removes all scopes, and no default scope will be used either.
5566 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5567 /// for details).
5568 pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupSetIamPolicyCall<'a, C> {
5569 self._scopes.clear();
5570 self
5571 }
5572}
5573
5574/// 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.
5575///
5576/// A builder for the *locations.registries.groups.testIamPermissions* method supported by a *project* resource.
5577/// It is not used directly, but through a [`ProjectMethods`] instance.
5578///
5579/// # Example
5580///
5581/// Instantiate a resource method builder
5582///
5583/// ```test_harness,no_run
5584/// # extern crate hyper;
5585/// # extern crate hyper_rustls;
5586/// # extern crate google_cloudiot1 as cloudiot1;
5587/// use cloudiot1::api::TestIamPermissionsRequest;
5588/// # async fn dox() {
5589/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5590///
5591/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5592/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5593/// # secret,
5594/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5595/// # ).build().await.unwrap();
5596///
5597/// # let client = hyper_util::client::legacy::Client::builder(
5598/// # hyper_util::rt::TokioExecutor::new()
5599/// # )
5600/// # .build(
5601/// # hyper_rustls::HttpsConnectorBuilder::new()
5602/// # .with_native_roots()
5603/// # .unwrap()
5604/// # .https_or_http()
5605/// # .enable_http1()
5606/// # .build()
5607/// # );
5608/// # let mut hub = CloudIot::new(client, auth);
5609/// // As the method needs a request, you would usually fill it with the desired information
5610/// // into the respective structure. Some of the parts shown here might not be applicable !
5611/// // Values shown here are possibly random and not representative !
5612/// let mut req = TestIamPermissionsRequest::default();
5613///
5614/// // You can configure optional parameters by calling the respective setters at will, and
5615/// // execute the final call using `doit()`.
5616/// // Values shown here are possibly random and not representative !
5617/// let result = hub.projects().locations_registries_groups_test_iam_permissions(req, "resource")
5618/// .doit().await;
5619/// # }
5620/// ```
5621pub struct ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
5622where
5623 C: 'a,
5624{
5625 hub: &'a CloudIot<C>,
5626 _request: TestIamPermissionsRequest,
5627 _resource: String,
5628 _delegate: Option<&'a mut dyn common::Delegate>,
5629 _additional_params: HashMap<String, String>,
5630 _scopes: BTreeSet<String>,
5631}
5632
5633impl<'a, C> common::CallBuilder for ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {}
5634
5635impl<'a, C> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
5636where
5637 C: common::Connector,
5638{
5639 /// Perform the operation you have build so far.
5640 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
5641 use std::borrow::Cow;
5642 use std::io::{Read, Seek};
5643
5644 use common::{url::Params, ToParts};
5645 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5646
5647 let mut dd = common::DefaultDelegate;
5648 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5649 dlg.begin(common::MethodInfo {
5650 id: "cloudiot.projects.locations.registries.groups.testIamPermissions",
5651 http_method: hyper::Method::POST,
5652 });
5653
5654 for &field in ["alt", "resource"].iter() {
5655 if self._additional_params.contains_key(field) {
5656 dlg.finished(false);
5657 return Err(common::Error::FieldClash(field));
5658 }
5659 }
5660
5661 let mut params = Params::with_capacity(4 + self._additional_params.len());
5662 params.push("resource", self._resource);
5663
5664 params.extend(self._additional_params.iter());
5665
5666 params.push("alt", "json");
5667 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
5668 if self._scopes.is_empty() {
5669 self._scopes
5670 .insert(Scope::CloudPlatform.as_ref().to_string());
5671 }
5672
5673 #[allow(clippy::single_element_loop)]
5674 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5675 url = params.uri_replacement(url, param_name, find_this, true);
5676 }
5677 {
5678 let to_remove = ["resource"];
5679 params.remove_params(&to_remove);
5680 }
5681
5682 let url = params.parse_with_url(&url);
5683
5684 let mut json_mime_type = mime::APPLICATION_JSON;
5685 let mut request_value_reader = {
5686 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5687 common::remove_json_null_values(&mut value);
5688 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5689 serde_json::to_writer(&mut dst, &value).unwrap();
5690 dst
5691 };
5692 let request_size = request_value_reader
5693 .seek(std::io::SeekFrom::End(0))
5694 .unwrap();
5695 request_value_reader
5696 .seek(std::io::SeekFrom::Start(0))
5697 .unwrap();
5698
5699 loop {
5700 let token = match self
5701 .hub
5702 .auth
5703 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5704 .await
5705 {
5706 Ok(token) => token,
5707 Err(e) => match dlg.token(e) {
5708 Ok(token) => token,
5709 Err(e) => {
5710 dlg.finished(false);
5711 return Err(common::Error::MissingToken(e));
5712 }
5713 },
5714 };
5715 request_value_reader
5716 .seek(std::io::SeekFrom::Start(0))
5717 .unwrap();
5718 let mut req_result = {
5719 let client = &self.hub.client;
5720 dlg.pre_request();
5721 let mut req_builder = hyper::Request::builder()
5722 .method(hyper::Method::POST)
5723 .uri(url.as_str())
5724 .header(USER_AGENT, self.hub._user_agent.clone());
5725
5726 if let Some(token) = token.as_ref() {
5727 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5728 }
5729
5730 let request = req_builder
5731 .header(CONTENT_TYPE, json_mime_type.to_string())
5732 .header(CONTENT_LENGTH, request_size as u64)
5733 .body(common::to_body(
5734 request_value_reader.get_ref().clone().into(),
5735 ));
5736
5737 client.request(request.unwrap()).await
5738 };
5739
5740 match req_result {
5741 Err(err) => {
5742 if let common::Retry::After(d) = dlg.http_error(&err) {
5743 sleep(d).await;
5744 continue;
5745 }
5746 dlg.finished(false);
5747 return Err(common::Error::HttpError(err));
5748 }
5749 Ok(res) => {
5750 let (mut parts, body) = res.into_parts();
5751 let mut body = common::Body::new(body);
5752 if !parts.status.is_success() {
5753 let bytes = common::to_bytes(body).await.unwrap_or_default();
5754 let error = serde_json::from_str(&common::to_string(&bytes));
5755 let response = common::to_response(parts, bytes.into());
5756
5757 if let common::Retry::After(d) =
5758 dlg.http_failure(&response, error.as_ref().ok())
5759 {
5760 sleep(d).await;
5761 continue;
5762 }
5763
5764 dlg.finished(false);
5765
5766 return Err(match error {
5767 Ok(value) => common::Error::BadRequest(value),
5768 _ => common::Error::Failure(response),
5769 });
5770 }
5771 let response = {
5772 let bytes = common::to_bytes(body).await.unwrap_or_default();
5773 let encoded = common::to_string(&bytes);
5774 match serde_json::from_str(&encoded) {
5775 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5776 Err(error) => {
5777 dlg.response_json_decode_error(&encoded, &error);
5778 return Err(common::Error::JsonDecodeError(
5779 encoded.to_string(),
5780 error,
5781 ));
5782 }
5783 }
5784 };
5785
5786 dlg.finished(true);
5787 return Ok(response);
5788 }
5789 }
5790 }
5791 }
5792
5793 ///
5794 /// Sets the *request* property to the given value.
5795 ///
5796 /// Even though the property as already been set when instantiating this call,
5797 /// we provide this method for API completeness.
5798 pub fn request(
5799 mut self,
5800 new_value: TestIamPermissionsRequest,
5801 ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
5802 self._request = new_value;
5803 self
5804 }
5805 /// 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.
5806 ///
5807 /// Sets the *resource* path property to the given value.
5808 ///
5809 /// Even though the property as already been set when instantiating this call,
5810 /// we provide this method for API completeness.
5811 pub fn resource(
5812 mut self,
5813 new_value: &str,
5814 ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
5815 self._resource = new_value.to_string();
5816 self
5817 }
5818 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5819 /// while executing the actual API request.
5820 ///
5821 /// ````text
5822 /// It should be used to handle progress information, and to implement a certain level of resilience.
5823 /// ````
5824 ///
5825 /// Sets the *delegate* property to the given value.
5826 pub fn delegate(
5827 mut self,
5828 new_value: &'a mut dyn common::Delegate,
5829 ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
5830 self._delegate = Some(new_value);
5831 self
5832 }
5833
5834 /// Set any additional parameter of the query string used in the request.
5835 /// It should be used to set parameters which are not yet available through their own
5836 /// setters.
5837 ///
5838 /// Please note that this method must not be used to set any of the known parameters
5839 /// which have their own setter method. If done anyway, the request will fail.
5840 ///
5841 /// # Additional Parameters
5842 ///
5843 /// * *$.xgafv* (query-string) - V1 error format.
5844 /// * *access_token* (query-string) - OAuth access token.
5845 /// * *alt* (query-string) - Data format for response.
5846 /// * *callback* (query-string) - JSONP
5847 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5848 /// * *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.
5849 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5850 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5851 /// * *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.
5852 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5853 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5854 pub fn param<T>(
5855 mut self,
5856 name: T,
5857 value: T,
5858 ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
5859 where
5860 T: AsRef<str>,
5861 {
5862 self._additional_params
5863 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5864 self
5865 }
5866
5867 /// Identifies the authorization scope for the method you are building.
5868 ///
5869 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5870 /// [`Scope::CloudPlatform`].
5871 ///
5872 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5873 /// tokens for more than one scope.
5874 ///
5875 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5876 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5877 /// sufficient, a read-write scope will do as well.
5878 pub fn add_scope<St>(
5879 mut self,
5880 scope: St,
5881 ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
5882 where
5883 St: AsRef<str>,
5884 {
5885 self._scopes.insert(String::from(scope.as_ref()));
5886 self
5887 }
5888 /// Identifies the authorization scope(s) for the method you are building.
5889 ///
5890 /// See [`Self::add_scope()`] for details.
5891 pub fn add_scopes<I, St>(
5892 mut self,
5893 scopes: I,
5894 ) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C>
5895 where
5896 I: IntoIterator<Item = St>,
5897 St: AsRef<str>,
5898 {
5899 self._scopes
5900 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5901 self
5902 }
5903
5904 /// Removes all scopes, and no default scope will be used either.
5905 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5906 /// for details).
5907 pub fn clear_scopes(mut self) -> ProjectLocationRegistryGroupTestIamPermissionCall<'a, C> {
5908 self._scopes.clear();
5909 self
5910 }
5911}
5912
5913/// Associates the device with the gateway.
5914///
5915/// A builder for the *locations.registries.bindDeviceToGateway* method supported by a *project* resource.
5916/// It is not used directly, but through a [`ProjectMethods`] instance.
5917///
5918/// # Example
5919///
5920/// Instantiate a resource method builder
5921///
5922/// ```test_harness,no_run
5923/// # extern crate hyper;
5924/// # extern crate hyper_rustls;
5925/// # extern crate google_cloudiot1 as cloudiot1;
5926/// use cloudiot1::api::BindDeviceToGatewayRequest;
5927/// # async fn dox() {
5928/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5929///
5930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5932/// # secret,
5933/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5934/// # ).build().await.unwrap();
5935///
5936/// # let client = hyper_util::client::legacy::Client::builder(
5937/// # hyper_util::rt::TokioExecutor::new()
5938/// # )
5939/// # .build(
5940/// # hyper_rustls::HttpsConnectorBuilder::new()
5941/// # .with_native_roots()
5942/// # .unwrap()
5943/// # .https_or_http()
5944/// # .enable_http1()
5945/// # .build()
5946/// # );
5947/// # let mut hub = CloudIot::new(client, auth);
5948/// // As the method needs a request, you would usually fill it with the desired information
5949/// // into the respective structure. Some of the parts shown here might not be applicable !
5950/// // Values shown here are possibly random and not representative !
5951/// let mut req = BindDeviceToGatewayRequest::default();
5952///
5953/// // You can configure optional parameters by calling the respective setters at will, and
5954/// // execute the final call using `doit()`.
5955/// // Values shown here are possibly random and not representative !
5956/// let result = hub.projects().locations_registries_bind_device_to_gateway(req, "parent")
5957/// .doit().await;
5958/// # }
5959/// ```
5960pub struct ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
5961where
5962 C: 'a,
5963{
5964 hub: &'a CloudIot<C>,
5965 _request: BindDeviceToGatewayRequest,
5966 _parent: String,
5967 _delegate: Option<&'a mut dyn common::Delegate>,
5968 _additional_params: HashMap<String, String>,
5969 _scopes: BTreeSet<String>,
5970}
5971
5972impl<'a, C> common::CallBuilder for ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {}
5973
5974impl<'a, C> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
5975where
5976 C: common::Connector,
5977{
5978 /// Perform the operation you have build so far.
5979 pub async fn doit(mut self) -> common::Result<(common::Response, BindDeviceToGatewayResponse)> {
5980 use std::borrow::Cow;
5981 use std::io::{Read, Seek};
5982
5983 use common::{url::Params, ToParts};
5984 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5985
5986 let mut dd = common::DefaultDelegate;
5987 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5988 dlg.begin(common::MethodInfo {
5989 id: "cloudiot.projects.locations.registries.bindDeviceToGateway",
5990 http_method: hyper::Method::POST,
5991 });
5992
5993 for &field in ["alt", "parent"].iter() {
5994 if self._additional_params.contains_key(field) {
5995 dlg.finished(false);
5996 return Err(common::Error::FieldClash(field));
5997 }
5998 }
5999
6000 let mut params = Params::with_capacity(4 + self._additional_params.len());
6001 params.push("parent", self._parent);
6002
6003 params.extend(self._additional_params.iter());
6004
6005 params.push("alt", "json");
6006 let mut url = self.hub._base_url.clone() + "v1/{+parent}:bindDeviceToGateway";
6007 if self._scopes.is_empty() {
6008 self._scopes
6009 .insert(Scope::CloudPlatform.as_ref().to_string());
6010 }
6011
6012 #[allow(clippy::single_element_loop)]
6013 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6014 url = params.uri_replacement(url, param_name, find_this, true);
6015 }
6016 {
6017 let to_remove = ["parent"];
6018 params.remove_params(&to_remove);
6019 }
6020
6021 let url = params.parse_with_url(&url);
6022
6023 let mut json_mime_type = mime::APPLICATION_JSON;
6024 let mut request_value_reader = {
6025 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6026 common::remove_json_null_values(&mut value);
6027 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6028 serde_json::to_writer(&mut dst, &value).unwrap();
6029 dst
6030 };
6031 let request_size = request_value_reader
6032 .seek(std::io::SeekFrom::End(0))
6033 .unwrap();
6034 request_value_reader
6035 .seek(std::io::SeekFrom::Start(0))
6036 .unwrap();
6037
6038 loop {
6039 let token = match self
6040 .hub
6041 .auth
6042 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6043 .await
6044 {
6045 Ok(token) => token,
6046 Err(e) => match dlg.token(e) {
6047 Ok(token) => token,
6048 Err(e) => {
6049 dlg.finished(false);
6050 return Err(common::Error::MissingToken(e));
6051 }
6052 },
6053 };
6054 request_value_reader
6055 .seek(std::io::SeekFrom::Start(0))
6056 .unwrap();
6057 let mut req_result = {
6058 let client = &self.hub.client;
6059 dlg.pre_request();
6060 let mut req_builder = hyper::Request::builder()
6061 .method(hyper::Method::POST)
6062 .uri(url.as_str())
6063 .header(USER_AGENT, self.hub._user_agent.clone());
6064
6065 if let Some(token) = token.as_ref() {
6066 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6067 }
6068
6069 let request = req_builder
6070 .header(CONTENT_TYPE, json_mime_type.to_string())
6071 .header(CONTENT_LENGTH, request_size as u64)
6072 .body(common::to_body(
6073 request_value_reader.get_ref().clone().into(),
6074 ));
6075
6076 client.request(request.unwrap()).await
6077 };
6078
6079 match req_result {
6080 Err(err) => {
6081 if let common::Retry::After(d) = dlg.http_error(&err) {
6082 sleep(d).await;
6083 continue;
6084 }
6085 dlg.finished(false);
6086 return Err(common::Error::HttpError(err));
6087 }
6088 Ok(res) => {
6089 let (mut parts, body) = res.into_parts();
6090 let mut body = common::Body::new(body);
6091 if !parts.status.is_success() {
6092 let bytes = common::to_bytes(body).await.unwrap_or_default();
6093 let error = serde_json::from_str(&common::to_string(&bytes));
6094 let response = common::to_response(parts, bytes.into());
6095
6096 if let common::Retry::After(d) =
6097 dlg.http_failure(&response, error.as_ref().ok())
6098 {
6099 sleep(d).await;
6100 continue;
6101 }
6102
6103 dlg.finished(false);
6104
6105 return Err(match error {
6106 Ok(value) => common::Error::BadRequest(value),
6107 _ => common::Error::Failure(response),
6108 });
6109 }
6110 let response = {
6111 let bytes = common::to_bytes(body).await.unwrap_or_default();
6112 let encoded = common::to_string(&bytes);
6113 match serde_json::from_str(&encoded) {
6114 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6115 Err(error) => {
6116 dlg.response_json_decode_error(&encoded, &error);
6117 return Err(common::Error::JsonDecodeError(
6118 encoded.to_string(),
6119 error,
6120 ));
6121 }
6122 }
6123 };
6124
6125 dlg.finished(true);
6126 return Ok(response);
6127 }
6128 }
6129 }
6130 }
6131
6132 ///
6133 /// Sets the *request* property to the given value.
6134 ///
6135 /// Even though the property as already been set when instantiating this call,
6136 /// we provide this method for API completeness.
6137 pub fn request(
6138 mut self,
6139 new_value: BindDeviceToGatewayRequest,
6140 ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6141 self._request = new_value;
6142 self
6143 }
6144 /// Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
6145 ///
6146 /// Sets the *parent* path property to the given value.
6147 ///
6148 /// Even though the property as already been set when instantiating this call,
6149 /// we provide this method for API completeness.
6150 pub fn parent(
6151 mut self,
6152 new_value: &str,
6153 ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6154 self._parent = new_value.to_string();
6155 self
6156 }
6157 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6158 /// while executing the actual API request.
6159 ///
6160 /// ````text
6161 /// It should be used to handle progress information, and to implement a certain level of resilience.
6162 /// ````
6163 ///
6164 /// Sets the *delegate* property to the given value.
6165 pub fn delegate(
6166 mut self,
6167 new_value: &'a mut dyn common::Delegate,
6168 ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6169 self._delegate = Some(new_value);
6170 self
6171 }
6172
6173 /// Set any additional parameter of the query string used in the request.
6174 /// It should be used to set parameters which are not yet available through their own
6175 /// setters.
6176 ///
6177 /// Please note that this method must not be used to set any of the known parameters
6178 /// which have their own setter method. If done anyway, the request will fail.
6179 ///
6180 /// # Additional Parameters
6181 ///
6182 /// * *$.xgafv* (query-string) - V1 error format.
6183 /// * *access_token* (query-string) - OAuth access token.
6184 /// * *alt* (query-string) - Data format for response.
6185 /// * *callback* (query-string) - JSONP
6186 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6187 /// * *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.
6188 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6189 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6190 /// * *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.
6191 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6192 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6193 pub fn param<T>(
6194 mut self,
6195 name: T,
6196 value: T,
6197 ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6198 where
6199 T: AsRef<str>,
6200 {
6201 self._additional_params
6202 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6203 self
6204 }
6205
6206 /// Identifies the authorization scope for the method you are building.
6207 ///
6208 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6209 /// [`Scope::CloudPlatform`].
6210 ///
6211 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6212 /// tokens for more than one scope.
6213 ///
6214 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6215 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6216 /// sufficient, a read-write scope will do as well.
6217 pub fn add_scope<St>(
6218 mut self,
6219 scope: St,
6220 ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6221 where
6222 St: AsRef<str>,
6223 {
6224 self._scopes.insert(String::from(scope.as_ref()));
6225 self
6226 }
6227 /// Identifies the authorization scope(s) for the method you are building.
6228 ///
6229 /// See [`Self::add_scope()`] for details.
6230 pub fn add_scopes<I, St>(
6231 mut self,
6232 scopes: I,
6233 ) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C>
6234 where
6235 I: IntoIterator<Item = St>,
6236 St: AsRef<str>,
6237 {
6238 self._scopes
6239 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6240 self
6241 }
6242
6243 /// Removes all scopes, and no default scope will be used either.
6244 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6245 /// for details).
6246 pub fn clear_scopes(mut self) -> ProjectLocationRegistryBindDeviceToGatewayCall<'a, C> {
6247 self._scopes.clear();
6248 self
6249 }
6250}
6251
6252/// Creates a device registry that contains devices.
6253///
6254/// A builder for the *locations.registries.create* method supported by a *project* resource.
6255/// It is not used directly, but through a [`ProjectMethods`] instance.
6256///
6257/// # Example
6258///
6259/// Instantiate a resource method builder
6260///
6261/// ```test_harness,no_run
6262/// # extern crate hyper;
6263/// # extern crate hyper_rustls;
6264/// # extern crate google_cloudiot1 as cloudiot1;
6265/// use cloudiot1::api::DeviceRegistry;
6266/// # async fn dox() {
6267/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6268///
6269/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6270/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6271/// # secret,
6272/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6273/// # ).build().await.unwrap();
6274///
6275/// # let client = hyper_util::client::legacy::Client::builder(
6276/// # hyper_util::rt::TokioExecutor::new()
6277/// # )
6278/// # .build(
6279/// # hyper_rustls::HttpsConnectorBuilder::new()
6280/// # .with_native_roots()
6281/// # .unwrap()
6282/// # .https_or_http()
6283/// # .enable_http1()
6284/// # .build()
6285/// # );
6286/// # let mut hub = CloudIot::new(client, auth);
6287/// // As the method needs a request, you would usually fill it with the desired information
6288/// // into the respective structure. Some of the parts shown here might not be applicable !
6289/// // Values shown here are possibly random and not representative !
6290/// let mut req = DeviceRegistry::default();
6291///
6292/// // You can configure optional parameters by calling the respective setters at will, and
6293/// // execute the final call using `doit()`.
6294/// // Values shown here are possibly random and not representative !
6295/// let result = hub.projects().locations_registries_create(req, "parent")
6296/// .doit().await;
6297/// # }
6298/// ```
6299pub struct ProjectLocationRegistryCreateCall<'a, C>
6300where
6301 C: 'a,
6302{
6303 hub: &'a CloudIot<C>,
6304 _request: DeviceRegistry,
6305 _parent: String,
6306 _delegate: Option<&'a mut dyn common::Delegate>,
6307 _additional_params: HashMap<String, String>,
6308 _scopes: BTreeSet<String>,
6309}
6310
6311impl<'a, C> common::CallBuilder for ProjectLocationRegistryCreateCall<'a, C> {}
6312
6313impl<'a, C> ProjectLocationRegistryCreateCall<'a, C>
6314where
6315 C: common::Connector,
6316{
6317 /// Perform the operation you have build so far.
6318 pub async fn doit(mut self) -> common::Result<(common::Response, DeviceRegistry)> {
6319 use std::borrow::Cow;
6320 use std::io::{Read, Seek};
6321
6322 use common::{url::Params, ToParts};
6323 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6324
6325 let mut dd = common::DefaultDelegate;
6326 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6327 dlg.begin(common::MethodInfo {
6328 id: "cloudiot.projects.locations.registries.create",
6329 http_method: hyper::Method::POST,
6330 });
6331
6332 for &field in ["alt", "parent"].iter() {
6333 if self._additional_params.contains_key(field) {
6334 dlg.finished(false);
6335 return Err(common::Error::FieldClash(field));
6336 }
6337 }
6338
6339 let mut params = Params::with_capacity(4 + self._additional_params.len());
6340 params.push("parent", self._parent);
6341
6342 params.extend(self._additional_params.iter());
6343
6344 params.push("alt", "json");
6345 let mut url = self.hub._base_url.clone() + "v1/{+parent}/registries";
6346 if self._scopes.is_empty() {
6347 self._scopes
6348 .insert(Scope::CloudPlatform.as_ref().to_string());
6349 }
6350
6351 #[allow(clippy::single_element_loop)]
6352 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6353 url = params.uri_replacement(url, param_name, find_this, true);
6354 }
6355 {
6356 let to_remove = ["parent"];
6357 params.remove_params(&to_remove);
6358 }
6359
6360 let url = params.parse_with_url(&url);
6361
6362 let mut json_mime_type = mime::APPLICATION_JSON;
6363 let mut request_value_reader = {
6364 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6365 common::remove_json_null_values(&mut value);
6366 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6367 serde_json::to_writer(&mut dst, &value).unwrap();
6368 dst
6369 };
6370 let request_size = request_value_reader
6371 .seek(std::io::SeekFrom::End(0))
6372 .unwrap();
6373 request_value_reader
6374 .seek(std::io::SeekFrom::Start(0))
6375 .unwrap();
6376
6377 loop {
6378 let token = match self
6379 .hub
6380 .auth
6381 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6382 .await
6383 {
6384 Ok(token) => token,
6385 Err(e) => match dlg.token(e) {
6386 Ok(token) => token,
6387 Err(e) => {
6388 dlg.finished(false);
6389 return Err(common::Error::MissingToken(e));
6390 }
6391 },
6392 };
6393 request_value_reader
6394 .seek(std::io::SeekFrom::Start(0))
6395 .unwrap();
6396 let mut req_result = {
6397 let client = &self.hub.client;
6398 dlg.pre_request();
6399 let mut req_builder = hyper::Request::builder()
6400 .method(hyper::Method::POST)
6401 .uri(url.as_str())
6402 .header(USER_AGENT, self.hub._user_agent.clone());
6403
6404 if let Some(token) = token.as_ref() {
6405 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6406 }
6407
6408 let request = req_builder
6409 .header(CONTENT_TYPE, json_mime_type.to_string())
6410 .header(CONTENT_LENGTH, request_size as u64)
6411 .body(common::to_body(
6412 request_value_reader.get_ref().clone().into(),
6413 ));
6414
6415 client.request(request.unwrap()).await
6416 };
6417
6418 match req_result {
6419 Err(err) => {
6420 if let common::Retry::After(d) = dlg.http_error(&err) {
6421 sleep(d).await;
6422 continue;
6423 }
6424 dlg.finished(false);
6425 return Err(common::Error::HttpError(err));
6426 }
6427 Ok(res) => {
6428 let (mut parts, body) = res.into_parts();
6429 let mut body = common::Body::new(body);
6430 if !parts.status.is_success() {
6431 let bytes = common::to_bytes(body).await.unwrap_or_default();
6432 let error = serde_json::from_str(&common::to_string(&bytes));
6433 let response = common::to_response(parts, bytes.into());
6434
6435 if let common::Retry::After(d) =
6436 dlg.http_failure(&response, error.as_ref().ok())
6437 {
6438 sleep(d).await;
6439 continue;
6440 }
6441
6442 dlg.finished(false);
6443
6444 return Err(match error {
6445 Ok(value) => common::Error::BadRequest(value),
6446 _ => common::Error::Failure(response),
6447 });
6448 }
6449 let response = {
6450 let bytes = common::to_bytes(body).await.unwrap_or_default();
6451 let encoded = common::to_string(&bytes);
6452 match serde_json::from_str(&encoded) {
6453 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6454 Err(error) => {
6455 dlg.response_json_decode_error(&encoded, &error);
6456 return Err(common::Error::JsonDecodeError(
6457 encoded.to_string(),
6458 error,
6459 ));
6460 }
6461 }
6462 };
6463
6464 dlg.finished(true);
6465 return Ok(response);
6466 }
6467 }
6468 }
6469 }
6470
6471 ///
6472 /// Sets the *request* property to the given value.
6473 ///
6474 /// Even though the property as already been set when instantiating this call,
6475 /// we provide this method for API completeness.
6476 pub fn request(
6477 mut self,
6478 new_value: DeviceRegistry,
6479 ) -> ProjectLocationRegistryCreateCall<'a, C> {
6480 self._request = new_value;
6481 self
6482 }
6483 /// Required. The project and cloud region where this device registry must be created. For example, `projects/example-project/locations/us-central1`.
6484 ///
6485 /// Sets the *parent* path property to the given value.
6486 ///
6487 /// Even though the property as already been set when instantiating this call,
6488 /// we provide this method for API completeness.
6489 pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryCreateCall<'a, C> {
6490 self._parent = new_value.to_string();
6491 self
6492 }
6493 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6494 /// while executing the actual API request.
6495 ///
6496 /// ````text
6497 /// It should be used to handle progress information, and to implement a certain level of resilience.
6498 /// ````
6499 ///
6500 /// Sets the *delegate* property to the given value.
6501 pub fn delegate(
6502 mut self,
6503 new_value: &'a mut dyn common::Delegate,
6504 ) -> ProjectLocationRegistryCreateCall<'a, C> {
6505 self._delegate = Some(new_value);
6506 self
6507 }
6508
6509 /// Set any additional parameter of the query string used in the request.
6510 /// It should be used to set parameters which are not yet available through their own
6511 /// setters.
6512 ///
6513 /// Please note that this method must not be used to set any of the known parameters
6514 /// which have their own setter method. If done anyway, the request will fail.
6515 ///
6516 /// # Additional Parameters
6517 ///
6518 /// * *$.xgafv* (query-string) - V1 error format.
6519 /// * *access_token* (query-string) - OAuth access token.
6520 /// * *alt* (query-string) - Data format for response.
6521 /// * *callback* (query-string) - JSONP
6522 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6523 /// * *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.
6524 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6525 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6526 /// * *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.
6527 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6528 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6529 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryCreateCall<'a, C>
6530 where
6531 T: AsRef<str>,
6532 {
6533 self._additional_params
6534 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6535 self
6536 }
6537
6538 /// Identifies the authorization scope for the method you are building.
6539 ///
6540 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6541 /// [`Scope::CloudPlatform`].
6542 ///
6543 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6544 /// tokens for more than one scope.
6545 ///
6546 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6547 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6548 /// sufficient, a read-write scope will do as well.
6549 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryCreateCall<'a, C>
6550 where
6551 St: AsRef<str>,
6552 {
6553 self._scopes.insert(String::from(scope.as_ref()));
6554 self
6555 }
6556 /// Identifies the authorization scope(s) for the method you are building.
6557 ///
6558 /// See [`Self::add_scope()`] for details.
6559 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryCreateCall<'a, C>
6560 where
6561 I: IntoIterator<Item = St>,
6562 St: AsRef<str>,
6563 {
6564 self._scopes
6565 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6566 self
6567 }
6568
6569 /// Removes all scopes, and no default scope will be used either.
6570 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6571 /// for details).
6572 pub fn clear_scopes(mut self) -> ProjectLocationRegistryCreateCall<'a, C> {
6573 self._scopes.clear();
6574 self
6575 }
6576}
6577
6578/// Deletes a device registry configuration.
6579///
6580/// A builder for the *locations.registries.delete* method supported by a *project* resource.
6581/// It is not used directly, but through a [`ProjectMethods`] instance.
6582///
6583/// # Example
6584///
6585/// Instantiate a resource method builder
6586///
6587/// ```test_harness,no_run
6588/// # extern crate hyper;
6589/// # extern crate hyper_rustls;
6590/// # extern crate google_cloudiot1 as cloudiot1;
6591/// # async fn dox() {
6592/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6593///
6594/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6595/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6596/// # secret,
6597/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6598/// # ).build().await.unwrap();
6599///
6600/// # let client = hyper_util::client::legacy::Client::builder(
6601/// # hyper_util::rt::TokioExecutor::new()
6602/// # )
6603/// # .build(
6604/// # hyper_rustls::HttpsConnectorBuilder::new()
6605/// # .with_native_roots()
6606/// # .unwrap()
6607/// # .https_or_http()
6608/// # .enable_http1()
6609/// # .build()
6610/// # );
6611/// # let mut hub = CloudIot::new(client, auth);
6612/// // You can configure optional parameters by calling the respective setters at will, and
6613/// // execute the final call using `doit()`.
6614/// // Values shown here are possibly random and not representative !
6615/// let result = hub.projects().locations_registries_delete("name")
6616/// .doit().await;
6617/// # }
6618/// ```
6619pub struct ProjectLocationRegistryDeleteCall<'a, C>
6620where
6621 C: 'a,
6622{
6623 hub: &'a CloudIot<C>,
6624 _name: String,
6625 _delegate: Option<&'a mut dyn common::Delegate>,
6626 _additional_params: HashMap<String, String>,
6627 _scopes: BTreeSet<String>,
6628}
6629
6630impl<'a, C> common::CallBuilder for ProjectLocationRegistryDeleteCall<'a, C> {}
6631
6632impl<'a, C> ProjectLocationRegistryDeleteCall<'a, C>
6633where
6634 C: common::Connector,
6635{
6636 /// Perform the operation you have build so far.
6637 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6638 use std::borrow::Cow;
6639 use std::io::{Read, Seek};
6640
6641 use common::{url::Params, ToParts};
6642 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6643
6644 let mut dd = common::DefaultDelegate;
6645 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6646 dlg.begin(common::MethodInfo {
6647 id: "cloudiot.projects.locations.registries.delete",
6648 http_method: hyper::Method::DELETE,
6649 });
6650
6651 for &field in ["alt", "name"].iter() {
6652 if self._additional_params.contains_key(field) {
6653 dlg.finished(false);
6654 return Err(common::Error::FieldClash(field));
6655 }
6656 }
6657
6658 let mut params = Params::with_capacity(3 + self._additional_params.len());
6659 params.push("name", self._name);
6660
6661 params.extend(self._additional_params.iter());
6662
6663 params.push("alt", "json");
6664 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6665 if self._scopes.is_empty() {
6666 self._scopes
6667 .insert(Scope::CloudPlatform.as_ref().to_string());
6668 }
6669
6670 #[allow(clippy::single_element_loop)]
6671 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6672 url = params.uri_replacement(url, param_name, find_this, true);
6673 }
6674 {
6675 let to_remove = ["name"];
6676 params.remove_params(&to_remove);
6677 }
6678
6679 let url = params.parse_with_url(&url);
6680
6681 loop {
6682 let token = match self
6683 .hub
6684 .auth
6685 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6686 .await
6687 {
6688 Ok(token) => token,
6689 Err(e) => match dlg.token(e) {
6690 Ok(token) => token,
6691 Err(e) => {
6692 dlg.finished(false);
6693 return Err(common::Error::MissingToken(e));
6694 }
6695 },
6696 };
6697 let mut req_result = {
6698 let client = &self.hub.client;
6699 dlg.pre_request();
6700 let mut req_builder = hyper::Request::builder()
6701 .method(hyper::Method::DELETE)
6702 .uri(url.as_str())
6703 .header(USER_AGENT, self.hub._user_agent.clone());
6704
6705 if let Some(token) = token.as_ref() {
6706 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6707 }
6708
6709 let request = req_builder
6710 .header(CONTENT_LENGTH, 0_u64)
6711 .body(common::to_body::<String>(None));
6712
6713 client.request(request.unwrap()).await
6714 };
6715
6716 match req_result {
6717 Err(err) => {
6718 if let common::Retry::After(d) = dlg.http_error(&err) {
6719 sleep(d).await;
6720 continue;
6721 }
6722 dlg.finished(false);
6723 return Err(common::Error::HttpError(err));
6724 }
6725 Ok(res) => {
6726 let (mut parts, body) = res.into_parts();
6727 let mut body = common::Body::new(body);
6728 if !parts.status.is_success() {
6729 let bytes = common::to_bytes(body).await.unwrap_or_default();
6730 let error = serde_json::from_str(&common::to_string(&bytes));
6731 let response = common::to_response(parts, bytes.into());
6732
6733 if let common::Retry::After(d) =
6734 dlg.http_failure(&response, error.as_ref().ok())
6735 {
6736 sleep(d).await;
6737 continue;
6738 }
6739
6740 dlg.finished(false);
6741
6742 return Err(match error {
6743 Ok(value) => common::Error::BadRequest(value),
6744 _ => common::Error::Failure(response),
6745 });
6746 }
6747 let response = {
6748 let bytes = common::to_bytes(body).await.unwrap_or_default();
6749 let encoded = common::to_string(&bytes);
6750 match serde_json::from_str(&encoded) {
6751 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6752 Err(error) => {
6753 dlg.response_json_decode_error(&encoded, &error);
6754 return Err(common::Error::JsonDecodeError(
6755 encoded.to_string(),
6756 error,
6757 ));
6758 }
6759 }
6760 };
6761
6762 dlg.finished(true);
6763 return Ok(response);
6764 }
6765 }
6766 }
6767 }
6768
6769 /// Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
6770 ///
6771 /// Sets the *name* path property to the given value.
6772 ///
6773 /// Even though the property as already been set when instantiating this call,
6774 /// we provide this method for API completeness.
6775 pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryDeleteCall<'a, C> {
6776 self._name = new_value.to_string();
6777 self
6778 }
6779 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6780 /// while executing the actual API request.
6781 ///
6782 /// ````text
6783 /// It should be used to handle progress information, and to implement a certain level of resilience.
6784 /// ````
6785 ///
6786 /// Sets the *delegate* property to the given value.
6787 pub fn delegate(
6788 mut self,
6789 new_value: &'a mut dyn common::Delegate,
6790 ) -> ProjectLocationRegistryDeleteCall<'a, C> {
6791 self._delegate = Some(new_value);
6792 self
6793 }
6794
6795 /// Set any additional parameter of the query string used in the request.
6796 /// It should be used to set parameters which are not yet available through their own
6797 /// setters.
6798 ///
6799 /// Please note that this method must not be used to set any of the known parameters
6800 /// which have their own setter method. If done anyway, the request will fail.
6801 ///
6802 /// # Additional Parameters
6803 ///
6804 /// * *$.xgafv* (query-string) - V1 error format.
6805 /// * *access_token* (query-string) - OAuth access token.
6806 /// * *alt* (query-string) - Data format for response.
6807 /// * *callback* (query-string) - JSONP
6808 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6809 /// * *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.
6810 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6811 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6812 /// * *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.
6813 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6814 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6815 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryDeleteCall<'a, C>
6816 where
6817 T: AsRef<str>,
6818 {
6819 self._additional_params
6820 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6821 self
6822 }
6823
6824 /// Identifies the authorization scope for the method you are building.
6825 ///
6826 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6827 /// [`Scope::CloudPlatform`].
6828 ///
6829 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6830 /// tokens for more than one scope.
6831 ///
6832 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6833 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6834 /// sufficient, a read-write scope will do as well.
6835 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryDeleteCall<'a, C>
6836 where
6837 St: AsRef<str>,
6838 {
6839 self._scopes.insert(String::from(scope.as_ref()));
6840 self
6841 }
6842 /// Identifies the authorization scope(s) for the method you are building.
6843 ///
6844 /// See [`Self::add_scope()`] for details.
6845 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryDeleteCall<'a, C>
6846 where
6847 I: IntoIterator<Item = St>,
6848 St: AsRef<str>,
6849 {
6850 self._scopes
6851 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6852 self
6853 }
6854
6855 /// Removes all scopes, and no default scope will be used either.
6856 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6857 /// for details).
6858 pub fn clear_scopes(mut self) -> ProjectLocationRegistryDeleteCall<'a, C> {
6859 self._scopes.clear();
6860 self
6861 }
6862}
6863
6864/// Gets a device registry configuration.
6865///
6866/// A builder for the *locations.registries.get* method supported by a *project* resource.
6867/// It is not used directly, but through a [`ProjectMethods`] instance.
6868///
6869/// # Example
6870///
6871/// Instantiate a resource method builder
6872///
6873/// ```test_harness,no_run
6874/// # extern crate hyper;
6875/// # extern crate hyper_rustls;
6876/// # extern crate google_cloudiot1 as cloudiot1;
6877/// # async fn dox() {
6878/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6879///
6880/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6881/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6882/// # secret,
6883/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6884/// # ).build().await.unwrap();
6885///
6886/// # let client = hyper_util::client::legacy::Client::builder(
6887/// # hyper_util::rt::TokioExecutor::new()
6888/// # )
6889/// # .build(
6890/// # hyper_rustls::HttpsConnectorBuilder::new()
6891/// # .with_native_roots()
6892/// # .unwrap()
6893/// # .https_or_http()
6894/// # .enable_http1()
6895/// # .build()
6896/// # );
6897/// # let mut hub = CloudIot::new(client, auth);
6898/// // You can configure optional parameters by calling the respective setters at will, and
6899/// // execute the final call using `doit()`.
6900/// // Values shown here are possibly random and not representative !
6901/// let result = hub.projects().locations_registries_get("name")
6902/// .doit().await;
6903/// # }
6904/// ```
6905pub struct ProjectLocationRegistryGetCall<'a, C>
6906where
6907 C: 'a,
6908{
6909 hub: &'a CloudIot<C>,
6910 _name: String,
6911 _delegate: Option<&'a mut dyn common::Delegate>,
6912 _additional_params: HashMap<String, String>,
6913 _scopes: BTreeSet<String>,
6914}
6915
6916impl<'a, C> common::CallBuilder for ProjectLocationRegistryGetCall<'a, C> {}
6917
6918impl<'a, C> ProjectLocationRegistryGetCall<'a, C>
6919where
6920 C: common::Connector,
6921{
6922 /// Perform the operation you have build so far.
6923 pub async fn doit(mut self) -> common::Result<(common::Response, DeviceRegistry)> {
6924 use std::borrow::Cow;
6925 use std::io::{Read, Seek};
6926
6927 use common::{url::Params, ToParts};
6928 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6929
6930 let mut dd = common::DefaultDelegate;
6931 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6932 dlg.begin(common::MethodInfo {
6933 id: "cloudiot.projects.locations.registries.get",
6934 http_method: hyper::Method::GET,
6935 });
6936
6937 for &field in ["alt", "name"].iter() {
6938 if self._additional_params.contains_key(field) {
6939 dlg.finished(false);
6940 return Err(common::Error::FieldClash(field));
6941 }
6942 }
6943
6944 let mut params = Params::with_capacity(3 + self._additional_params.len());
6945 params.push("name", self._name);
6946
6947 params.extend(self._additional_params.iter());
6948
6949 params.push("alt", "json");
6950 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6951 if self._scopes.is_empty() {
6952 self._scopes
6953 .insert(Scope::CloudPlatform.as_ref().to_string());
6954 }
6955
6956 #[allow(clippy::single_element_loop)]
6957 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6958 url = params.uri_replacement(url, param_name, find_this, true);
6959 }
6960 {
6961 let to_remove = ["name"];
6962 params.remove_params(&to_remove);
6963 }
6964
6965 let url = params.parse_with_url(&url);
6966
6967 loop {
6968 let token = match self
6969 .hub
6970 .auth
6971 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6972 .await
6973 {
6974 Ok(token) => token,
6975 Err(e) => match dlg.token(e) {
6976 Ok(token) => token,
6977 Err(e) => {
6978 dlg.finished(false);
6979 return Err(common::Error::MissingToken(e));
6980 }
6981 },
6982 };
6983 let mut req_result = {
6984 let client = &self.hub.client;
6985 dlg.pre_request();
6986 let mut req_builder = hyper::Request::builder()
6987 .method(hyper::Method::GET)
6988 .uri(url.as_str())
6989 .header(USER_AGENT, self.hub._user_agent.clone());
6990
6991 if let Some(token) = token.as_ref() {
6992 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6993 }
6994
6995 let request = req_builder
6996 .header(CONTENT_LENGTH, 0_u64)
6997 .body(common::to_body::<String>(None));
6998
6999 client.request(request.unwrap()).await
7000 };
7001
7002 match req_result {
7003 Err(err) => {
7004 if let common::Retry::After(d) = dlg.http_error(&err) {
7005 sleep(d).await;
7006 continue;
7007 }
7008 dlg.finished(false);
7009 return Err(common::Error::HttpError(err));
7010 }
7011 Ok(res) => {
7012 let (mut parts, body) = res.into_parts();
7013 let mut body = common::Body::new(body);
7014 if !parts.status.is_success() {
7015 let bytes = common::to_bytes(body).await.unwrap_or_default();
7016 let error = serde_json::from_str(&common::to_string(&bytes));
7017 let response = common::to_response(parts, bytes.into());
7018
7019 if let common::Retry::After(d) =
7020 dlg.http_failure(&response, error.as_ref().ok())
7021 {
7022 sleep(d).await;
7023 continue;
7024 }
7025
7026 dlg.finished(false);
7027
7028 return Err(match error {
7029 Ok(value) => common::Error::BadRequest(value),
7030 _ => common::Error::Failure(response),
7031 });
7032 }
7033 let response = {
7034 let bytes = common::to_bytes(body).await.unwrap_or_default();
7035 let encoded = common::to_string(&bytes);
7036 match serde_json::from_str(&encoded) {
7037 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7038 Err(error) => {
7039 dlg.response_json_decode_error(&encoded, &error);
7040 return Err(common::Error::JsonDecodeError(
7041 encoded.to_string(),
7042 error,
7043 ));
7044 }
7045 }
7046 };
7047
7048 dlg.finished(true);
7049 return Ok(response);
7050 }
7051 }
7052 }
7053 }
7054
7055 /// Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
7056 ///
7057 /// Sets the *name* path property to the given value.
7058 ///
7059 /// Even though the property as already been set when instantiating this call,
7060 /// we provide this method for API completeness.
7061 pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryGetCall<'a, C> {
7062 self._name = new_value.to_string();
7063 self
7064 }
7065 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7066 /// while executing the actual API request.
7067 ///
7068 /// ````text
7069 /// It should be used to handle progress information, and to implement a certain level of resilience.
7070 /// ````
7071 ///
7072 /// Sets the *delegate* property to the given value.
7073 pub fn delegate(
7074 mut self,
7075 new_value: &'a mut dyn common::Delegate,
7076 ) -> ProjectLocationRegistryGetCall<'a, C> {
7077 self._delegate = Some(new_value);
7078 self
7079 }
7080
7081 /// Set any additional parameter of the query string used in the request.
7082 /// It should be used to set parameters which are not yet available through their own
7083 /// setters.
7084 ///
7085 /// Please note that this method must not be used to set any of the known parameters
7086 /// which have their own setter method. If done anyway, the request will fail.
7087 ///
7088 /// # Additional Parameters
7089 ///
7090 /// * *$.xgafv* (query-string) - V1 error format.
7091 /// * *access_token* (query-string) - OAuth access token.
7092 /// * *alt* (query-string) - Data format for response.
7093 /// * *callback* (query-string) - JSONP
7094 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7095 /// * *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.
7096 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7097 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7098 /// * *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.
7099 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7100 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7101 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryGetCall<'a, C>
7102 where
7103 T: AsRef<str>,
7104 {
7105 self._additional_params
7106 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7107 self
7108 }
7109
7110 /// Identifies the authorization scope for the method you are building.
7111 ///
7112 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7113 /// [`Scope::CloudPlatform`].
7114 ///
7115 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7116 /// tokens for more than one scope.
7117 ///
7118 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7119 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7120 /// sufficient, a read-write scope will do as well.
7121 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGetCall<'a, C>
7122 where
7123 St: AsRef<str>,
7124 {
7125 self._scopes.insert(String::from(scope.as_ref()));
7126 self
7127 }
7128 /// Identifies the authorization scope(s) for the method you are building.
7129 ///
7130 /// See [`Self::add_scope()`] for details.
7131 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryGetCall<'a, C>
7132 where
7133 I: IntoIterator<Item = St>,
7134 St: AsRef<str>,
7135 {
7136 self._scopes
7137 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7138 self
7139 }
7140
7141 /// Removes all scopes, and no default scope will be used either.
7142 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7143 /// for details).
7144 pub fn clear_scopes(mut self) -> ProjectLocationRegistryGetCall<'a, C> {
7145 self._scopes.clear();
7146 self
7147 }
7148}
7149
7150/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7151///
7152/// A builder for the *locations.registries.getIamPolicy* method supported by a *project* resource.
7153/// It is not used directly, but through a [`ProjectMethods`] instance.
7154///
7155/// # Example
7156///
7157/// Instantiate a resource method builder
7158///
7159/// ```test_harness,no_run
7160/// # extern crate hyper;
7161/// # extern crate hyper_rustls;
7162/// # extern crate google_cloudiot1 as cloudiot1;
7163/// use cloudiot1::api::GetIamPolicyRequest;
7164/// # async fn dox() {
7165/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7166///
7167/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7168/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7169/// # secret,
7170/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7171/// # ).build().await.unwrap();
7172///
7173/// # let client = hyper_util::client::legacy::Client::builder(
7174/// # hyper_util::rt::TokioExecutor::new()
7175/// # )
7176/// # .build(
7177/// # hyper_rustls::HttpsConnectorBuilder::new()
7178/// # .with_native_roots()
7179/// # .unwrap()
7180/// # .https_or_http()
7181/// # .enable_http1()
7182/// # .build()
7183/// # );
7184/// # let mut hub = CloudIot::new(client, auth);
7185/// // As the method needs a request, you would usually fill it with the desired information
7186/// // into the respective structure. Some of the parts shown here might not be applicable !
7187/// // Values shown here are possibly random and not representative !
7188/// let mut req = GetIamPolicyRequest::default();
7189///
7190/// // You can configure optional parameters by calling the respective setters at will, and
7191/// // execute the final call using `doit()`.
7192/// // Values shown here are possibly random and not representative !
7193/// let result = hub.projects().locations_registries_get_iam_policy(req, "resource")
7194/// .doit().await;
7195/// # }
7196/// ```
7197pub struct ProjectLocationRegistryGetIamPolicyCall<'a, C>
7198where
7199 C: 'a,
7200{
7201 hub: &'a CloudIot<C>,
7202 _request: GetIamPolicyRequest,
7203 _resource: String,
7204 _delegate: Option<&'a mut dyn common::Delegate>,
7205 _additional_params: HashMap<String, String>,
7206 _scopes: BTreeSet<String>,
7207}
7208
7209impl<'a, C> common::CallBuilder for ProjectLocationRegistryGetIamPolicyCall<'a, C> {}
7210
7211impl<'a, C> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7212where
7213 C: common::Connector,
7214{
7215 /// Perform the operation you have build so far.
7216 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7217 use std::borrow::Cow;
7218 use std::io::{Read, Seek};
7219
7220 use common::{url::Params, ToParts};
7221 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7222
7223 let mut dd = common::DefaultDelegate;
7224 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7225 dlg.begin(common::MethodInfo {
7226 id: "cloudiot.projects.locations.registries.getIamPolicy",
7227 http_method: hyper::Method::POST,
7228 });
7229
7230 for &field in ["alt", "resource"].iter() {
7231 if self._additional_params.contains_key(field) {
7232 dlg.finished(false);
7233 return Err(common::Error::FieldClash(field));
7234 }
7235 }
7236
7237 let mut params = Params::with_capacity(4 + self._additional_params.len());
7238 params.push("resource", self._resource);
7239
7240 params.extend(self._additional_params.iter());
7241
7242 params.push("alt", "json");
7243 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7244 if self._scopes.is_empty() {
7245 self._scopes
7246 .insert(Scope::CloudPlatform.as_ref().to_string());
7247 }
7248
7249 #[allow(clippy::single_element_loop)]
7250 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7251 url = params.uri_replacement(url, param_name, find_this, true);
7252 }
7253 {
7254 let to_remove = ["resource"];
7255 params.remove_params(&to_remove);
7256 }
7257
7258 let url = params.parse_with_url(&url);
7259
7260 let mut json_mime_type = mime::APPLICATION_JSON;
7261 let mut request_value_reader = {
7262 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7263 common::remove_json_null_values(&mut value);
7264 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7265 serde_json::to_writer(&mut dst, &value).unwrap();
7266 dst
7267 };
7268 let request_size = request_value_reader
7269 .seek(std::io::SeekFrom::End(0))
7270 .unwrap();
7271 request_value_reader
7272 .seek(std::io::SeekFrom::Start(0))
7273 .unwrap();
7274
7275 loop {
7276 let token = match self
7277 .hub
7278 .auth
7279 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7280 .await
7281 {
7282 Ok(token) => token,
7283 Err(e) => match dlg.token(e) {
7284 Ok(token) => token,
7285 Err(e) => {
7286 dlg.finished(false);
7287 return Err(common::Error::MissingToken(e));
7288 }
7289 },
7290 };
7291 request_value_reader
7292 .seek(std::io::SeekFrom::Start(0))
7293 .unwrap();
7294 let mut req_result = {
7295 let client = &self.hub.client;
7296 dlg.pre_request();
7297 let mut req_builder = hyper::Request::builder()
7298 .method(hyper::Method::POST)
7299 .uri(url.as_str())
7300 .header(USER_AGENT, self.hub._user_agent.clone());
7301
7302 if let Some(token) = token.as_ref() {
7303 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7304 }
7305
7306 let request = req_builder
7307 .header(CONTENT_TYPE, json_mime_type.to_string())
7308 .header(CONTENT_LENGTH, request_size as u64)
7309 .body(common::to_body(
7310 request_value_reader.get_ref().clone().into(),
7311 ));
7312
7313 client.request(request.unwrap()).await
7314 };
7315
7316 match req_result {
7317 Err(err) => {
7318 if let common::Retry::After(d) = dlg.http_error(&err) {
7319 sleep(d).await;
7320 continue;
7321 }
7322 dlg.finished(false);
7323 return Err(common::Error::HttpError(err));
7324 }
7325 Ok(res) => {
7326 let (mut parts, body) = res.into_parts();
7327 let mut body = common::Body::new(body);
7328 if !parts.status.is_success() {
7329 let bytes = common::to_bytes(body).await.unwrap_or_default();
7330 let error = serde_json::from_str(&common::to_string(&bytes));
7331 let response = common::to_response(parts, bytes.into());
7332
7333 if let common::Retry::After(d) =
7334 dlg.http_failure(&response, error.as_ref().ok())
7335 {
7336 sleep(d).await;
7337 continue;
7338 }
7339
7340 dlg.finished(false);
7341
7342 return Err(match error {
7343 Ok(value) => common::Error::BadRequest(value),
7344 _ => common::Error::Failure(response),
7345 });
7346 }
7347 let response = {
7348 let bytes = common::to_bytes(body).await.unwrap_or_default();
7349 let encoded = common::to_string(&bytes);
7350 match serde_json::from_str(&encoded) {
7351 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7352 Err(error) => {
7353 dlg.response_json_decode_error(&encoded, &error);
7354 return Err(common::Error::JsonDecodeError(
7355 encoded.to_string(),
7356 error,
7357 ));
7358 }
7359 }
7360 };
7361
7362 dlg.finished(true);
7363 return Ok(response);
7364 }
7365 }
7366 }
7367 }
7368
7369 ///
7370 /// Sets the *request* property to the given value.
7371 ///
7372 /// Even though the property as already been set when instantiating this call,
7373 /// we provide this method for API completeness.
7374 pub fn request(
7375 mut self,
7376 new_value: GetIamPolicyRequest,
7377 ) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7378 self._request = new_value;
7379 self
7380 }
7381 /// 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.
7382 ///
7383 /// Sets the *resource* path property to the given value.
7384 ///
7385 /// Even though the property as already been set when instantiating this call,
7386 /// we provide this method for API completeness.
7387 pub fn resource(mut self, new_value: &str) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7388 self._resource = new_value.to_string();
7389 self
7390 }
7391 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7392 /// while executing the actual API request.
7393 ///
7394 /// ````text
7395 /// It should be used to handle progress information, and to implement a certain level of resilience.
7396 /// ````
7397 ///
7398 /// Sets the *delegate* property to the given value.
7399 pub fn delegate(
7400 mut self,
7401 new_value: &'a mut dyn common::Delegate,
7402 ) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7403 self._delegate = Some(new_value);
7404 self
7405 }
7406
7407 /// Set any additional parameter of the query string used in the request.
7408 /// It should be used to set parameters which are not yet available through their own
7409 /// setters.
7410 ///
7411 /// Please note that this method must not be used to set any of the known parameters
7412 /// which have their own setter method. If done anyway, the request will fail.
7413 ///
7414 /// # Additional Parameters
7415 ///
7416 /// * *$.xgafv* (query-string) - V1 error format.
7417 /// * *access_token* (query-string) - OAuth access token.
7418 /// * *alt* (query-string) - Data format for response.
7419 /// * *callback* (query-string) - JSONP
7420 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7421 /// * *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.
7422 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7423 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7424 /// * *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.
7425 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7426 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7427 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7428 where
7429 T: AsRef<str>,
7430 {
7431 self._additional_params
7432 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7433 self
7434 }
7435
7436 /// Identifies the authorization scope for the method you are building.
7437 ///
7438 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7439 /// [`Scope::CloudPlatform`].
7440 ///
7441 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7442 /// tokens for more than one scope.
7443 ///
7444 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7445 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7446 /// sufficient, a read-write scope will do as well.
7447 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7448 where
7449 St: AsRef<str>,
7450 {
7451 self._scopes.insert(String::from(scope.as_ref()));
7452 self
7453 }
7454 /// Identifies the authorization scope(s) for the method you are building.
7455 ///
7456 /// See [`Self::add_scope()`] for details.
7457 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryGetIamPolicyCall<'a, C>
7458 where
7459 I: IntoIterator<Item = St>,
7460 St: AsRef<str>,
7461 {
7462 self._scopes
7463 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7464 self
7465 }
7466
7467 /// Removes all scopes, and no default scope will be used either.
7468 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7469 /// for details).
7470 pub fn clear_scopes(mut self) -> ProjectLocationRegistryGetIamPolicyCall<'a, C> {
7471 self._scopes.clear();
7472 self
7473 }
7474}
7475
7476/// Lists device registries.
7477///
7478/// A builder for the *locations.registries.list* method supported by a *project* resource.
7479/// It is not used directly, but through a [`ProjectMethods`] instance.
7480///
7481/// # Example
7482///
7483/// Instantiate a resource method builder
7484///
7485/// ```test_harness,no_run
7486/// # extern crate hyper;
7487/// # extern crate hyper_rustls;
7488/// # extern crate google_cloudiot1 as cloudiot1;
7489/// # async fn dox() {
7490/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7491///
7492/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7493/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7494/// # secret,
7495/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7496/// # ).build().await.unwrap();
7497///
7498/// # let client = hyper_util::client::legacy::Client::builder(
7499/// # hyper_util::rt::TokioExecutor::new()
7500/// # )
7501/// # .build(
7502/// # hyper_rustls::HttpsConnectorBuilder::new()
7503/// # .with_native_roots()
7504/// # .unwrap()
7505/// # .https_or_http()
7506/// # .enable_http1()
7507/// # .build()
7508/// # );
7509/// # let mut hub = CloudIot::new(client, auth);
7510/// // You can configure optional parameters by calling the respective setters at will, and
7511/// // execute the final call using `doit()`.
7512/// // Values shown here are possibly random and not representative !
7513/// let result = hub.projects().locations_registries_list("parent")
7514/// .page_token("sed")
7515/// .page_size(-70)
7516/// .doit().await;
7517/// # }
7518/// ```
7519pub struct ProjectLocationRegistryListCall<'a, C>
7520where
7521 C: 'a,
7522{
7523 hub: &'a CloudIot<C>,
7524 _parent: String,
7525 _page_token: Option<String>,
7526 _page_size: Option<i32>,
7527 _delegate: Option<&'a mut dyn common::Delegate>,
7528 _additional_params: HashMap<String, String>,
7529 _scopes: BTreeSet<String>,
7530}
7531
7532impl<'a, C> common::CallBuilder for ProjectLocationRegistryListCall<'a, C> {}
7533
7534impl<'a, C> ProjectLocationRegistryListCall<'a, C>
7535where
7536 C: common::Connector,
7537{
7538 /// Perform the operation you have build so far.
7539 pub async fn doit(
7540 mut self,
7541 ) -> common::Result<(common::Response, ListDeviceRegistriesResponse)> {
7542 use std::borrow::Cow;
7543 use std::io::{Read, Seek};
7544
7545 use common::{url::Params, ToParts};
7546 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7547
7548 let mut dd = common::DefaultDelegate;
7549 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7550 dlg.begin(common::MethodInfo {
7551 id: "cloudiot.projects.locations.registries.list",
7552 http_method: hyper::Method::GET,
7553 });
7554
7555 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
7556 if self._additional_params.contains_key(field) {
7557 dlg.finished(false);
7558 return Err(common::Error::FieldClash(field));
7559 }
7560 }
7561
7562 let mut params = Params::with_capacity(5 + self._additional_params.len());
7563 params.push("parent", self._parent);
7564 if let Some(value) = self._page_token.as_ref() {
7565 params.push("pageToken", value);
7566 }
7567 if let Some(value) = self._page_size.as_ref() {
7568 params.push("pageSize", value.to_string());
7569 }
7570
7571 params.extend(self._additional_params.iter());
7572
7573 params.push("alt", "json");
7574 let mut url = self.hub._base_url.clone() + "v1/{+parent}/registries";
7575 if self._scopes.is_empty() {
7576 self._scopes
7577 .insert(Scope::CloudPlatform.as_ref().to_string());
7578 }
7579
7580 #[allow(clippy::single_element_loop)]
7581 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7582 url = params.uri_replacement(url, param_name, find_this, true);
7583 }
7584 {
7585 let to_remove = ["parent"];
7586 params.remove_params(&to_remove);
7587 }
7588
7589 let url = params.parse_with_url(&url);
7590
7591 loop {
7592 let token = match self
7593 .hub
7594 .auth
7595 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7596 .await
7597 {
7598 Ok(token) => token,
7599 Err(e) => match dlg.token(e) {
7600 Ok(token) => token,
7601 Err(e) => {
7602 dlg.finished(false);
7603 return Err(common::Error::MissingToken(e));
7604 }
7605 },
7606 };
7607 let mut req_result = {
7608 let client = &self.hub.client;
7609 dlg.pre_request();
7610 let mut req_builder = hyper::Request::builder()
7611 .method(hyper::Method::GET)
7612 .uri(url.as_str())
7613 .header(USER_AGENT, self.hub._user_agent.clone());
7614
7615 if let Some(token) = token.as_ref() {
7616 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7617 }
7618
7619 let request = req_builder
7620 .header(CONTENT_LENGTH, 0_u64)
7621 .body(common::to_body::<String>(None));
7622
7623 client.request(request.unwrap()).await
7624 };
7625
7626 match req_result {
7627 Err(err) => {
7628 if let common::Retry::After(d) = dlg.http_error(&err) {
7629 sleep(d).await;
7630 continue;
7631 }
7632 dlg.finished(false);
7633 return Err(common::Error::HttpError(err));
7634 }
7635 Ok(res) => {
7636 let (mut parts, body) = res.into_parts();
7637 let mut body = common::Body::new(body);
7638 if !parts.status.is_success() {
7639 let bytes = common::to_bytes(body).await.unwrap_or_default();
7640 let error = serde_json::from_str(&common::to_string(&bytes));
7641 let response = common::to_response(parts, bytes.into());
7642
7643 if let common::Retry::After(d) =
7644 dlg.http_failure(&response, error.as_ref().ok())
7645 {
7646 sleep(d).await;
7647 continue;
7648 }
7649
7650 dlg.finished(false);
7651
7652 return Err(match error {
7653 Ok(value) => common::Error::BadRequest(value),
7654 _ => common::Error::Failure(response),
7655 });
7656 }
7657 let response = {
7658 let bytes = common::to_bytes(body).await.unwrap_or_default();
7659 let encoded = common::to_string(&bytes);
7660 match serde_json::from_str(&encoded) {
7661 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7662 Err(error) => {
7663 dlg.response_json_decode_error(&encoded, &error);
7664 return Err(common::Error::JsonDecodeError(
7665 encoded.to_string(),
7666 error,
7667 ));
7668 }
7669 }
7670 };
7671
7672 dlg.finished(true);
7673 return Ok(response);
7674 }
7675 }
7676 }
7677 }
7678
7679 /// Required. The project and cloud region path. For example, `projects/example-project/locations/us-central1`.
7680 ///
7681 /// Sets the *parent* path property to the given value.
7682 ///
7683 /// Even though the property as already been set when instantiating this call,
7684 /// we provide this method for API completeness.
7685 pub fn parent(mut self, new_value: &str) -> ProjectLocationRegistryListCall<'a, C> {
7686 self._parent = new_value.to_string();
7687 self
7688 }
7689 /// 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.
7690 ///
7691 /// Sets the *page token* query property to the given value.
7692 pub fn page_token(mut self, new_value: &str) -> ProjectLocationRegistryListCall<'a, C> {
7693 self._page_token = Some(new_value.to_string());
7694 self
7695 }
7696 /// 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.
7697 ///
7698 /// Sets the *page size* query property to the given value.
7699 pub fn page_size(mut self, new_value: i32) -> ProjectLocationRegistryListCall<'a, C> {
7700 self._page_size = Some(new_value);
7701 self
7702 }
7703 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7704 /// while executing the actual API request.
7705 ///
7706 /// ````text
7707 /// It should be used to handle progress information, and to implement a certain level of resilience.
7708 /// ````
7709 ///
7710 /// Sets the *delegate* property to the given value.
7711 pub fn delegate(
7712 mut self,
7713 new_value: &'a mut dyn common::Delegate,
7714 ) -> ProjectLocationRegistryListCall<'a, C> {
7715 self._delegate = Some(new_value);
7716 self
7717 }
7718
7719 /// Set any additional parameter of the query string used in the request.
7720 /// It should be used to set parameters which are not yet available through their own
7721 /// setters.
7722 ///
7723 /// Please note that this method must not be used to set any of the known parameters
7724 /// which have their own setter method. If done anyway, the request will fail.
7725 ///
7726 /// # Additional Parameters
7727 ///
7728 /// * *$.xgafv* (query-string) - V1 error format.
7729 /// * *access_token* (query-string) - OAuth access token.
7730 /// * *alt* (query-string) - Data format for response.
7731 /// * *callback* (query-string) - JSONP
7732 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7733 /// * *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.
7734 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7735 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7736 /// * *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.
7737 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7738 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7739 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryListCall<'a, C>
7740 where
7741 T: AsRef<str>,
7742 {
7743 self._additional_params
7744 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7745 self
7746 }
7747
7748 /// Identifies the authorization scope for the method you are building.
7749 ///
7750 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7751 /// [`Scope::CloudPlatform`].
7752 ///
7753 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7754 /// tokens for more than one scope.
7755 ///
7756 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7757 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7758 /// sufficient, a read-write scope will do as well.
7759 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryListCall<'a, C>
7760 where
7761 St: AsRef<str>,
7762 {
7763 self._scopes.insert(String::from(scope.as_ref()));
7764 self
7765 }
7766 /// Identifies the authorization scope(s) for the method you are building.
7767 ///
7768 /// See [`Self::add_scope()`] for details.
7769 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryListCall<'a, C>
7770 where
7771 I: IntoIterator<Item = St>,
7772 St: AsRef<str>,
7773 {
7774 self._scopes
7775 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7776 self
7777 }
7778
7779 /// Removes all scopes, and no default scope will be used either.
7780 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7781 /// for details).
7782 pub fn clear_scopes(mut self) -> ProjectLocationRegistryListCall<'a, C> {
7783 self._scopes.clear();
7784 self
7785 }
7786}
7787
7788/// Updates a device registry configuration.
7789///
7790/// A builder for the *locations.registries.patch* method supported by a *project* resource.
7791/// It is not used directly, but through a [`ProjectMethods`] instance.
7792///
7793/// # Example
7794///
7795/// Instantiate a resource method builder
7796///
7797/// ```test_harness,no_run
7798/// # extern crate hyper;
7799/// # extern crate hyper_rustls;
7800/// # extern crate google_cloudiot1 as cloudiot1;
7801/// use cloudiot1::api::DeviceRegistry;
7802/// # async fn dox() {
7803/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7804///
7805/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7806/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7807/// # secret,
7808/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7809/// # ).build().await.unwrap();
7810///
7811/// # let client = hyper_util::client::legacy::Client::builder(
7812/// # hyper_util::rt::TokioExecutor::new()
7813/// # )
7814/// # .build(
7815/// # hyper_rustls::HttpsConnectorBuilder::new()
7816/// # .with_native_roots()
7817/// # .unwrap()
7818/// # .https_or_http()
7819/// # .enable_http1()
7820/// # .build()
7821/// # );
7822/// # let mut hub = CloudIot::new(client, auth);
7823/// // As the method needs a request, you would usually fill it with the desired information
7824/// // into the respective structure. Some of the parts shown here might not be applicable !
7825/// // Values shown here are possibly random and not representative !
7826/// let mut req = DeviceRegistry::default();
7827///
7828/// // You can configure optional parameters by calling the respective setters at will, and
7829/// // execute the final call using `doit()`.
7830/// // Values shown here are possibly random and not representative !
7831/// let result = hub.projects().locations_registries_patch(req, "name")
7832/// .update_mask(FieldMask::new::<&str>(&[]))
7833/// .doit().await;
7834/// # }
7835/// ```
7836pub struct ProjectLocationRegistryPatchCall<'a, C>
7837where
7838 C: 'a,
7839{
7840 hub: &'a CloudIot<C>,
7841 _request: DeviceRegistry,
7842 _name: String,
7843 _update_mask: Option<common::FieldMask>,
7844 _delegate: Option<&'a mut dyn common::Delegate>,
7845 _additional_params: HashMap<String, String>,
7846 _scopes: BTreeSet<String>,
7847}
7848
7849impl<'a, C> common::CallBuilder for ProjectLocationRegistryPatchCall<'a, C> {}
7850
7851impl<'a, C> ProjectLocationRegistryPatchCall<'a, C>
7852where
7853 C: common::Connector,
7854{
7855 /// Perform the operation you have build so far.
7856 pub async fn doit(mut self) -> common::Result<(common::Response, DeviceRegistry)> {
7857 use std::borrow::Cow;
7858 use std::io::{Read, Seek};
7859
7860 use common::{url::Params, ToParts};
7861 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7862
7863 let mut dd = common::DefaultDelegate;
7864 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7865 dlg.begin(common::MethodInfo {
7866 id: "cloudiot.projects.locations.registries.patch",
7867 http_method: hyper::Method::PATCH,
7868 });
7869
7870 for &field in ["alt", "name", "updateMask"].iter() {
7871 if self._additional_params.contains_key(field) {
7872 dlg.finished(false);
7873 return Err(common::Error::FieldClash(field));
7874 }
7875 }
7876
7877 let mut params = Params::with_capacity(5 + self._additional_params.len());
7878 params.push("name", self._name);
7879 if let Some(value) = self._update_mask.as_ref() {
7880 params.push("updateMask", value.to_string());
7881 }
7882
7883 params.extend(self._additional_params.iter());
7884
7885 params.push("alt", "json");
7886 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7887 if self._scopes.is_empty() {
7888 self._scopes
7889 .insert(Scope::CloudPlatform.as_ref().to_string());
7890 }
7891
7892 #[allow(clippy::single_element_loop)]
7893 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7894 url = params.uri_replacement(url, param_name, find_this, true);
7895 }
7896 {
7897 let to_remove = ["name"];
7898 params.remove_params(&to_remove);
7899 }
7900
7901 let url = params.parse_with_url(&url);
7902
7903 let mut json_mime_type = mime::APPLICATION_JSON;
7904 let mut request_value_reader = {
7905 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7906 common::remove_json_null_values(&mut value);
7907 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7908 serde_json::to_writer(&mut dst, &value).unwrap();
7909 dst
7910 };
7911 let request_size = request_value_reader
7912 .seek(std::io::SeekFrom::End(0))
7913 .unwrap();
7914 request_value_reader
7915 .seek(std::io::SeekFrom::Start(0))
7916 .unwrap();
7917
7918 loop {
7919 let token = match self
7920 .hub
7921 .auth
7922 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7923 .await
7924 {
7925 Ok(token) => token,
7926 Err(e) => match dlg.token(e) {
7927 Ok(token) => token,
7928 Err(e) => {
7929 dlg.finished(false);
7930 return Err(common::Error::MissingToken(e));
7931 }
7932 },
7933 };
7934 request_value_reader
7935 .seek(std::io::SeekFrom::Start(0))
7936 .unwrap();
7937 let mut req_result = {
7938 let client = &self.hub.client;
7939 dlg.pre_request();
7940 let mut req_builder = hyper::Request::builder()
7941 .method(hyper::Method::PATCH)
7942 .uri(url.as_str())
7943 .header(USER_AGENT, self.hub._user_agent.clone());
7944
7945 if let Some(token) = token.as_ref() {
7946 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7947 }
7948
7949 let request = req_builder
7950 .header(CONTENT_TYPE, json_mime_type.to_string())
7951 .header(CONTENT_LENGTH, request_size as u64)
7952 .body(common::to_body(
7953 request_value_reader.get_ref().clone().into(),
7954 ));
7955
7956 client.request(request.unwrap()).await
7957 };
7958
7959 match req_result {
7960 Err(err) => {
7961 if let common::Retry::After(d) = dlg.http_error(&err) {
7962 sleep(d).await;
7963 continue;
7964 }
7965 dlg.finished(false);
7966 return Err(common::Error::HttpError(err));
7967 }
7968 Ok(res) => {
7969 let (mut parts, body) = res.into_parts();
7970 let mut body = common::Body::new(body);
7971 if !parts.status.is_success() {
7972 let bytes = common::to_bytes(body).await.unwrap_or_default();
7973 let error = serde_json::from_str(&common::to_string(&bytes));
7974 let response = common::to_response(parts, bytes.into());
7975
7976 if let common::Retry::After(d) =
7977 dlg.http_failure(&response, error.as_ref().ok())
7978 {
7979 sleep(d).await;
7980 continue;
7981 }
7982
7983 dlg.finished(false);
7984
7985 return Err(match error {
7986 Ok(value) => common::Error::BadRequest(value),
7987 _ => common::Error::Failure(response),
7988 });
7989 }
7990 let response = {
7991 let bytes = common::to_bytes(body).await.unwrap_or_default();
7992 let encoded = common::to_string(&bytes);
7993 match serde_json::from_str(&encoded) {
7994 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7995 Err(error) => {
7996 dlg.response_json_decode_error(&encoded, &error);
7997 return Err(common::Error::JsonDecodeError(
7998 encoded.to_string(),
7999 error,
8000 ));
8001 }
8002 }
8003 };
8004
8005 dlg.finished(true);
8006 return Ok(response);
8007 }
8008 }
8009 }
8010 }
8011
8012 ///
8013 /// Sets the *request* property to the given value.
8014 ///
8015 /// Even though the property as already been set when instantiating this call,
8016 /// we provide this method for API completeness.
8017 pub fn request(mut self, new_value: DeviceRegistry) -> ProjectLocationRegistryPatchCall<'a, C> {
8018 self._request = new_value;
8019 self
8020 }
8021 /// The resource path name. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
8022 ///
8023 /// Sets the *name* path property to the given value.
8024 ///
8025 /// Even though the property as already been set when instantiating this call,
8026 /// we provide this method for API completeness.
8027 pub fn name(mut self, new_value: &str) -> ProjectLocationRegistryPatchCall<'a, C> {
8028 self._name = new_value.to_string();
8029 self
8030 }
8031 /// 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`.
8032 ///
8033 /// Sets the *update mask* query property to the given value.
8034 pub fn update_mask(
8035 mut self,
8036 new_value: common::FieldMask,
8037 ) -> ProjectLocationRegistryPatchCall<'a, C> {
8038 self._update_mask = Some(new_value);
8039 self
8040 }
8041 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8042 /// while executing the actual API request.
8043 ///
8044 /// ````text
8045 /// It should be used to handle progress information, and to implement a certain level of resilience.
8046 /// ````
8047 ///
8048 /// Sets the *delegate* property to the given value.
8049 pub fn delegate(
8050 mut self,
8051 new_value: &'a mut dyn common::Delegate,
8052 ) -> ProjectLocationRegistryPatchCall<'a, C> {
8053 self._delegate = Some(new_value);
8054 self
8055 }
8056
8057 /// Set any additional parameter of the query string used in the request.
8058 /// It should be used to set parameters which are not yet available through their own
8059 /// setters.
8060 ///
8061 /// Please note that this method must not be used to set any of the known parameters
8062 /// which have their own setter method. If done anyway, the request will fail.
8063 ///
8064 /// # Additional Parameters
8065 ///
8066 /// * *$.xgafv* (query-string) - V1 error format.
8067 /// * *access_token* (query-string) - OAuth access token.
8068 /// * *alt* (query-string) - Data format for response.
8069 /// * *callback* (query-string) - JSONP
8070 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8071 /// * *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.
8072 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8073 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8074 /// * *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.
8075 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8076 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8077 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistryPatchCall<'a, C>
8078 where
8079 T: AsRef<str>,
8080 {
8081 self._additional_params
8082 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8083 self
8084 }
8085
8086 /// Identifies the authorization scope for the method you are building.
8087 ///
8088 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8089 /// [`Scope::CloudPlatform`].
8090 ///
8091 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8092 /// tokens for more than one scope.
8093 ///
8094 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8095 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8096 /// sufficient, a read-write scope will do as well.
8097 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryPatchCall<'a, C>
8098 where
8099 St: AsRef<str>,
8100 {
8101 self._scopes.insert(String::from(scope.as_ref()));
8102 self
8103 }
8104 /// Identifies the authorization scope(s) for the method you are building.
8105 ///
8106 /// See [`Self::add_scope()`] for details.
8107 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistryPatchCall<'a, C>
8108 where
8109 I: IntoIterator<Item = St>,
8110 St: AsRef<str>,
8111 {
8112 self._scopes
8113 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8114 self
8115 }
8116
8117 /// Removes all scopes, and no default scope will be used either.
8118 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8119 /// for details).
8120 pub fn clear_scopes(mut self) -> ProjectLocationRegistryPatchCall<'a, C> {
8121 self._scopes.clear();
8122 self
8123 }
8124}
8125
8126/// Sets the access control policy on the specified resource. Replaces any existing policy.
8127///
8128/// A builder for the *locations.registries.setIamPolicy* method supported by a *project* resource.
8129/// It is not used directly, but through a [`ProjectMethods`] instance.
8130///
8131/// # Example
8132///
8133/// Instantiate a resource method builder
8134///
8135/// ```test_harness,no_run
8136/// # extern crate hyper;
8137/// # extern crate hyper_rustls;
8138/// # extern crate google_cloudiot1 as cloudiot1;
8139/// use cloudiot1::api::SetIamPolicyRequest;
8140/// # async fn dox() {
8141/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8142///
8143/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8144/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8145/// # secret,
8146/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8147/// # ).build().await.unwrap();
8148///
8149/// # let client = hyper_util::client::legacy::Client::builder(
8150/// # hyper_util::rt::TokioExecutor::new()
8151/// # )
8152/// # .build(
8153/// # hyper_rustls::HttpsConnectorBuilder::new()
8154/// # .with_native_roots()
8155/// # .unwrap()
8156/// # .https_or_http()
8157/// # .enable_http1()
8158/// # .build()
8159/// # );
8160/// # let mut hub = CloudIot::new(client, auth);
8161/// // As the method needs a request, you would usually fill it with the desired information
8162/// // into the respective structure. Some of the parts shown here might not be applicable !
8163/// // Values shown here are possibly random and not representative !
8164/// let mut req = SetIamPolicyRequest::default();
8165///
8166/// // You can configure optional parameters by calling the respective setters at will, and
8167/// // execute the final call using `doit()`.
8168/// // Values shown here are possibly random and not representative !
8169/// let result = hub.projects().locations_registries_set_iam_policy(req, "resource")
8170/// .doit().await;
8171/// # }
8172/// ```
8173pub struct ProjectLocationRegistrySetIamPolicyCall<'a, C>
8174where
8175 C: 'a,
8176{
8177 hub: &'a CloudIot<C>,
8178 _request: SetIamPolicyRequest,
8179 _resource: String,
8180 _delegate: Option<&'a mut dyn common::Delegate>,
8181 _additional_params: HashMap<String, String>,
8182 _scopes: BTreeSet<String>,
8183}
8184
8185impl<'a, C> common::CallBuilder for ProjectLocationRegistrySetIamPolicyCall<'a, C> {}
8186
8187impl<'a, C> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8188where
8189 C: common::Connector,
8190{
8191 /// Perform the operation you have build so far.
8192 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8193 use std::borrow::Cow;
8194 use std::io::{Read, Seek};
8195
8196 use common::{url::Params, ToParts};
8197 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8198
8199 let mut dd = common::DefaultDelegate;
8200 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8201 dlg.begin(common::MethodInfo {
8202 id: "cloudiot.projects.locations.registries.setIamPolicy",
8203 http_method: hyper::Method::POST,
8204 });
8205
8206 for &field in ["alt", "resource"].iter() {
8207 if self._additional_params.contains_key(field) {
8208 dlg.finished(false);
8209 return Err(common::Error::FieldClash(field));
8210 }
8211 }
8212
8213 let mut params = Params::with_capacity(4 + self._additional_params.len());
8214 params.push("resource", self._resource);
8215
8216 params.extend(self._additional_params.iter());
8217
8218 params.push("alt", "json");
8219 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8220 if self._scopes.is_empty() {
8221 self._scopes
8222 .insert(Scope::CloudPlatform.as_ref().to_string());
8223 }
8224
8225 #[allow(clippy::single_element_loop)]
8226 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8227 url = params.uri_replacement(url, param_name, find_this, true);
8228 }
8229 {
8230 let to_remove = ["resource"];
8231 params.remove_params(&to_remove);
8232 }
8233
8234 let url = params.parse_with_url(&url);
8235
8236 let mut json_mime_type = mime::APPLICATION_JSON;
8237 let mut request_value_reader = {
8238 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8239 common::remove_json_null_values(&mut value);
8240 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8241 serde_json::to_writer(&mut dst, &value).unwrap();
8242 dst
8243 };
8244 let request_size = request_value_reader
8245 .seek(std::io::SeekFrom::End(0))
8246 .unwrap();
8247 request_value_reader
8248 .seek(std::io::SeekFrom::Start(0))
8249 .unwrap();
8250
8251 loop {
8252 let token = match self
8253 .hub
8254 .auth
8255 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8256 .await
8257 {
8258 Ok(token) => token,
8259 Err(e) => match dlg.token(e) {
8260 Ok(token) => token,
8261 Err(e) => {
8262 dlg.finished(false);
8263 return Err(common::Error::MissingToken(e));
8264 }
8265 },
8266 };
8267 request_value_reader
8268 .seek(std::io::SeekFrom::Start(0))
8269 .unwrap();
8270 let mut req_result = {
8271 let client = &self.hub.client;
8272 dlg.pre_request();
8273 let mut req_builder = hyper::Request::builder()
8274 .method(hyper::Method::POST)
8275 .uri(url.as_str())
8276 .header(USER_AGENT, self.hub._user_agent.clone());
8277
8278 if let Some(token) = token.as_ref() {
8279 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8280 }
8281
8282 let request = req_builder
8283 .header(CONTENT_TYPE, json_mime_type.to_string())
8284 .header(CONTENT_LENGTH, request_size as u64)
8285 .body(common::to_body(
8286 request_value_reader.get_ref().clone().into(),
8287 ));
8288
8289 client.request(request.unwrap()).await
8290 };
8291
8292 match req_result {
8293 Err(err) => {
8294 if let common::Retry::After(d) = dlg.http_error(&err) {
8295 sleep(d).await;
8296 continue;
8297 }
8298 dlg.finished(false);
8299 return Err(common::Error::HttpError(err));
8300 }
8301 Ok(res) => {
8302 let (mut parts, body) = res.into_parts();
8303 let mut body = common::Body::new(body);
8304 if !parts.status.is_success() {
8305 let bytes = common::to_bytes(body).await.unwrap_or_default();
8306 let error = serde_json::from_str(&common::to_string(&bytes));
8307 let response = common::to_response(parts, bytes.into());
8308
8309 if let common::Retry::After(d) =
8310 dlg.http_failure(&response, error.as_ref().ok())
8311 {
8312 sleep(d).await;
8313 continue;
8314 }
8315
8316 dlg.finished(false);
8317
8318 return Err(match error {
8319 Ok(value) => common::Error::BadRequest(value),
8320 _ => common::Error::Failure(response),
8321 });
8322 }
8323 let response = {
8324 let bytes = common::to_bytes(body).await.unwrap_or_default();
8325 let encoded = common::to_string(&bytes);
8326 match serde_json::from_str(&encoded) {
8327 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8328 Err(error) => {
8329 dlg.response_json_decode_error(&encoded, &error);
8330 return Err(common::Error::JsonDecodeError(
8331 encoded.to_string(),
8332 error,
8333 ));
8334 }
8335 }
8336 };
8337
8338 dlg.finished(true);
8339 return Ok(response);
8340 }
8341 }
8342 }
8343 }
8344
8345 ///
8346 /// Sets the *request* property to the given value.
8347 ///
8348 /// Even though the property as already been set when instantiating this call,
8349 /// we provide this method for API completeness.
8350 pub fn request(
8351 mut self,
8352 new_value: SetIamPolicyRequest,
8353 ) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8354 self._request = new_value;
8355 self
8356 }
8357 /// 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.
8358 ///
8359 /// Sets the *resource* path property to the given value.
8360 ///
8361 /// Even though the property as already been set when instantiating this call,
8362 /// we provide this method for API completeness.
8363 pub fn resource(mut self, new_value: &str) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8364 self._resource = new_value.to_string();
8365 self
8366 }
8367 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8368 /// while executing the actual API request.
8369 ///
8370 /// ````text
8371 /// It should be used to handle progress information, and to implement a certain level of resilience.
8372 /// ````
8373 ///
8374 /// Sets the *delegate* property to the given value.
8375 pub fn delegate(
8376 mut self,
8377 new_value: &'a mut dyn common::Delegate,
8378 ) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8379 self._delegate = Some(new_value);
8380 self
8381 }
8382
8383 /// Set any additional parameter of the query string used in the request.
8384 /// It should be used to set parameters which are not yet available through their own
8385 /// setters.
8386 ///
8387 /// Please note that this method must not be used to set any of the known parameters
8388 /// which have their own setter method. If done anyway, the request will fail.
8389 ///
8390 /// # Additional Parameters
8391 ///
8392 /// * *$.xgafv* (query-string) - V1 error format.
8393 /// * *access_token* (query-string) - OAuth access token.
8394 /// * *alt* (query-string) - Data format for response.
8395 /// * *callback* (query-string) - JSONP
8396 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8397 /// * *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.
8398 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8399 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8400 /// * *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.
8401 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8402 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8403 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8404 where
8405 T: AsRef<str>,
8406 {
8407 self._additional_params
8408 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8409 self
8410 }
8411
8412 /// Identifies the authorization scope for the method you are building.
8413 ///
8414 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8415 /// [`Scope::CloudPlatform`].
8416 ///
8417 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8418 /// tokens for more than one scope.
8419 ///
8420 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8421 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8422 /// sufficient, a read-write scope will do as well.
8423 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8424 where
8425 St: AsRef<str>,
8426 {
8427 self._scopes.insert(String::from(scope.as_ref()));
8428 self
8429 }
8430 /// Identifies the authorization scope(s) for the method you are building.
8431 ///
8432 /// See [`Self::add_scope()`] for details.
8433 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRegistrySetIamPolicyCall<'a, C>
8434 where
8435 I: IntoIterator<Item = St>,
8436 St: AsRef<str>,
8437 {
8438 self._scopes
8439 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8440 self
8441 }
8442
8443 /// Removes all scopes, and no default scope will be used either.
8444 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8445 /// for details).
8446 pub fn clear_scopes(mut self) -> ProjectLocationRegistrySetIamPolicyCall<'a, C> {
8447 self._scopes.clear();
8448 self
8449 }
8450}
8451
8452/// 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.
8453///
8454/// A builder for the *locations.registries.testIamPermissions* method supported by a *project* resource.
8455/// It is not used directly, but through a [`ProjectMethods`] instance.
8456///
8457/// # Example
8458///
8459/// Instantiate a resource method builder
8460///
8461/// ```test_harness,no_run
8462/// # extern crate hyper;
8463/// # extern crate hyper_rustls;
8464/// # extern crate google_cloudiot1 as cloudiot1;
8465/// use cloudiot1::api::TestIamPermissionsRequest;
8466/// # async fn dox() {
8467/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8468///
8469/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8470/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8471/// # secret,
8472/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8473/// # ).build().await.unwrap();
8474///
8475/// # let client = hyper_util::client::legacy::Client::builder(
8476/// # hyper_util::rt::TokioExecutor::new()
8477/// # )
8478/// # .build(
8479/// # hyper_rustls::HttpsConnectorBuilder::new()
8480/// # .with_native_roots()
8481/// # .unwrap()
8482/// # .https_or_http()
8483/// # .enable_http1()
8484/// # .build()
8485/// # );
8486/// # let mut hub = CloudIot::new(client, auth);
8487/// // As the method needs a request, you would usually fill it with the desired information
8488/// // into the respective structure. Some of the parts shown here might not be applicable !
8489/// // Values shown here are possibly random and not representative !
8490/// let mut req = TestIamPermissionsRequest::default();
8491///
8492/// // You can configure optional parameters by calling the respective setters at will, and
8493/// // execute the final call using `doit()`.
8494/// // Values shown here are possibly random and not representative !
8495/// let result = hub.projects().locations_registries_test_iam_permissions(req, "resource")
8496/// .doit().await;
8497/// # }
8498/// ```
8499pub struct ProjectLocationRegistryTestIamPermissionCall<'a, C>
8500where
8501 C: 'a,
8502{
8503 hub: &'a CloudIot<C>,
8504 _request: TestIamPermissionsRequest,
8505 _resource: String,
8506 _delegate: Option<&'a mut dyn common::Delegate>,
8507 _additional_params: HashMap<String, String>,
8508 _scopes: BTreeSet<String>,
8509}
8510
8511impl<'a, C> common::CallBuilder for ProjectLocationRegistryTestIamPermissionCall<'a, C> {}
8512
8513impl<'a, C> ProjectLocationRegistryTestIamPermissionCall<'a, C>
8514where
8515 C: common::Connector,
8516{
8517 /// Perform the operation you have build so far.
8518 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8519 use std::borrow::Cow;
8520 use std::io::{Read, Seek};
8521
8522 use common::{url::Params, ToParts};
8523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8524
8525 let mut dd = common::DefaultDelegate;
8526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8527 dlg.begin(common::MethodInfo {
8528 id: "cloudiot.projects.locations.registries.testIamPermissions",
8529 http_method: hyper::Method::POST,
8530 });
8531
8532 for &field in ["alt", "resource"].iter() {
8533 if self._additional_params.contains_key(field) {
8534 dlg.finished(false);
8535 return Err(common::Error::FieldClash(field));
8536 }
8537 }
8538
8539 let mut params = Params::with_capacity(4 + self._additional_params.len());
8540 params.push("resource", self._resource);
8541
8542 params.extend(self._additional_params.iter());
8543
8544 params.push("alt", "json");
8545 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
8546 if self._scopes.is_empty() {
8547 self._scopes
8548 .insert(Scope::CloudPlatform.as_ref().to_string());
8549 }
8550
8551 #[allow(clippy::single_element_loop)]
8552 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8553 url = params.uri_replacement(url, param_name, find_this, true);
8554 }
8555 {
8556 let to_remove = ["resource"];
8557 params.remove_params(&to_remove);
8558 }
8559
8560 let url = params.parse_with_url(&url);
8561
8562 let mut json_mime_type = mime::APPLICATION_JSON;
8563 let mut request_value_reader = {
8564 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8565 common::remove_json_null_values(&mut value);
8566 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8567 serde_json::to_writer(&mut dst, &value).unwrap();
8568 dst
8569 };
8570 let request_size = request_value_reader
8571 .seek(std::io::SeekFrom::End(0))
8572 .unwrap();
8573 request_value_reader
8574 .seek(std::io::SeekFrom::Start(0))
8575 .unwrap();
8576
8577 loop {
8578 let token = match self
8579 .hub
8580 .auth
8581 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8582 .await
8583 {
8584 Ok(token) => token,
8585 Err(e) => match dlg.token(e) {
8586 Ok(token) => token,
8587 Err(e) => {
8588 dlg.finished(false);
8589 return Err(common::Error::MissingToken(e));
8590 }
8591 },
8592 };
8593 request_value_reader
8594 .seek(std::io::SeekFrom::Start(0))
8595 .unwrap();
8596 let mut req_result = {
8597 let client = &self.hub.client;
8598 dlg.pre_request();
8599 let mut req_builder = hyper::Request::builder()
8600 .method(hyper::Method::POST)
8601 .uri(url.as_str())
8602 .header(USER_AGENT, self.hub._user_agent.clone());
8603
8604 if let Some(token) = token.as_ref() {
8605 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8606 }
8607
8608 let request = req_builder
8609 .header(CONTENT_TYPE, json_mime_type.to_string())
8610 .header(CONTENT_LENGTH, request_size as u64)
8611 .body(common::to_body(
8612 request_value_reader.get_ref().clone().into(),
8613 ));
8614
8615 client.request(request.unwrap()).await
8616 };
8617
8618 match req_result {
8619 Err(err) => {
8620 if let common::Retry::After(d) = dlg.http_error(&err) {
8621 sleep(d).await;
8622 continue;
8623 }
8624 dlg.finished(false);
8625 return Err(common::Error::HttpError(err));
8626 }
8627 Ok(res) => {
8628 let (mut parts, body) = res.into_parts();
8629 let mut body = common::Body::new(body);
8630 if !parts.status.is_success() {
8631 let bytes = common::to_bytes(body).await.unwrap_or_default();
8632 let error = serde_json::from_str(&common::to_string(&bytes));
8633 let response = common::to_response(parts, bytes.into());
8634
8635 if let common::Retry::After(d) =
8636 dlg.http_failure(&response, error.as_ref().ok())
8637 {
8638 sleep(d).await;
8639 continue;
8640 }
8641
8642 dlg.finished(false);
8643
8644 return Err(match error {
8645 Ok(value) => common::Error::BadRequest(value),
8646 _ => common::Error::Failure(response),
8647 });
8648 }
8649 let response = {
8650 let bytes = common::to_bytes(body).await.unwrap_or_default();
8651 let encoded = common::to_string(&bytes);
8652 match serde_json::from_str(&encoded) {
8653 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8654 Err(error) => {
8655 dlg.response_json_decode_error(&encoded, &error);
8656 return Err(common::Error::JsonDecodeError(
8657 encoded.to_string(),
8658 error,
8659 ));
8660 }
8661 }
8662 };
8663
8664 dlg.finished(true);
8665 return Ok(response);
8666 }
8667 }
8668 }
8669 }
8670
8671 ///
8672 /// Sets the *request* property to the given value.
8673 ///
8674 /// Even though the property as already been set when instantiating this call,
8675 /// we provide this method for API completeness.
8676 pub fn request(
8677 mut self,
8678 new_value: TestIamPermissionsRequest,
8679 ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
8680 self._request = new_value;
8681 self
8682 }
8683 /// 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.
8684 ///
8685 /// Sets the *resource* path property to the given value.
8686 ///
8687 /// Even though the property as already been set when instantiating this call,
8688 /// we provide this method for API completeness.
8689 pub fn resource(
8690 mut self,
8691 new_value: &str,
8692 ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
8693 self._resource = new_value.to_string();
8694 self
8695 }
8696 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8697 /// while executing the actual API request.
8698 ///
8699 /// ````text
8700 /// It should be used to handle progress information, and to implement a certain level of resilience.
8701 /// ````
8702 ///
8703 /// Sets the *delegate* property to the given value.
8704 pub fn delegate(
8705 mut self,
8706 new_value: &'a mut dyn common::Delegate,
8707 ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
8708 self._delegate = Some(new_value);
8709 self
8710 }
8711
8712 /// Set any additional parameter of the query string used in the request.
8713 /// It should be used to set parameters which are not yet available through their own
8714 /// setters.
8715 ///
8716 /// Please note that this method must not be used to set any of the known parameters
8717 /// which have their own setter method. If done anyway, the request will fail.
8718 ///
8719 /// # Additional Parameters
8720 ///
8721 /// * *$.xgafv* (query-string) - V1 error format.
8722 /// * *access_token* (query-string) - OAuth access token.
8723 /// * *alt* (query-string) - Data format for response.
8724 /// * *callback* (query-string) - JSONP
8725 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8726 /// * *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.
8727 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8728 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8729 /// * *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.
8730 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8731 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8732 pub fn param<T>(
8733 mut self,
8734 name: T,
8735 value: T,
8736 ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C>
8737 where
8738 T: AsRef<str>,
8739 {
8740 self._additional_params
8741 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8742 self
8743 }
8744
8745 /// Identifies the authorization scope for the method you are building.
8746 ///
8747 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8748 /// [`Scope::CloudPlatform`].
8749 ///
8750 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8751 /// tokens for more than one scope.
8752 ///
8753 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8754 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8755 /// sufficient, a read-write scope will do as well.
8756 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRegistryTestIamPermissionCall<'a, C>
8757 where
8758 St: AsRef<str>,
8759 {
8760 self._scopes.insert(String::from(scope.as_ref()));
8761 self
8762 }
8763 /// Identifies the authorization scope(s) for the method you are building.
8764 ///
8765 /// See [`Self::add_scope()`] for details.
8766 pub fn add_scopes<I, St>(
8767 mut self,
8768 scopes: I,
8769 ) -> ProjectLocationRegistryTestIamPermissionCall<'a, C>
8770 where
8771 I: IntoIterator<Item = St>,
8772 St: AsRef<str>,
8773 {
8774 self._scopes
8775 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8776 self
8777 }
8778
8779 /// Removes all scopes, and no default scope will be used either.
8780 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8781 /// for details).
8782 pub fn clear_scopes(mut self) -> ProjectLocationRegistryTestIamPermissionCall<'a, C> {
8783 self._scopes.clear();
8784 self
8785 }
8786}
8787
8788/// Deletes the association between the device and the gateway.
8789///
8790/// A builder for the *locations.registries.unbindDeviceFromGateway* method supported by a *project* resource.
8791/// It is not used directly, but through a [`ProjectMethods`] instance.
8792///
8793/// # Example
8794///
8795/// Instantiate a resource method builder
8796///
8797/// ```test_harness,no_run
8798/// # extern crate hyper;
8799/// # extern crate hyper_rustls;
8800/// # extern crate google_cloudiot1 as cloudiot1;
8801/// use cloudiot1::api::UnbindDeviceFromGatewayRequest;
8802/// # async fn dox() {
8803/// # use cloudiot1::{CloudIot, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8804///
8805/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8806/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8807/// # secret,
8808/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8809/// # ).build().await.unwrap();
8810///
8811/// # let client = hyper_util::client::legacy::Client::builder(
8812/// # hyper_util::rt::TokioExecutor::new()
8813/// # )
8814/// # .build(
8815/// # hyper_rustls::HttpsConnectorBuilder::new()
8816/// # .with_native_roots()
8817/// # .unwrap()
8818/// # .https_or_http()
8819/// # .enable_http1()
8820/// # .build()
8821/// # );
8822/// # let mut hub = CloudIot::new(client, auth);
8823/// // As the method needs a request, you would usually fill it with the desired information
8824/// // into the respective structure. Some of the parts shown here might not be applicable !
8825/// // Values shown here are possibly random and not representative !
8826/// let mut req = UnbindDeviceFromGatewayRequest::default();
8827///
8828/// // You can configure optional parameters by calling the respective setters at will, and
8829/// // execute the final call using `doit()`.
8830/// // Values shown here are possibly random and not representative !
8831/// let result = hub.projects().locations_registries_unbind_device_from_gateway(req, "parent")
8832/// .doit().await;
8833/// # }
8834/// ```
8835pub struct ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
8836where
8837 C: 'a,
8838{
8839 hub: &'a CloudIot<C>,
8840 _request: UnbindDeviceFromGatewayRequest,
8841 _parent: String,
8842 _delegate: Option<&'a mut dyn common::Delegate>,
8843 _additional_params: HashMap<String, String>,
8844 _scopes: BTreeSet<String>,
8845}
8846
8847impl<'a, C> common::CallBuilder for ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {}
8848
8849impl<'a, C> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
8850where
8851 C: common::Connector,
8852{
8853 /// Perform the operation you have build so far.
8854 pub async fn doit(
8855 mut self,
8856 ) -> common::Result<(common::Response, UnbindDeviceFromGatewayResponse)> {
8857 use std::borrow::Cow;
8858 use std::io::{Read, Seek};
8859
8860 use common::{url::Params, ToParts};
8861 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8862
8863 let mut dd = common::DefaultDelegate;
8864 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8865 dlg.begin(common::MethodInfo {
8866 id: "cloudiot.projects.locations.registries.unbindDeviceFromGateway",
8867 http_method: hyper::Method::POST,
8868 });
8869
8870 for &field in ["alt", "parent"].iter() {
8871 if self._additional_params.contains_key(field) {
8872 dlg.finished(false);
8873 return Err(common::Error::FieldClash(field));
8874 }
8875 }
8876
8877 let mut params = Params::with_capacity(4 + self._additional_params.len());
8878 params.push("parent", self._parent);
8879
8880 params.extend(self._additional_params.iter());
8881
8882 params.push("alt", "json");
8883 let mut url = self.hub._base_url.clone() + "v1/{+parent}:unbindDeviceFromGateway";
8884 if self._scopes.is_empty() {
8885 self._scopes
8886 .insert(Scope::CloudPlatform.as_ref().to_string());
8887 }
8888
8889 #[allow(clippy::single_element_loop)]
8890 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8891 url = params.uri_replacement(url, param_name, find_this, true);
8892 }
8893 {
8894 let to_remove = ["parent"];
8895 params.remove_params(&to_remove);
8896 }
8897
8898 let url = params.parse_with_url(&url);
8899
8900 let mut json_mime_type = mime::APPLICATION_JSON;
8901 let mut request_value_reader = {
8902 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8903 common::remove_json_null_values(&mut value);
8904 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8905 serde_json::to_writer(&mut dst, &value).unwrap();
8906 dst
8907 };
8908 let request_size = request_value_reader
8909 .seek(std::io::SeekFrom::End(0))
8910 .unwrap();
8911 request_value_reader
8912 .seek(std::io::SeekFrom::Start(0))
8913 .unwrap();
8914
8915 loop {
8916 let token = match self
8917 .hub
8918 .auth
8919 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8920 .await
8921 {
8922 Ok(token) => token,
8923 Err(e) => match dlg.token(e) {
8924 Ok(token) => token,
8925 Err(e) => {
8926 dlg.finished(false);
8927 return Err(common::Error::MissingToken(e));
8928 }
8929 },
8930 };
8931 request_value_reader
8932 .seek(std::io::SeekFrom::Start(0))
8933 .unwrap();
8934 let mut req_result = {
8935 let client = &self.hub.client;
8936 dlg.pre_request();
8937 let mut req_builder = hyper::Request::builder()
8938 .method(hyper::Method::POST)
8939 .uri(url.as_str())
8940 .header(USER_AGENT, self.hub._user_agent.clone());
8941
8942 if let Some(token) = token.as_ref() {
8943 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8944 }
8945
8946 let request = req_builder
8947 .header(CONTENT_TYPE, json_mime_type.to_string())
8948 .header(CONTENT_LENGTH, request_size as u64)
8949 .body(common::to_body(
8950 request_value_reader.get_ref().clone().into(),
8951 ));
8952
8953 client.request(request.unwrap()).await
8954 };
8955
8956 match req_result {
8957 Err(err) => {
8958 if let common::Retry::After(d) = dlg.http_error(&err) {
8959 sleep(d).await;
8960 continue;
8961 }
8962 dlg.finished(false);
8963 return Err(common::Error::HttpError(err));
8964 }
8965 Ok(res) => {
8966 let (mut parts, body) = res.into_parts();
8967 let mut body = common::Body::new(body);
8968 if !parts.status.is_success() {
8969 let bytes = common::to_bytes(body).await.unwrap_or_default();
8970 let error = serde_json::from_str(&common::to_string(&bytes));
8971 let response = common::to_response(parts, bytes.into());
8972
8973 if let common::Retry::After(d) =
8974 dlg.http_failure(&response, error.as_ref().ok())
8975 {
8976 sleep(d).await;
8977 continue;
8978 }
8979
8980 dlg.finished(false);
8981
8982 return Err(match error {
8983 Ok(value) => common::Error::BadRequest(value),
8984 _ => common::Error::Failure(response),
8985 });
8986 }
8987 let response = {
8988 let bytes = common::to_bytes(body).await.unwrap_or_default();
8989 let encoded = common::to_string(&bytes);
8990 match serde_json::from_str(&encoded) {
8991 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8992 Err(error) => {
8993 dlg.response_json_decode_error(&encoded, &error);
8994 return Err(common::Error::JsonDecodeError(
8995 encoded.to_string(),
8996 error,
8997 ));
8998 }
8999 }
9000 };
9001
9002 dlg.finished(true);
9003 return Ok(response);
9004 }
9005 }
9006 }
9007 }
9008
9009 ///
9010 /// Sets the *request* property to the given value.
9011 ///
9012 /// Even though the property as already been set when instantiating this call,
9013 /// we provide this method for API completeness.
9014 pub fn request(
9015 mut self,
9016 new_value: UnbindDeviceFromGatewayRequest,
9017 ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9018 self._request = new_value;
9019 self
9020 }
9021 /// Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.
9022 ///
9023 /// Sets the *parent* path property to the given value.
9024 ///
9025 /// Even though the property as already been set when instantiating this call,
9026 /// we provide this method for API completeness.
9027 pub fn parent(
9028 mut self,
9029 new_value: &str,
9030 ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9031 self._parent = new_value.to_string();
9032 self
9033 }
9034 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9035 /// while executing the actual API request.
9036 ///
9037 /// ````text
9038 /// It should be used to handle progress information, and to implement a certain level of resilience.
9039 /// ````
9040 ///
9041 /// Sets the *delegate* property to the given value.
9042 pub fn delegate(
9043 mut self,
9044 new_value: &'a mut dyn common::Delegate,
9045 ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9046 self._delegate = Some(new_value);
9047 self
9048 }
9049
9050 /// Set any additional parameter of the query string used in the request.
9051 /// It should be used to set parameters which are not yet available through their own
9052 /// setters.
9053 ///
9054 /// Please note that this method must not be used to set any of the known parameters
9055 /// which have their own setter method. If done anyway, the request will fail.
9056 ///
9057 /// # Additional Parameters
9058 ///
9059 /// * *$.xgafv* (query-string) - V1 error format.
9060 /// * *access_token* (query-string) - OAuth access token.
9061 /// * *alt* (query-string) - Data format for response.
9062 /// * *callback* (query-string) - JSONP
9063 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9064 /// * *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.
9065 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9066 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9067 /// * *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.
9068 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9069 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9070 pub fn param<T>(
9071 mut self,
9072 name: T,
9073 value: T,
9074 ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9075 where
9076 T: AsRef<str>,
9077 {
9078 self._additional_params
9079 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9080 self
9081 }
9082
9083 /// Identifies the authorization scope for the method you are building.
9084 ///
9085 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9086 /// [`Scope::CloudPlatform`].
9087 ///
9088 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9089 /// tokens for more than one scope.
9090 ///
9091 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9092 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9093 /// sufficient, a read-write scope will do as well.
9094 pub fn add_scope<St>(
9095 mut self,
9096 scope: St,
9097 ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9098 where
9099 St: AsRef<str>,
9100 {
9101 self._scopes.insert(String::from(scope.as_ref()));
9102 self
9103 }
9104 /// Identifies the authorization scope(s) for the method you are building.
9105 ///
9106 /// See [`Self::add_scope()`] for details.
9107 pub fn add_scopes<I, St>(
9108 mut self,
9109 scopes: I,
9110 ) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C>
9111 where
9112 I: IntoIterator<Item = St>,
9113 St: AsRef<str>,
9114 {
9115 self._scopes
9116 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9117 self
9118 }
9119
9120 /// Removes all scopes, and no default scope will be used either.
9121 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9122 /// for details).
9123 pub fn clear_scopes(mut self) -> ProjectLocationRegistryUnbindDeviceFromGatewayCall<'a, C> {
9124 self._scopes.clear();
9125 self
9126 }
9127}