google_androidmanagement1/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 /// Manage Android devices and apps for your customers
17 Full,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::Full => "https://www.googleapis.com/auth/androidmanagement",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::Full
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all AndroidManagement related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_androidmanagement1 as androidmanagement1;
49/// use androidmanagement1::api::Enterprise;
50/// use androidmanagement1::{Result, Error};
51/// # async fn dox() {
52/// use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = AndroidManagement::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Enterprise::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.enterprises().create(req)
88/// .signup_url_name("amet.")
89/// .project_id("takimata")
90/// .enterprise_token("amet.")
91/// .agreement_accepted(true)
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 AndroidManagement<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 AndroidManagement<C> {}
123
124impl<'a, C> AndroidManagement<C> {
125 pub fn new<A: 'static + common::GetToken>(
126 client: common::Client<C>,
127 auth: A,
128 ) -> AndroidManagement<C> {
129 AndroidManagement {
130 client,
131 auth: Box::new(auth),
132 _user_agent: "google-api-rust-client/6.0.0".to_string(),
133 _base_url: "https://androidmanagement.googleapis.com/".to_string(),
134 _root_url: "https://androidmanagement.googleapis.com/".to_string(),
135 }
136 }
137
138 pub fn enterprises(&'a self) -> EnterpriseMethods<'a, C> {
139 EnterpriseMethods { hub: self }
140 }
141 pub fn provisioning_info(&'a self) -> ProvisioningInfoMethods<'a, C> {
142 ProvisioningInfoMethods { hub: self }
143 }
144 pub fn signup_urls(&'a self) -> SignupUrlMethods<'a, C> {
145 SignupUrlMethods { hub: self }
146 }
147
148 /// Set the user-agent header field to use in all requests to the server.
149 /// It defaults to `google-api-rust-client/6.0.0`.
150 ///
151 /// Returns the previously set user-agent.
152 pub fn user_agent(&mut self, agent_name: String) -> String {
153 std::mem::replace(&mut self._user_agent, agent_name)
154 }
155
156 /// Set the base url to use in all requests to the server.
157 /// It defaults to `https://androidmanagement.googleapis.com/`.
158 ///
159 /// Returns the previously set base url.
160 pub fn base_url(&mut self, new_base_url: String) -> String {
161 std::mem::replace(&mut self._base_url, new_base_url)
162 }
163
164 /// Set the root url to use in all requests to the server.
165 /// It defaults to `https://androidmanagement.googleapis.com/`.
166 ///
167 /// Returns the previously set root url.
168 pub fn root_url(&mut self, new_root_url: String) -> String {
169 std::mem::replace(&mut self._root_url, new_root_url)
170 }
171}
172
173// ############
174// SCHEMAS ###
175// ##########
176/// Advanced security settings. In most cases, setting these is not needed.
177///
178/// This type is not used in any activity, and only used as *part* of another schema.
179///
180#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
181#[serde_with::serde_as]
182#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
183pub struct AdvancedSecurityOverrides {
184 /// Controls Common Criteria Mode—security standards defined in the Common Criteria for Information Technology Security Evaluation (https://www.commoncriteriaportal.org/) (CC). Enabling Common Criteria Mode increases certain security components on a device, including AES-GCM encryption of Bluetooth Long Term Keys, and Wi-Fi configuration stores.Warning: Common Criteria Mode enforces a strict security model typically only required for IT products used in national security systems and other highly sensitive organizations. Standard device use may be affected. Only enabled if required.
185 #[serde(rename = "commonCriteriaMode")]
186 pub common_criteria_mode: Option<String>,
187 /// Controls access to developer settings: developer options and safe boot. Replaces safeBootDisabled (deprecated) and debuggingFeaturesAllowed (deprecated).
188 #[serde(rename = "developerSettings")]
189 pub developer_settings: Option<String>,
190 /// Whether Google Play Protect verification (https://support.google.com/accounts/answer/2812853) is enforced. Replaces ensureVerifyAppsEnabled (deprecated).
191 #[serde(rename = "googlePlayProtectVerifyApps")]
192 pub google_play_protect_verify_apps: Option<String>,
193 /// Optional. Controls Memory Tagging Extension (MTE) (https://source.android.com/docs/security/test/memory-safety/arm-mte) on the device. The device needs to be rebooted to apply changes to the MTE policy.
194 #[serde(rename = "mtePolicy")]
195 pub mte_policy: Option<String>,
196 /// Personal apps that can read work profile notifications using a NotificationListenerService (https://developer.android.com/reference/android/service/notification/NotificationListenerService). By default, no personal apps (aside from system apps) can read work notifications. Each value in the list must be a package name.
197 #[serde(rename = "personalAppsThatCanReadWorkNotifications")]
198 pub personal_apps_that_can_read_work_notifications: Option<Vec<String>>,
199 /// The policy for untrusted apps (apps from unknown sources) enforced on the device. Replaces install_unknown_sources_allowed (deprecated).
200 #[serde(rename = "untrustedAppsPolicy")]
201 pub untrusted_apps_policy: Option<String>,
202}
203
204impl common::Part for AdvancedSecurityOverrides {}
205
206/// Configuration for an always-on VPN connection.
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 AlwaysOnVpnPackage {
214 /// Disallows networking when the VPN is not connected.
215 #[serde(rename = "lockdownEnabled")]
216 pub lockdown_enabled: Option<bool>,
217 /// The package name of the VPN app.
218 #[serde(rename = "packageName")]
219 pub package_name: Option<String>,
220}
221
222impl common::Part for AlwaysOnVpnPackage {}
223
224/// A compliance rule condition which is satisfied if the Android Framework API level on the device doesn't meet a minimum requirement. There can only be one rule with this type of condition per policy.
225///
226/// This type is not used in any activity, and only used as *part* of another schema.
227///
228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
229#[serde_with::serde_as]
230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
231pub struct ApiLevelCondition {
232 /// The minimum desired Android Framework API level. If the device doesn't meet the minimum requirement, this condition is satisfied. Must be greater than zero.
233 #[serde(rename = "minApiLevel")]
234 pub min_api_level: Option<i32>,
235}
236
237impl common::Part for ApiLevelCondition {}
238
239/// Id to name association of a app track.
240///
241/// This type is not used in any activity, and only used as *part* of another schema.
242///
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct AppTrackInfo {
247 /// The track name associated with the trackId, set in the Play Console. The name is modifiable from Play Console.
248 #[serde(rename = "trackAlias")]
249 pub track_alias: Option<String>,
250 /// The unmodifiable unique track identifier, taken from the releaseTrackId in the URL of the Play Console page that displays the app’s track information.
251 #[serde(rename = "trackId")]
252 pub track_id: Option<String>,
253}
254
255impl common::Part for AppTrackInfo {}
256
257/// This represents a single version of the app.
258///
259/// This type is not used in any activity, and only used as *part* of another schema.
260///
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct AppVersion {
265 /// If the value is True, it indicates that this version is a production track.
266 pub production: Option<bool>,
267 /// Track identifiers that the app version is published in. This does not include the production track (see production instead).
268 #[serde(rename = "trackIds")]
269 pub track_ids: Option<Vec<String>>,
270 /// Unique increasing identifier for the app version.
271 #[serde(rename = "versionCode")]
272 pub version_code: Option<i32>,
273 /// The string used in the Play store by the app developer to identify the version. The string is not necessarily unique or localized (for example, the string could be "1.4").
274 #[serde(rename = "versionString")]
275 pub version_string: Option<String>,
276}
277
278impl common::Part for AppVersion {}
279
280/// Information about an app.
281///
282/// # Activities
283///
284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
286///
287/// * [applications get enterprises](EnterpriseApplicationGetCall) (response)
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct Application {
292 /// Whether this app is free, free with in-app purchases, or paid. If the pricing is unspecified, this means the app is not generally available anymore (even though it might still be available to people who own it).
293 #[serde(rename = "appPricing")]
294 pub app_pricing: Option<String>,
295 /// Application tracks visible to the enterprise.
296 #[serde(rename = "appTracks")]
297 pub app_tracks: Option<Vec<AppTrackInfo>>,
298 /// Versions currently available for this app.
299 #[serde(rename = "appVersions")]
300 pub app_versions: Option<Vec<AppVersion>>,
301 /// The name of the author of the apps (for example, the app developer).
302 pub author: Option<String>,
303 /// The countries which this app is available in as per ISO 3166-1 alpha-2.
304 #[serde(rename = "availableCountries")]
305 pub available_countries: Option<Vec<String>>,
306 /// The app category (e.g. RACING, SOCIAL, etc.)
307 pub category: Option<String>,
308 /// The content rating for this app.
309 #[serde(rename = "contentRating")]
310 pub content_rating: Option<String>,
311 /// The localized promotional description, if available.
312 pub description: Option<String>,
313 /// How and to whom the package is made available.
314 #[serde(rename = "distributionChannel")]
315 pub distribution_channel: Option<String>,
316 /// Noteworthy features (if any) of this app.
317 pub features: Option<Vec<String>>,
318 /// Full app description, if available.
319 #[serde(rename = "fullDescription")]
320 pub full_description: Option<String>,
321 /// A link to an image that can be used as an icon for the app. This image is suitable for use up to a pixel size of 512 x 512.
322 #[serde(rename = "iconUrl")]
323 pub icon_url: Option<String>,
324 /// The set of managed properties available to be pre-configured for the app.
325 #[serde(rename = "managedProperties")]
326 pub managed_properties: Option<Vec<ManagedProperty>>,
327 /// The minimum Android SDK necessary to run the app.
328 #[serde(rename = "minAndroidSdkVersion")]
329 pub min_android_sdk_version: Option<i32>,
330 /// The name of the app in the form enterprises/{enterprise}/applications/{package_name}.
331 pub name: Option<String>,
332 /// The permissions required by the app.
333 pub permissions: Option<Vec<ApplicationPermission>>,
334 /// A link to the (consumer) Google Play details page for the app.
335 #[serde(rename = "playStoreUrl")]
336 pub play_store_url: Option<String>,
337 /// A localised description of the recent changes made to the app.
338 #[serde(rename = "recentChanges")]
339 pub recent_changes: Option<String>,
340 /// A list of screenshot links representing the app.
341 #[serde(rename = "screenshotUrls")]
342 pub screenshot_urls: Option<Vec<String>>,
343 /// A link to a smaller image that can be used as an icon for the app. This image is suitable for use up to a pixel size of 128 x 128.
344 #[serde(rename = "smallIconUrl")]
345 pub small_icon_url: Option<String>,
346 /// The title of the app. Localized.
347 pub title: Option<String>,
348 /// Output only. The approximate time (within 7 days) the app was last published.
349 #[serde(rename = "updateTime")]
350 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
351}
352
353impl common::ResponseResult for Application {}
354
355/// An app-related event.
356///
357/// This type is not used in any activity, and only used as *part* of another schema.
358///
359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
360#[serde_with::serde_as]
361#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
362pub struct ApplicationEvent {
363 /// The creation time of the event.
364 #[serde(rename = "createTime")]
365 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
366 /// App event type.
367 #[serde(rename = "eventType")]
368 pub event_type: Option<String>,
369}
370
371impl common::Part for ApplicationEvent {}
372
373/// A permission required by the app.
374///
375/// This type is not used in any activity, and only used as *part* of another schema.
376///
377#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
378#[serde_with::serde_as]
379#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
380pub struct ApplicationPermission {
381 /// A longer description of the permission, providing more detail on what it affects. Localized.
382 pub description: Option<String>,
383 /// The name of the permission. Localized.
384 pub name: Option<String>,
385 /// An opaque string uniquely identifying the permission. Not localized.
386 #[serde(rename = "permissionId")]
387 pub permission_id: Option<String>,
388}
389
390impl common::Part for ApplicationPermission {}
391
392/// Policy for an individual app. Note: Application availability on a given device cannot be changed using this policy if installAppsDisabled is enabled. The maximum number of applications that you can specify per policy is 3,000.
393///
394/// This type is not used in any activity, and only used as *part* of another schema.
395///
396#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
397#[serde_with::serde_as]
398#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
399pub struct ApplicationPolicy {
400 /// List of the app’s track IDs that a device belonging to the enterprise can access. If the list contains multiple track IDs, devices receive the latest version among all accessible tracks. If the list contains no track IDs, devices only have access to the app’s production track. More details about each track are available in AppTrackInfo.
401 #[serde(rename = "accessibleTrackIds")]
402 pub accessible_track_ids: Option<Vec<String>>,
403 /// Specifies whether the app is allowed networking when the VPN is not connected and alwaysOnVpnPackage.lockdownEnabled is enabled. If set to VPN_LOCKDOWN_ENFORCED, the app is not allowed networking, and if set to VPN_LOCKDOWN_EXEMPTION, the app is allowed networking. Only supported on devices running Android 10 and above. If this is not supported by the device, the device will contain a NonComplianceDetail with non_compliance_reason set to API_LEVEL and a fieldPath. If this is not applicable to the app, the device will contain a NonComplianceDetail with non_compliance_reason set to UNSUPPORTED and a fieldPath. The fieldPath is set to applications[i].alwaysOnVpnLockdownExemption, where i is the index of the package in the applications policy.
404 #[serde(rename = "alwaysOnVpnLockdownExemption")]
405 pub always_on_vpn_lockdown_exemption: Option<String>,
406 /// Controls the auto-update mode for the app.
407 #[serde(rename = "autoUpdateMode")]
408 pub auto_update_mode: Option<String>,
409 /// Controls whether the app can communicate with itself across a device’s work and personal profiles, subject to user consent.
410 #[serde(rename = "connectedWorkAndPersonalApp")]
411 pub connected_work_and_personal_app: Option<String>,
412 /// Optional. Whether the app is allowed to act as a credential provider on Android 14 and above.
413 #[serde(rename = "credentialProviderPolicy")]
414 pub credential_provider_policy: Option<String>,
415 /// The default policy for all permissions requested by the app. If specified, this overrides the policy-level default_permission_policy which applies to all apps. It does not override the permission_grants which applies to all apps.
416 #[serde(rename = "defaultPermissionPolicy")]
417 pub default_permission_policy: Option<String>,
418 /// The scopes delegated to the app from Android Device Policy. These provide additional privileges for the applications they are applied to.
419 #[serde(rename = "delegatedScopes")]
420 pub delegated_scopes: Option<Vec<String>>,
421 /// Whether the app is disabled. When disabled, the app data is still preserved.
422 pub disabled: Option<bool>,
423 /// Configuration to enable this app as an extension app, with the capability of interacting with Android Device Policy offline.This field can be set for at most one app.
424 #[serde(rename = "extensionConfig")]
425 pub extension_config: Option<ExtensionConfig>,
426 /// Optional. The constraints for installing the app. You can specify a maximum of one InstallConstraint. Multiple constraints are rejected.
427 #[serde(rename = "installConstraint")]
428 pub install_constraint: Option<Vec<InstallConstraint>>,
429 /// Optional. Amongst apps with installType set to: FORCE_INSTALLED PREINSTALLEDthis controls the relative priority of installation. A value of 0 (default) means this app has no priority over other apps. For values between 1 and 10,000, a lower value means a higher priority. Values outside of the range 0 to 10,000 inclusive are rejected.
430 #[serde(rename = "installPriority")]
431 pub install_priority: Option<i32>,
432 /// The type of installation to perform.
433 #[serde(rename = "installType")]
434 pub install_type: Option<String>,
435 /// Whether the app is allowed to lock itself in full-screen mode. DEPRECATED. Use InstallType KIOSK or kioskCustomLauncherEnabled to configure a dedicated device.
436 #[serde(rename = "lockTaskAllowed")]
437 pub lock_task_allowed: Option<bool>,
438 /// Managed configuration applied to the app. The format for the configuration is dictated by the ManagedProperty values supported by the app. Each field name in the managed configuration must match the key field of the ManagedProperty. The field value must be compatible with the type of the ManagedProperty: *type* *JSON value* BOOL true or false STRING string INTEGER number CHOICE string MULTISELECT array of strings HIDDEN string BUNDLE_ARRAY array of objects
439 #[serde(rename = "managedConfiguration")]
440 pub managed_configuration: Option<HashMap<String, serde_json::Value>>,
441 /// The managed configurations template for the app, saved from the managed configurations iframe. This field is ignored if managed_configuration is set.
442 #[serde(rename = "managedConfigurationTemplate")]
443 pub managed_configuration_template: Option<ManagedConfigurationTemplate>,
444 /// The minimum version of the app that runs on the device. If set, the device attempts to update the app to at least this version code. If the app is not up-to-date, the device will contain a NonComplianceDetail with non_compliance_reason set to APP_NOT_UPDATED. The app must already be published to Google Play with a version code greater than or equal to this value. At most 20 apps may specify a minimum version code per policy.
445 #[serde(rename = "minimumVersionCode")]
446 pub minimum_version_code: Option<i32>,
447 /// The package name of the app. For example, com.google.android.youtube for the YouTube app.
448 #[serde(rename = "packageName")]
449 pub package_name: Option<String>,
450 /// Explicit permission grants or denials for the app. These values override the default_permission_policy and permission_grants which apply to all apps.
451 #[serde(rename = "permissionGrants")]
452 pub permission_grants: Option<Vec<PermissionGrant>>,
453 /// Optional. Specifies whether user control is permitted for the app. User control includes user actions like force-stopping and clearing app data. Supported on Android 11 and above.
454 #[serde(rename = "userControlSettings")]
455 pub user_control_settings: Option<String>,
456 /// Specifies whether the app installed in the work profile is allowed to add widgets to the home screen.
457 #[serde(rename = "workProfileWidgets")]
458 pub work_profile_widgets: Option<String>,
459}
460
461impl common::Part for ApplicationPolicy {}
462
463/// Information reported about an installed app.
464///
465/// This type is not used in any activity, and only used as *part* of another schema.
466///
467#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
468#[serde_with::serde_as]
469#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
470pub struct ApplicationReport {
471 /// The source of the package.
472 #[serde(rename = "applicationSource")]
473 pub application_source: Option<String>,
474 /// The display name of the app.
475 #[serde(rename = "displayName")]
476 pub display_name: Option<String>,
477 /// The list of app events which have occurred in the last 30 hours.
478 pub events: Option<Vec<ApplicationEvent>>,
479 /// The package name of the app that installed this app.
480 #[serde(rename = "installerPackageName")]
481 pub installer_package_name: Option<String>,
482 /// List of keyed app states reported by the app.
483 #[serde(rename = "keyedAppStates")]
484 pub keyed_app_states: Option<Vec<KeyedAppState>>,
485 /// Package name of the app.
486 #[serde(rename = "packageName")]
487 pub package_name: Option<String>,
488 /// The SHA-256 hash of the app's APK file, which can be used to verify the app hasn't been modified. Each byte of the hash value is represented as a two-digit hexadecimal number.
489 #[serde(rename = "packageSha256Hash")]
490 pub package_sha256_hash: Option<String>,
491 /// The SHA-1 hash of each android.content.pm.Signature (https://developer.android.com/reference/android/content/pm/Signature.html) associated with the app package. Each byte of each hash value is represented as a two-digit hexadecimal number.
492 #[serde(rename = "signingKeyCertFingerprints")]
493 pub signing_key_cert_fingerprints: Option<Vec<String>>,
494 /// Application state.
495 pub state: Option<String>,
496 /// Whether the app is user facing.
497 #[serde(rename = "userFacingType")]
498 pub user_facing_type: Option<String>,
499 /// The app version code, which can be used to determine whether one version is more recent than another.
500 #[serde(rename = "versionCode")]
501 pub version_code: Option<i32>,
502 /// The app version as displayed to the user.
503 #[serde(rename = "versionName")]
504 pub version_name: Option<String>,
505}
506
507impl common::Part for ApplicationReport {}
508
509/// Settings controlling the behavior of application reports.
510///
511/// This type is not used in any activity, and only used as *part* of another schema.
512///
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct ApplicationReportingSettings {
517 /// Whether removed apps are included in application reports.
518 #[serde(rename = "includeRemovedApps")]
519 pub include_removed_apps: Option<bool>,
520}
521
522impl common::Part for ApplicationReportingSettings {}
523
524/// An action to block access to apps and data on a fully managed device or in a work profile. This action also triggers a device or work profile to displays a user-facing notification with information (where possible) on how to correct the compliance issue. Note: wipeAction must also be specified.
525///
526/// This type is not used in any activity, and only used as *part* of another schema.
527///
528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
529#[serde_with::serde_as]
530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
531pub struct BlockAction {
532 /// Number of days the policy is non-compliant before the device or work profile is blocked. To block access immediately, set to 0. blockAfterDays must be less than wipeAfterDays.
533 #[serde(rename = "blockAfterDays")]
534 pub block_after_days: Option<i32>,
535 /// Specifies the scope of this BlockAction. Only applicable to devices that are company-owned.
536 #[serde(rename = "blockScope")]
537 pub block_scope: Option<String>,
538}
539
540impl common::Part for BlockAction {}
541
542/// Controls apps' access to private keys. The rule determines which private key, if any, Android Device Policy grants to the specified app. Access is granted either when the app calls KeyChain.choosePrivateKeyAlias (https://developer.android.com/reference/android/security/KeyChain#choosePrivateKeyAlias%28android.app.Activity,%20android.security.KeyChainAliasCallback,%20java.lang.String[],%20java.security.Principal[],%20java.lang.String,%20int,%20java.lang.String%29) (or any overloads) to request a private key alias for a given URL, or for rules that are not URL-specific (that is, if urlPattern is not set, or set to the empty string or .*) on Android 11 and above, directly so that the app can call KeyChain.getPrivateKey (https://developer.android.com/reference/android/security/KeyChain#getPrivateKey%28android.content.Context,%20java.lang.String%29), without first having to call KeyChain.choosePrivateKeyAlias.When an app calls KeyChain.choosePrivateKeyAlias if more than one choosePrivateKeyRules matches, the last matching rule defines which key alias to return.
543///
544/// This type is not used in any activity, and only used as *part* of another schema.
545///
546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
547#[serde_with::serde_as]
548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
549pub struct ChoosePrivateKeyRule {
550 /// The package names to which this rule applies. The hash of the signing certificate for each app is verified against the hash provided by Play. If no package names are specified, then the alias is provided to all apps that call KeyChain.choosePrivateKeyAlias (https://developer.android.com/reference/android/security/KeyChain#choosePrivateKeyAlias%28android.app.Activity,%20android.security.KeyChainAliasCallback,%20java.lang.String[],%20java.security.Principal[],%20java.lang.String,%20int,%20java.lang.String%29) or any overloads (but not without calling KeyChain.choosePrivateKeyAlias, even on Android 11 and above). Any app with the same Android UID as a package specified here will have access when they call KeyChain.choosePrivateKeyAlias.
551 #[serde(rename = "packageNames")]
552 pub package_names: Option<Vec<String>>,
553 /// The alias of the private key to be used.
554 #[serde(rename = "privateKeyAlias")]
555 pub private_key_alias: Option<String>,
556 /// The URL pattern to match against the URL of the request. If not set or empty, it matches all URLs. This uses the regular expression syntax of java.util.regex.Pattern.
557 #[serde(rename = "urlPattern")]
558 pub url_pattern: Option<String>,
559}
560
561impl common::Part for ChoosePrivateKeyRule {}
562
563/// Parameters associated with the CLEAR_APP_DATA command to clear the data of specified apps from the device.
564///
565/// This type is not used in any activity, and only used as *part* of another schema.
566///
567#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
568#[serde_with::serde_as]
569#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
570pub struct ClearAppsDataParams {
571 /// The package names of the apps whose data will be cleared when the command is executed.
572 #[serde(rename = "packageNames")]
573 pub package_names: Option<Vec<String>>,
574}
575
576impl common::Part for ClearAppsDataParams {}
577
578/// Status of the CLEAR_APP_DATA command to clear the data of specified apps from the device.
579///
580/// This type is not used in any activity, and only used as *part* of another schema.
581///
582#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
583#[serde_with::serde_as]
584#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
585pub struct ClearAppsDataStatus {
586 /// The per-app results, a mapping from package names to the respective clearing result.
587 pub results: Option<HashMap<String, PerAppResult>>,
588}
589
590impl common::Part for ClearAppsDataStatus {}
591
592/// A command.
593///
594/// # Activities
595///
596/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
597/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
598///
599/// * [devices issue command enterprises](EnterpriseDeviceIssueCommandCall) (request)
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct Command {
604 /// Parameters for the CLEAR_APP_DATA command to clear the data of specified apps from the device. See ClearAppsDataParams. If this is set, then it is suggested that type should not be set. In this case, the server automatically sets it to CLEAR_APP_DATA. It is also acceptable to explicitly set type to CLEAR_APP_DATA.
605 #[serde(rename = "clearAppsDataParams")]
606 pub clear_apps_data_params: Option<ClearAppsDataParams>,
607 /// Output only. Status of the CLEAR_APP_DATA command to clear the data of specified apps from the device. See ClearAppsDataStatus.
608 #[serde(rename = "clearAppsDataStatus")]
609 pub clear_apps_data_status: Option<ClearAppsDataStatus>,
610 /// The timestamp at which the command was created. The timestamp is automatically generated by the server.
611 #[serde(rename = "createTime")]
612 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
613 /// The duration for which the command is valid. The command will expire if not executed by the device during this time. The default duration if unspecified is ten minutes. There is no maximum duration.
614 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
615 pub duration: Option<chrono::Duration>,
616 /// If the command failed, an error code explaining the failure. This is not set when the command is cancelled by the caller.
617 #[serde(rename = "errorCode")]
618 pub error_code: Option<String>,
619 /// For commands of type RESET_PASSWORD, optionally specifies the new password. Note: The new password must be at least 6 characters long if it is numeric in case of Android 14 devices. Else the command will fail with INVALID_VALUE.
620 #[serde(rename = "newPassword")]
621 pub new_password: Option<String>,
622 /// For commands of type RESET_PASSWORD, optionally specifies flags.
623 #[serde(rename = "resetPasswordFlags")]
624 pub reset_password_flags: Option<Vec<String>>,
625 /// Parameters for the START_LOST_MODE command to put the device into lost mode. See StartLostModeParams. If this is set, then it is suggested that type should not be set. In this case, the server automatically sets it to START_LOST_MODE. It is also acceptable to explicitly set type to START_LOST_MODE.
626 #[serde(rename = "startLostModeParams")]
627 pub start_lost_mode_params: Option<StartLostModeParams>,
628 /// Output only. Status of the START_LOST_MODE command to put the device into lost mode. See StartLostModeStatus.
629 #[serde(rename = "startLostModeStatus")]
630 pub start_lost_mode_status: Option<StartLostModeStatus>,
631 /// Parameters for the STOP_LOST_MODE command to take the device out of lost mode. See StopLostModeParams. If this is set, then it is suggested that type should not be set. In this case, the server automatically sets it to STOP_LOST_MODE. It is also acceptable to explicitly set type to STOP_LOST_MODE.
632 #[serde(rename = "stopLostModeParams")]
633 pub stop_lost_mode_params: Option<StopLostModeParams>,
634 /// Output only. Status of the STOP_LOST_MODE command to take the device out of lost mode. See StopLostModeStatus.
635 #[serde(rename = "stopLostModeStatus")]
636 pub stop_lost_mode_status: Option<StopLostModeStatus>,
637 /// The type of the command.
638 #[serde(rename = "type")]
639 pub type_: Option<String>,
640 /// The resource name of the user that owns the device in the form enterprises/{enterpriseId}/users/{userId}. This is automatically generated by the server based on the device the command is sent to.
641 #[serde(rename = "userName")]
642 pub user_name: Option<String>,
643}
644
645impl common::RequestValue for Command {}
646
647/// Information about Common Criteria Mode—security standards defined in the Common Criteria for Information Technology Security Evaluation (https://www.commoncriteriaportal.org/) (CC).This information is only available if statusReportingSettings.commonCriteriaModeEnabled is true in the device's policy.
648///
649/// This type is not used in any activity, and only used as *part* of another schema.
650///
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct CommonCriteriaModeInfo {
655 /// Whether Common Criteria Mode is enabled.
656 #[serde(rename = "commonCriteriaModeStatus")]
657 pub common_criteria_mode_status: Option<String>,
658}
659
660impl common::Part for CommonCriteriaModeInfo {}
661
662/// A rule declaring which mitigating actions to take when a device is not compliant with its policy. For every rule, there is always an implicit mitigating action to set policy_compliant to false for the Device resource, and display a message on the device indicating that the device is not compliant with its policy. Other mitigating actions may optionally be taken as well, depending on the field values in the rule.
663///
664/// This type is not used in any activity, and only used as *part* of another schema.
665///
666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
667#[serde_with::serde_as]
668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
669pub struct ComplianceRule {
670 /// A condition which is satisfied if the Android Framework API level on the device doesn't meet a minimum requirement.
671 #[serde(rename = "apiLevelCondition")]
672 pub api_level_condition: Option<ApiLevelCondition>,
673 /// If set to true, the rule includes a mitigating action to disable apps so that the device is effectively disabled, but app data is preserved. If the device is running an app in locked task mode, the app will be closed and a UI showing the reason for non-compliance will be displayed.
674 #[serde(rename = "disableApps")]
675 pub disable_apps: Option<bool>,
676 /// A condition which is satisfied if there exists any matching NonComplianceDetail for the device.
677 #[serde(rename = "nonComplianceDetailCondition")]
678 pub non_compliance_detail_condition: Option<NonComplianceDetailCondition>,
679 /// If set, the rule includes a mitigating action to disable apps specified in the list, but app data is preserved.
680 #[serde(rename = "packageNamesToDisable")]
681 pub package_names_to_disable: Option<Vec<String>>,
682}
683
684impl common::Part for ComplianceRule {}
685
686/// Contact details for managed Google Play enterprises.
687///
688/// This type is not used in any activity, and only used as *part* of another schema.
689///
690#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
691#[serde_with::serde_as]
692#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
693pub struct ContactInfo {
694 /// Email address for a point of contact, which will be used to send important announcements related to managed Google Play.
695 #[serde(rename = "contactEmail")]
696 pub contact_email: Option<String>,
697 /// The email of the data protection officer. The email is validated but not verified.
698 #[serde(rename = "dataProtectionOfficerEmail")]
699 pub data_protection_officer_email: Option<String>,
700 /// The name of the data protection officer.
701 #[serde(rename = "dataProtectionOfficerName")]
702 pub data_protection_officer_name: Option<String>,
703 /// The phone number of the data protection officer The phone number is validated but not verified.
704 #[serde(rename = "dataProtectionOfficerPhone")]
705 pub data_protection_officer_phone: Option<String>,
706 /// The email of the EU representative. The email is validated but not verified.
707 #[serde(rename = "euRepresentativeEmail")]
708 pub eu_representative_email: Option<String>,
709 /// The name of the EU representative.
710 #[serde(rename = "euRepresentativeName")]
711 pub eu_representative_name: Option<String>,
712 /// The phone number of the EU representative. The phone number is validated but not verified.
713 #[serde(rename = "euRepresentativePhone")]
714 pub eu_representative_phone: Option<String>,
715}
716
717impl common::Part for ContactInfo {}
718
719/// This feature is not generally available.
720///
721/// This type is not used in any activity, and only used as *part* of another schema.
722///
723#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
724#[serde_with::serde_as]
725#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
726pub struct ContentProviderEndpoint {
727 /// This feature is not generally available.
728 #[serde(rename = "packageName")]
729 pub package_name: Option<String>,
730 /// Required. This feature is not generally available.
731 #[serde(rename = "signingCertsSha256")]
732 pub signing_certs_sha256: Option<Vec<String>>,
733 /// This feature is not generally available.
734 pub uri: Option<String>,
735}
736
737impl common::Part for ContentProviderEndpoint {}
738
739/// Controls the data from the work profile that can be accessed from the personal profile and vice versa. A nonComplianceDetail with MANAGEMENT_MODE is reported if the device does not have a work profile.
740///
741/// This type is not used in any activity, and only used as *part* of another schema.
742///
743#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
744#[serde_with::serde_as]
745#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
746pub struct CrossProfilePolicies {
747 /// Whether text copied from one profile (personal or work) can be pasted in the other profile.
748 #[serde(rename = "crossProfileCopyPaste")]
749 pub cross_profile_copy_paste: Option<String>,
750 /// Whether data from one profile (personal or work) can be shared with apps in the other profile. Specifically controls simple data sharing via intents. Management of other cross-profile communication channels, such as contact search, copy/paste, or connected work & personal apps, are configured separately.
751 #[serde(rename = "crossProfileDataSharing")]
752 pub cross_profile_data_sharing: Option<String>,
753 /// List of apps which are excluded from the ShowWorkContactsInPersonalProfile setting. For this to be set, ShowWorkContactsInPersonalProfile must be set to one of the following values: SHOW_WORK_CONTACTS_IN_PERSONAL_PROFILE_ALLOWED. In this case, these exemptions act as a blocklist. SHOW_WORK_CONTACTS_IN_PERSONAL_PROFILE_DISALLOWED. In this case, these exemptions act as an allowlist. SHOW_WORK_CONTACTS_IN_PERSONAL_PROFILE_DISALLOWED_EXCEPT_SYSTEM. In this case, these exemptions act as an allowlist, in addition to the already allowlisted system apps.Supported on Android 14 and above. A nonComplianceDetail with API_LEVEL is reported if the Android version is less than 14.
754 #[serde(rename = "exemptionsToShowWorkContactsInPersonalProfile")]
755 pub exemptions_to_show_work_contacts_in_personal_profile: Option<PackageNameList>,
756 /// Whether personal apps can access contacts stored in the work profile.See also exemptions_to_show_work_contacts_in_personal_profile.
757 #[serde(rename = "showWorkContactsInPersonalProfile")]
758 pub show_work_contacts_in_personal_profile: Option<String>,
759 /// Specifies the default behaviour for work profile widgets. If the policy does not specify work_profile_widgets for a specific application, it will behave according to the value specified here.
760 #[serde(rename = "workProfileWidgetsDefault")]
761 pub work_profile_widgets_default: Option<String>,
762}
763
764impl common::Part for CrossProfilePolicies {}
765
766/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: A full date, with non-zero year, month, and day values. A month and day, with a zero year (for example, an anniversary). A year on its own, with a zero month and a zero day. A year and month, with a zero day (for example, a credit card expiration date).Related types: google.type.TimeOfDay google.type.DateTime google.protobuf.Timestamp
767///
768/// This type is not used in any activity, and only used as *part* of another schema.
769///
770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
771#[serde_with::serde_as]
772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
773pub struct Date {
774 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
775 pub day: Option<i32>,
776 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
777 pub month: Option<i32>,
778 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
779 pub year: Option<i32>,
780}
781
782impl common::Part for Date {}
783
784/// A device owned by an enterprise. Unless otherwise noted, all fields are read-only and can’t be modified by enterprises.devices.patch.
785///
786/// # Activities
787///
788/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
789/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
790///
791/// * [devices get enterprises](EnterpriseDeviceGetCall) (response)
792/// * [devices patch enterprises](EnterpriseDevicePatchCall) (request|response)
793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
794#[serde_with::serde_as]
795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
796pub struct Device {
797 /// The API level of the Android platform version running on the device.
798 #[serde(rename = "apiLevel")]
799 pub api_level: Option<i32>,
800 /// Reports for apps installed on the device. This information is only available when application_reports_enabled is true in the device's policy.
801 #[serde(rename = "applicationReports")]
802 pub application_reports: Option<Vec<ApplicationReport>>,
803 /// The password requirements currently applied to the device. The applied requirements may be slightly different from those specified in passwordPolicies in some cases. fieldPath is set based on passwordPolicies.
804 #[serde(rename = "appliedPasswordPolicies")]
805 pub applied_password_policies: Option<Vec<PasswordRequirements>>,
806 /// The name of the policy currently applied to the device.
807 #[serde(rename = "appliedPolicyName")]
808 pub applied_policy_name: Option<String>,
809 /// The version of the policy currently applied to the device.
810 #[serde(rename = "appliedPolicyVersion")]
811 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
812 pub applied_policy_version: Option<i64>,
813 /// The state currently applied to the device.
814 #[serde(rename = "appliedState")]
815 pub applied_state: Option<String>,
816 /// Information about Common Criteria Mode—security standards defined in the Common Criteria for Information Technology Security Evaluation (https://www.commoncriteriaportal.org/) (CC).This information is only available if statusReportingSettings.commonCriteriaModeEnabled is true in the device's policy.
817 #[serde(rename = "commonCriteriaModeInfo")]
818 pub common_criteria_mode_info: Option<CommonCriteriaModeInfo>,
819 /// Device settings information. This information is only available if deviceSettingsEnabled is true in the device's policy.
820 #[serde(rename = "deviceSettings")]
821 pub device_settings: Option<DeviceSettings>,
822 /// If the device state is DISABLED, an optional message that is displayed on the device indicating the reason the device is disabled. This field can be modified by a patch request.
823 #[serde(rename = "disabledReason")]
824 pub disabled_reason: Option<UserFacingMessage>,
825 /// Detailed information about displays on the device. This information is only available if displayInfoEnabled is true in the device's policy.
826 pub displays: Option<Vec<Display>>,
827 /// Output only. Information related to whether this device was migrated from being managed by another Device Policy Controller (DPC).
828 #[serde(rename = "dpcMigrationInfo")]
829 pub dpc_migration_info: Option<DpcMigrationInfo>,
830 /// The time of device enrollment.
831 #[serde(rename = "enrollmentTime")]
832 pub enrollment_time: Option<chrono::DateTime<chrono::offset::Utc>>,
833 /// If the device was enrolled with an enrollment token with additional data provided, this field contains that data.
834 #[serde(rename = "enrollmentTokenData")]
835 pub enrollment_token_data: Option<String>,
836 /// If the device was enrolled with an enrollment token, this field contains the name of the token.
837 #[serde(rename = "enrollmentTokenName")]
838 pub enrollment_token_name: Option<String>,
839 /// Detailed information about the device hardware.
840 #[serde(rename = "hardwareInfo")]
841 pub hardware_info: Option<HardwareInfo>,
842 /// Hardware status samples in chronological order. This information is only available if hardwareStatusEnabled is true in the device's policy.
843 #[serde(rename = "hardwareStatusSamples")]
844 pub hardware_status_samples: Option<Vec<HardwareStatus>>,
845 /// Deprecated.
846 #[serde(rename = "lastPolicyComplianceReportTime")]
847 pub last_policy_compliance_report_time: Option<chrono::DateTime<chrono::offset::Utc>>,
848 /// The last time the device fetched its policy.
849 #[serde(rename = "lastPolicySyncTime")]
850 pub last_policy_sync_time: Option<chrono::DateTime<chrono::offset::Utc>>,
851 /// The last time the device sent a status report.
852 #[serde(rename = "lastStatusReportTime")]
853 pub last_status_report_time: Option<chrono::DateTime<chrono::offset::Utc>>,
854 /// The type of management mode Android Device Policy takes on the device. This influences which policy settings are supported.
855 #[serde(rename = "managementMode")]
856 pub management_mode: Option<String>,
857 /// Events related to memory and storage measurements in chronological order. This information is only available if memoryInfoEnabled is true in the device's policy.Events are retained for a certain period of time and old events are deleted.
858 #[serde(rename = "memoryEvents")]
859 pub memory_events: Option<Vec<MemoryEvent>>,
860 /// Memory information: contains information about device memory and storage.
861 #[serde(rename = "memoryInfo")]
862 pub memory_info: Option<MemoryInfo>,
863 /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
864 pub name: Option<String>,
865 /// Device network information. This information is only available if networkInfoEnabled is true in the device's policy.
866 #[serde(rename = "networkInfo")]
867 pub network_info: Option<NetworkInfo>,
868 /// Details about policy settings that the device is not compliant with.
869 #[serde(rename = "nonComplianceDetails")]
870 pub non_compliance_details: Option<Vec<NonComplianceDetail>>,
871 /// Ownership of the managed device.
872 pub ownership: Option<String>,
873 /// Whether the device is compliant with its policy.
874 #[serde(rename = "policyCompliant")]
875 pub policy_compliant: Option<bool>,
876 /// The name of the policy applied to the device, in the form enterprises/{enterpriseId}/policies/{policyId}. If not specified, the policy_name for the device's user is applied. This field can be modified by a patch request. You can specify only the policyId when calling enterprises.devices.patch, as long as the policyId doesn’t contain any slashes. The rest of the policy name is inferred.
877 #[serde(rename = "policyName")]
878 pub policy_name: Option<String>,
879 /// Power management events on the device in chronological order. This information is only available if powerManagementEventsEnabled is true in the device's policy.
880 #[serde(rename = "powerManagementEvents")]
881 pub power_management_events: Option<Vec<PowerManagementEvent>>,
882 /// If the same physical device has been enrolled multiple times, this field contains its previous device names. The serial number is used as the unique identifier to determine if the same physical device has enrolled previously. The names are in chronological order.
883 #[serde(rename = "previousDeviceNames")]
884 pub previous_device_names: Option<Vec<String>>,
885 /// Device's security posture value that reflects how secure the device is.
886 #[serde(rename = "securityPosture")]
887 pub security_posture: Option<SecurityPosture>,
888 /// Detailed information about the device software. This information is only available if softwareInfoEnabled is true in the device's policy.
889 #[serde(rename = "softwareInfo")]
890 pub software_info: Option<SoftwareInfo>,
891 /// The state to be applied to the device. This field can be modified by a patch request. Note that when calling enterprises.devices.patch, ACTIVE and DISABLED are the only allowable values. To enter the device into a DELETED state, call enterprises.devices.delete.
892 pub state: Option<String>,
893 /// Map of selected system properties name and value related to the device. This information is only available if systemPropertiesEnabled is true in the device's policy.
894 #[serde(rename = "systemProperties")]
895 pub system_properties: Option<HashMap<String, String>>,
896 /// The user who owns the device.
897 pub user: Option<User>,
898 /// The resource name of the user that owns this device in the form enterprises/{enterpriseId}/users/{userId}.
899 #[serde(rename = "userName")]
900 pub user_name: Option<String>,
901}
902
903impl common::RequestValue for Device {}
904impl common::ResponseResult for Device {}
905
906/// Covers controls for device connectivity such as Wi-Fi, USB data access, keyboard/mouse connections, and more.
907///
908/// This type is not used in any activity, and only used as *part* of another schema.
909///
910#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
911#[serde_with::serde_as]
912#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
913pub struct DeviceConnectivityManagement {
914 /// Controls Wi-Fi configuring privileges. Based on the option set, user will have either full or limited or no control in configuring Wi-Fi networks.
915 #[serde(rename = "configureWifi")]
916 pub configure_wifi: Option<String>,
917 /// Controls tethering settings. Based on the value set, the user is partially or fully disallowed from using different forms of tethering.
918 #[serde(rename = "tetheringSettings")]
919 pub tethering_settings: Option<String>,
920 /// Controls what files and/or data can be transferred via USB. Supported only on company-owned devices.
921 #[serde(rename = "usbDataAccess")]
922 pub usb_data_access: Option<String>,
923 /// Controls configuring and using Wi-Fi direct settings. Supported on company-owned devices running Android 13 and above.
924 #[serde(rename = "wifiDirectSettings")]
925 pub wifi_direct_settings: Option<String>,
926 /// Restrictions on which Wi-Fi SSIDs the device can connect to. Note that this does not affect which networks can be configured on the device. Supported on company-owned devices running Android 13 and above.
927 #[serde(rename = "wifiSsidPolicy")]
928 pub wifi_ssid_policy: Option<WifiSsidPolicy>,
929}
930
931impl common::Part for DeviceConnectivityManagement {}
932
933/// Controls for device radio settings.
934///
935/// This type is not used in any activity, and only used as *part* of another schema.
936///
937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
938#[serde_with::serde_as]
939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
940pub struct DeviceRadioState {
941 /// Controls whether airplane mode can be toggled by the user or not.
942 #[serde(rename = "airplaneModeState")]
943 pub airplane_mode_state: Option<String>,
944 /// Controls whether cellular 2G setting can be toggled by the user or not.
945 #[serde(rename = "cellularTwoGState")]
946 pub cellular_two_g_state: Option<String>,
947 /// The minimum required security level of Wi-Fi networks that the device can connect to.
948 #[serde(rename = "minimumWifiSecurityLevel")]
949 pub minimum_wifi_security_level: Option<String>,
950 /// Controls the state of the ultra wideband setting and whether the user can toggle it on or off.
951 #[serde(rename = "ultraWidebandState")]
952 pub ultra_wideband_state: Option<String>,
953 /// Controls current state of Wi-Fi and if user can change its state.
954 #[serde(rename = "wifiState")]
955 pub wifi_state: Option<String>,
956}
957
958impl common::Part for DeviceRadioState {}
959
960/// Information about security related device settings on device.
961///
962/// This type is not used in any activity, and only used as *part* of another schema.
963///
964#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
965#[serde_with::serde_as]
966#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
967pub struct DeviceSettings {
968 /// Whether ADB (https://developer.android.com/studio/command-line/adb.html) is enabled on the device.
969 #[serde(rename = "adbEnabled")]
970 pub adb_enabled: Option<bool>,
971 /// Whether developer mode is enabled on the device.
972 #[serde(rename = "developmentSettingsEnabled")]
973 pub development_settings_enabled: Option<bool>,
974 /// Encryption status from DevicePolicyManager.
975 #[serde(rename = "encryptionStatus")]
976 pub encryption_status: Option<String>,
977 /// Whether the device is secured with PIN/password.
978 #[serde(rename = "isDeviceSecure")]
979 pub is_device_secure: Option<bool>,
980 /// Whether the storage encryption is enabled.
981 #[serde(rename = "isEncrypted")]
982 pub is_encrypted: Option<bool>,
983 /// Whether installing apps from unknown sources is enabled.
984 #[serde(rename = "unknownSourcesEnabled")]
985 pub unknown_sources_enabled: Option<bool>,
986 /// Whether Google Play Protect verification (https://support.google.com/accounts/answer/2812853) is enforced on the device.
987 #[serde(rename = "verifyAppsEnabled")]
988 pub verify_apps_enabled: Option<bool>,
989}
990
991impl common::Part for DeviceSettings {}
992
993/// Device display information.
994///
995/// This type is not used in any activity, and only used as *part* of another schema.
996///
997#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
998#[serde_with::serde_as]
999#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1000pub struct Display {
1001 /// Display density expressed as dots-per-inch.
1002 pub density: Option<i32>,
1003 /// Unique display id.
1004 #[serde(rename = "displayId")]
1005 pub display_id: Option<i32>,
1006 /// Display height in pixels.
1007 pub height: Option<i32>,
1008 /// Name of the display.
1009 pub name: Option<String>,
1010 /// Refresh rate of the display in frames per second.
1011 #[serde(rename = "refreshRate")]
1012 pub refresh_rate: Option<i32>,
1013 /// State of the display.
1014 pub state: Option<String>,
1015 /// Display width in pixels.
1016 pub width: Option<i32>,
1017}
1018
1019impl common::Part for Display {}
1020
1021/// Controls for the display settings.
1022///
1023/// This type is not used in any activity, and only used as *part* of another schema.
1024///
1025#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1026#[serde_with::serde_as]
1027#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1028pub struct DisplaySettings {
1029 /// Optional. Controls the screen brightness settings.
1030 #[serde(rename = "screenBrightnessSettings")]
1031 pub screen_brightness_settings: Option<ScreenBrightnessSettings>,
1032 /// Optional. Controls the screen timeout settings.
1033 #[serde(rename = "screenTimeoutSettings")]
1034 pub screen_timeout_settings: Option<ScreenTimeoutSettings>,
1035}
1036
1037impl common::Part for DisplaySettings {}
1038
1039/// Information related to whether this device was migrated from being managed by another Device Policy Controller (DPC).
1040///
1041/// This type is not used in any activity, and only used as *part* of another schema.
1042///
1043#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1044#[serde_with::serde_as]
1045#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1046pub struct DpcMigrationInfo {
1047 /// Output only. If this device was migrated from another DPC, the additionalData field of the migration token is populated here.
1048 #[serde(rename = "additionalData")]
1049 pub additional_data: Option<String>,
1050 /// Output only. If this device was migrated from another DPC, this is its package name. Not populated otherwise.
1051 #[serde(rename = "previousDpc")]
1052 pub previous_dpc: Option<String>,
1053}
1054
1055impl common::Part for DpcMigrationInfo {}
1056
1057/// 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); }
1058///
1059/// # Activities
1060///
1061/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1062/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1063///
1064/// * [devices operations cancel enterprises](EnterpriseDeviceOperationCancelCall) (response)
1065/// * [devices delete enterprises](EnterpriseDeviceDeleteCall) (response)
1066/// * [enrollment tokens delete enterprises](EnterpriseEnrollmentTokenDeleteCall) (response)
1067/// * [policies delete enterprises](EnterprisePolicyDeleteCall) (response)
1068/// * [web apps delete enterprises](EnterpriseWebAppDeleteCall) (response)
1069/// * [delete enterprises](EnterpriseDeleteCall) (response)
1070#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1071#[serde_with::serde_as]
1072#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1073pub struct Empty {
1074 _never_set: Option<bool>,
1075}
1076
1077impl common::ResponseResult for Empty {}
1078
1079/// An enrollment token.
1080///
1081/// # Activities
1082///
1083/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1084/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1085///
1086/// * [enrollment tokens create enterprises](EnterpriseEnrollmentTokenCreateCall) (request|response)
1087/// * [enrollment tokens get enterprises](EnterpriseEnrollmentTokenGetCall) (response)
1088#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1089#[serde_with::serde_as]
1090#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1091pub struct EnrollmentToken {
1092 /// Optional, arbitrary data associated with the enrollment token. This could contain, for example, the ID of an org unit the device is assigned to after enrollment. After a device enrolls with the token, this data will be exposed in the enrollment_token_data field of the Device resource. The data must be 1024 characters or less; otherwise, the creation request will fail.
1093 #[serde(rename = "additionalData")]
1094 pub additional_data: Option<String>,
1095 /// Controls whether personal usage is allowed on a device provisioned with this enrollment token.For company-owned devices: Enabling personal usage allows the user to set up a work profile on the device. Disabling personal usage requires the user provision the device as a fully managed device.For personally-owned devices: Enabling personal usage allows the user to set up a work profile on the device. Disabling personal usage will prevent the device from provisioning. Personal usage cannot be disabled on personally-owned device.
1096 #[serde(rename = "allowPersonalUsage")]
1097 pub allow_personal_usage: Option<String>,
1098 /// The length of time the enrollment token is valid, ranging from 1 minute to Durations.MAX_VALUE (https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/util/Durations.html#MAX_VALUE), approximately 10,000 years. If not specified, the default duration is 1 hour. Please note that if requested duration causes the resulting expiration_timestamp to exceed Timestamps.MAX_VALUE (https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/util/Timestamps.html#MAX_VALUE), then expiration_timestamp is coerced to Timestamps.MAX_VALUE.
1099 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1100 pub duration: Option<chrono::Duration>,
1101 /// The expiration time of the token. This is a read-only field generated by the server.
1102 #[serde(rename = "expirationTimestamp")]
1103 pub expiration_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
1104 /// The name of the enrollment token, which is generated by the server during creation, in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}.
1105 pub name: Option<String>,
1106 /// Whether the enrollment token is for one time use only. If the flag is set to true, only one device can use it for registration.
1107 #[serde(rename = "oneTimeOnly")]
1108 pub one_time_only: Option<bool>,
1109 /// The name of the policy initially applied to the enrolled device, in the form enterprises/{enterpriseId}/policies/{policyId}. If not specified, the policy_name for the device’s user is applied. If user_name is also not specified, enterprises/{enterpriseId}/policies/default is applied by default. When updating this field, you can specify only the policyId as long as the policyId doesn’t contain any slashes. The rest of the policy name will be inferred.
1110 #[serde(rename = "policyName")]
1111 pub policy_name: Option<String>,
1112 /// A JSON string whose UTF-8 representation can be used to generate a QR code to enroll a device with this enrollment token. To enroll a device using NFC, the NFC record must contain a serialized java.util.Properties representation of the properties in the JSON.
1113 #[serde(rename = "qrCode")]
1114 pub qr_code: Option<String>,
1115 /// This field is deprecated and the value is ignored.
1116 pub user: Option<User>,
1117 /// The token value that's passed to the device and authorizes the device to enroll. This is a read-only field generated by the server.
1118 pub value: Option<String>,
1119}
1120
1121impl common::RequestValue for EnrollmentToken {}
1122impl common::ResponseResult for EnrollmentToken {}
1123
1124/// The configuration applied to an enterprise.
1125///
1126/// # Activities
1127///
1128/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1129/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1130///
1131/// * [applications get enterprises](EnterpriseApplicationGetCall) (none)
1132/// * [devices operations cancel enterprises](EnterpriseDeviceOperationCancelCall) (none)
1133/// * [devices operations get enterprises](EnterpriseDeviceOperationGetCall) (none)
1134/// * [devices operations list enterprises](EnterpriseDeviceOperationListCall) (none)
1135/// * [devices delete enterprises](EnterpriseDeviceDeleteCall) (none)
1136/// * [devices get enterprises](EnterpriseDeviceGetCall) (none)
1137/// * [devices issue command enterprises](EnterpriseDeviceIssueCommandCall) (none)
1138/// * [devices list enterprises](EnterpriseDeviceListCall) (none)
1139/// * [devices patch enterprises](EnterpriseDevicePatchCall) (none)
1140/// * [enrollment tokens create enterprises](EnterpriseEnrollmentTokenCreateCall) (none)
1141/// * [enrollment tokens delete enterprises](EnterpriseEnrollmentTokenDeleteCall) (none)
1142/// * [enrollment tokens get enterprises](EnterpriseEnrollmentTokenGetCall) (none)
1143/// * [enrollment tokens list enterprises](EnterpriseEnrollmentTokenListCall) (none)
1144/// * [migration tokens create enterprises](EnterpriseMigrationTokenCreateCall) (none)
1145/// * [migration tokens get enterprises](EnterpriseMigrationTokenGetCall) (none)
1146/// * [migration tokens list enterprises](EnterpriseMigrationTokenListCall) (none)
1147/// * [policies delete enterprises](EnterprisePolicyDeleteCall) (none)
1148/// * [policies get enterprises](EnterprisePolicyGetCall) (none)
1149/// * [policies list enterprises](EnterprisePolicyListCall) (none)
1150/// * [policies patch enterprises](EnterprisePolicyPatchCall) (none)
1151/// * [web apps create enterprises](EnterpriseWebAppCreateCall) (none)
1152/// * [web apps delete enterprises](EnterpriseWebAppDeleteCall) (none)
1153/// * [web apps get enterprises](EnterpriseWebAppGetCall) (none)
1154/// * [web apps list enterprises](EnterpriseWebAppListCall) (none)
1155/// * [web apps patch enterprises](EnterpriseWebAppPatchCall) (none)
1156/// * [web tokens create enterprises](EnterpriseWebTokenCreateCall) (none)
1157/// * [create enterprises](EnterpriseCreateCall) (request|response)
1158/// * [delete enterprises](EnterpriseDeleteCall) (none)
1159/// * [get enterprises](EnterpriseGetCall) (response)
1160/// * [list enterprises](EnterpriseListCall) (none)
1161/// * [patch enterprises](EnterprisePatchCall) (request|response)
1162#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1163#[serde_with::serde_as]
1164#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1165pub struct Enterprise {
1166 /// Deprecated and unused.
1167 #[serde(rename = "appAutoApprovalEnabled")]
1168 pub app_auto_approval_enabled: Option<bool>,
1169 /// The enterprise contact info of an EMM-managed enterprise.
1170 #[serde(rename = "contactInfo")]
1171 pub contact_info: Option<ContactInfo>,
1172 /// The types of Google Pub/Sub notifications enabled for the enterprise.
1173 #[serde(rename = "enabledNotificationTypes")]
1174 pub enabled_notification_types: Option<Vec<String>>,
1175 /// The name of the enterprise displayed to users. This field has a maximum length of 100 characters.
1176 #[serde(rename = "enterpriseDisplayName")]
1177 pub enterprise_display_name: Option<String>,
1178 /// Settings for Google-provided user authentication.
1179 #[serde(rename = "googleAuthenticationSettings")]
1180 pub google_authentication_settings: Option<GoogleAuthenticationSettings>,
1181 /// An image displayed as a logo during device provisioning. Supported types are: image/bmp, image/gif, image/x-ico, image/jpeg, image/png, image/webp, image/vnd.wap.wbmp, image/x-adobe-dng.
1182 pub logo: Option<ExternalData>,
1183 /// The name of the enterprise which is generated by the server during creation, in the form enterprises/{enterpriseId}.
1184 pub name: Option<String>,
1185 /// A color in RGB format that indicates the predominant color to display in the device management app UI. The color components are stored as follows: (red << 16) | (green << 8) | blue, where the value of each component is between 0 and 255, inclusive.
1186 #[serde(rename = "primaryColor")]
1187 pub primary_color: Option<i32>,
1188 /// The topic which Pub/Sub notifications are published to, in the form projects/{project}/topics/{topic}. This field is only required if Pub/Sub notifications are enabled.
1189 #[serde(rename = "pubsubTopic")]
1190 pub pubsub_topic: Option<String>,
1191 /// Sign-in details of the enterprise.
1192 #[serde(rename = "signinDetails")]
1193 pub signin_details: Option<Vec<SigninDetail>>,
1194 /// Terms and conditions that must be accepted when provisioning a device for this enterprise. A page of terms is generated for each value in this list.
1195 #[serde(rename = "termsAndConditions")]
1196 pub terms_and_conditions: Option<Vec<TermsAndConditions>>,
1197}
1198
1199impl common::RequestValue for Enterprise {}
1200impl common::Resource for Enterprise {}
1201impl common::ResponseResult for Enterprise {}
1202
1203/// Configuration to enable an app as an extension app, with the capability of interacting with Android Device Policy offline. For Android versions 13 and above, extension apps are exempt from battery restrictions so will not be placed into the restricted App Standby Bucket (https://developer.android.com/topic/performance/appstandby#restricted-bucket). Extensions apps are also protected against users clearing their data or force-closing the application, although admins can continue to use the clear app data command on extension apps if needed for Android 13 and above.
1204///
1205/// This type is not used in any activity, and only used as *part* of another schema.
1206///
1207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1208#[serde_with::serde_as]
1209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1210pub struct ExtensionConfig {
1211 /// Fully qualified class name of the receiver service class for Android Device Policy to notify the extension app of any local command status updates.
1212 #[serde(rename = "notificationReceiver")]
1213 pub notification_receiver: Option<String>,
1214 /// Hex-encoded SHA-256 hash of the signing certificate of the extension app. Only hexadecimal string representations of 64 characters are valid.If not specified, the signature for the corresponding package name is obtained from the Play Store instead.If this list is empty, the signature of the extension app on the device must match the signature obtained from the Play Store for the app to be able to communicate with Android Device Policy.If this list is not empty, the signature of the extension app on the device must match one of the entries in this list for the app to be able to communicate with Android Device Policy.In production use cases, it is recommended to leave this empty.
1215 #[serde(rename = "signingKeyFingerprintsSha256")]
1216 pub signing_key_fingerprints_sha256: Option<Vec<String>>,
1217}
1218
1219impl common::Part for ExtensionConfig {}
1220
1221/// Data hosted at an external location. The data is to be downloaded by Android Device Policy and verified against the hash.
1222///
1223/// This type is not used in any activity, and only used as *part* of another schema.
1224///
1225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1226#[serde_with::serde_as]
1227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1228pub struct ExternalData {
1229 /// The base-64 encoded SHA-256 hash of the content hosted at url. If the content doesn't match this hash, Android Device Policy won't use the data.
1230 #[serde(rename = "sha256Hash")]
1231 pub sha256_hash: Option<String>,
1232 /// The absolute URL to the data, which must use either the http or https scheme. Android Device Policy doesn't provide any credentials in the GET request, so the URL must be publicly accessible. Including a long, random component in the URL may be used to prevent attackers from discovering the URL.
1233 pub url: Option<String>,
1234}
1235
1236impl common::Part for ExternalData {}
1237
1238/// A system freeze period. When a device’s clock is within the freeze period, all incoming system updates (including security patches) are blocked and won’t be installed.When the device is outside any set freeze periods, the normal policy behavior (automatic, windowed, or postponed) applies.Leap years are ignored in freeze period calculations, in particular: If Feb. 29th is set as the start or end date of a freeze period, the freeze period will start or end on Feb. 28th instead. When a device’s system clock reads Feb. 29th, it’s treated as Feb. 28th. When calculating the number of days in a freeze period or the time between two freeze periods, Feb. 29th is ignored and not counted as a day.Note: For Freeze Periods to take effect, SystemUpdateType cannot be specified as SYSTEM_UPDATE_TYPE_UNSPECIFIED, because freeze periods require a defined policy to be specified.
1239///
1240/// This type is not used in any activity, and only used as *part* of another schema.
1241///
1242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1243#[serde_with::serde_as]
1244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1245pub struct FreezePeriod {
1246 /// The end date (inclusive) of the freeze period. Must be no later than 90 days from the start date. If the end date is earlier than the start date, the freeze period is considered wrapping year-end. Note: year must not be set. For example, {"month": 1,"date": 30}.
1247 #[serde(rename = "endDate")]
1248 pub end_date: Option<Date>,
1249 /// The start date (inclusive) of the freeze period. Note: year must not be set. For example, {"month": 1,"date": 30}.
1250 #[serde(rename = "startDate")]
1251 pub start_date: Option<Date>,
1252}
1253
1254impl common::Part for FreezePeriod {}
1255
1256/// Contains settings for Google-provided user authentication.
1257///
1258/// This type is not used in any activity, and only used as *part* of another schema.
1259///
1260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1261#[serde_with::serde_as]
1262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1263pub struct GoogleAuthenticationSettings {
1264 /// Output only. Whether users need to be authenticated by Google during the enrollment process. IT admin can specify if Google authentication is enabled for the enterprise for knowledge worker devices. This value can be set only via the Google Admin Console. Google authentication can be used with signin_url In the case where Google authentication is required and a signin_url is specified, Google authentication will be launched before signin_url.
1265 #[serde(rename = "googleAuthenticationRequired")]
1266 pub google_authentication_required: Option<String>,
1267}
1268
1269impl common::Part for GoogleAuthenticationSettings {}
1270
1271/// Information about device hardware. The fields related to temperature thresholds are only available if hardwareStatusEnabled is true in the device's policy.
1272///
1273/// This type is not used in any activity, and only used as *part* of another schema.
1274///
1275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1276#[serde_with::serde_as]
1277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1278pub struct HardwareInfo {
1279 /// Battery shutdown temperature thresholds in Celsius for each battery on the device.
1280 #[serde(rename = "batteryShutdownTemperatures")]
1281 pub battery_shutdown_temperatures: Option<Vec<f32>>,
1282 /// Battery throttling temperature thresholds in Celsius for each battery on the device.
1283 #[serde(rename = "batteryThrottlingTemperatures")]
1284 pub battery_throttling_temperatures: Option<Vec<f32>>,
1285 /// Brand of the device. For example, Google.
1286 pub brand: Option<String>,
1287 /// CPU shutdown temperature thresholds in Celsius for each CPU on the device.
1288 #[serde(rename = "cpuShutdownTemperatures")]
1289 pub cpu_shutdown_temperatures: Option<Vec<f32>>,
1290 /// CPU throttling temperature thresholds in Celsius for each CPU on the device.
1291 #[serde(rename = "cpuThrottlingTemperatures")]
1292 pub cpu_throttling_temperatures: Option<Vec<f32>>,
1293 /// Baseband version. For example, MDM9625_104662.22.05.34p.
1294 #[serde(rename = "deviceBasebandVersion")]
1295 pub device_baseband_version: Option<String>,
1296 /// Output only. ID that uniquely identifies a personally-owned device in a particular organization. On the same physical device when enrolled with the same organization, this ID persists across setups and even factory resets. This ID is available on personally-owned devices with a work profile on devices running Android 12 and above.
1297 #[serde(rename = "enterpriseSpecificId")]
1298 pub enterprise_specific_id: Option<String>,
1299 /// GPU shutdown temperature thresholds in Celsius for each GPU on the device.
1300 #[serde(rename = "gpuShutdownTemperatures")]
1301 pub gpu_shutdown_temperatures: Option<Vec<f32>>,
1302 /// GPU throttling temperature thresholds in Celsius for each GPU on the device.
1303 #[serde(rename = "gpuThrottlingTemperatures")]
1304 pub gpu_throttling_temperatures: Option<Vec<f32>>,
1305 /// Name of the hardware. For example, Angler.
1306 pub hardware: Option<String>,
1307 /// Manufacturer. For example, Motorola.
1308 pub manufacturer: Option<String>,
1309 /// The model of the device. For example, Asus Nexus 7.
1310 pub model: Option<String>,
1311 /// The device serial number.
1312 #[serde(rename = "serialNumber")]
1313 pub serial_number: Option<String>,
1314 /// Device skin shutdown temperature thresholds in Celsius.
1315 #[serde(rename = "skinShutdownTemperatures")]
1316 pub skin_shutdown_temperatures: Option<Vec<f32>>,
1317 /// Device skin throttling temperature thresholds in Celsius.
1318 #[serde(rename = "skinThrottlingTemperatures")]
1319 pub skin_throttling_temperatures: Option<Vec<f32>>,
1320}
1321
1322impl common::Part for HardwareInfo {}
1323
1324/// Hardware status. Temperatures may be compared to the temperature thresholds available in hardwareInfo to determine hardware health.
1325///
1326/// This type is not used in any activity, and only used as *part* of another schema.
1327///
1328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1329#[serde_with::serde_as]
1330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1331pub struct HardwareStatus {
1332 /// Current battery temperatures in Celsius for each battery on the device.
1333 #[serde(rename = "batteryTemperatures")]
1334 pub battery_temperatures: Option<Vec<f32>>,
1335 /// Current CPU temperatures in Celsius for each CPU on the device.
1336 #[serde(rename = "cpuTemperatures")]
1337 pub cpu_temperatures: Option<Vec<f32>>,
1338 /// CPU usages in percentage for each core available on the device. Usage is 0 for each unplugged core. Empty array implies that CPU usage is not supported in the system.
1339 #[serde(rename = "cpuUsages")]
1340 pub cpu_usages: Option<Vec<f32>>,
1341 /// The time the measurements were taken.
1342 #[serde(rename = "createTime")]
1343 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1344 /// Fan speeds in RPM for each fan on the device. Empty array means that there are no fans or fan speed is not supported on the system.
1345 #[serde(rename = "fanSpeeds")]
1346 pub fan_speeds: Option<Vec<f32>>,
1347 /// Current GPU temperatures in Celsius for each GPU on the device.
1348 #[serde(rename = "gpuTemperatures")]
1349 pub gpu_temperatures: Option<Vec<f32>>,
1350 /// Current device skin temperatures in Celsius.
1351 #[serde(rename = "skinTemperatures")]
1352 pub skin_temperatures: Option<Vec<f32>>,
1353}
1354
1355impl common::Part for HardwareStatus {}
1356
1357/// Amongst apps with InstallType set to: FORCE_INSTALLED PREINSTALLEDthis defines a set of restrictions for the app installation. At least one of the fields must be set. When multiple fields are set, then all the constraints need to be satisfied for the app to be installed.
1358///
1359/// This type is not used in any activity, and only used as *part* of another schema.
1360///
1361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1362#[serde_with::serde_as]
1363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1364pub struct InstallConstraint {
1365 /// Optional. Charging constraint.
1366 #[serde(rename = "chargingConstraint")]
1367 pub charging_constraint: Option<String>,
1368 /// Optional. Device idle constraint.
1369 #[serde(rename = "deviceIdleConstraint")]
1370 pub device_idle_constraint: Option<String>,
1371 /// Optional. Network type constraint.
1372 #[serde(rename = "networkTypeConstraint")]
1373 pub network_type_constraint: Option<String>,
1374}
1375
1376impl common::Part for InstallConstraint {}
1377
1378/// Keyed app state reported by the app.
1379///
1380/// This type is not used in any activity, and only used as *part* of another schema.
1381///
1382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1383#[serde_with::serde_as]
1384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1385pub struct KeyedAppState {
1386 /// The creation time of the app state on the device.
1387 #[serde(rename = "createTime")]
1388 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1389 /// Optionally, a machine-readable value to be read by the EMM. For example, setting values that the admin can choose to query against in the EMM console (e.g. “notify me if the battery_warning data < 10”).
1390 pub data: Option<String>,
1391 /// The key for the app state. Acts as a point of reference for what the app is providing state for. For example, when providing managed configuration feedback, this key could be the managed configuration key.
1392 pub key: Option<String>,
1393 /// The time the app state was most recently updated.
1394 #[serde(rename = "lastUpdateTime")]
1395 pub last_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1396 /// Optionally, a free-form message string to explain the app state. If the state was triggered by a particular value (e.g. a managed configuration value), it should be included in the message.
1397 pub message: Option<String>,
1398 /// The severity of the app state.
1399 pub severity: Option<String>,
1400}
1401
1402impl common::Part for KeyedAppState {}
1403
1404/// Settings controlling the behavior of a device in kiosk mode. To enable kiosk mode, set kioskCustomLauncherEnabled to true or specify an app in the policy with installType KIOSK.
1405///
1406/// This type is not used in any activity, and only used as *part* of another schema.
1407///
1408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1409#[serde_with::serde_as]
1410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1411pub struct KioskCustomization {
1412 /// Specifies whether the Settings app is allowed in kiosk mode.
1413 #[serde(rename = "deviceSettings")]
1414 pub device_settings: Option<String>,
1415 /// Sets the behavior of a device in kiosk mode when a user presses and holds (long-presses) the Power button.
1416 #[serde(rename = "powerButtonActions")]
1417 pub power_button_actions: Option<String>,
1418 /// Specifies whether system info and notifications are disabled in kiosk mode.
1419 #[serde(rename = "statusBar")]
1420 pub status_bar: Option<String>,
1421 /// Specifies whether system error dialogs for crashed or unresponsive apps are blocked in kiosk mode. When blocked, the system will force-stop the app as if the user chooses the "close app" option on the UI.
1422 #[serde(rename = "systemErrorWarnings")]
1423 pub system_error_warnings: Option<String>,
1424 /// Specifies which navigation features are enabled (e.g. Home, Overview buttons) in kiosk mode.
1425 #[serde(rename = "systemNavigation")]
1426 pub system_navigation: Option<String>,
1427}
1428
1429impl common::Part for KioskCustomization {}
1430
1431/// An action to launch an app.
1432///
1433/// This type is not used in any activity, and only used as *part* of another schema.
1434///
1435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1436#[serde_with::serde_as]
1437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1438pub struct LaunchAppAction {
1439 /// Package name of app to be launched
1440 #[serde(rename = "packageName")]
1441 pub package_name: Option<String>,
1442}
1443
1444impl common::Part for LaunchAppAction {}
1445
1446/// Response to a request to list devices for a given enterprise.
1447///
1448/// # Activities
1449///
1450/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1451/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1452///
1453/// * [devices list enterprises](EnterpriseDeviceListCall) (response)
1454#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1455#[serde_with::serde_as]
1456#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1457pub struct ListDevicesResponse {
1458 /// The list of devices.
1459 pub devices: Option<Vec<Device>>,
1460 /// If there are more results, a token to retrieve next page of results.
1461 #[serde(rename = "nextPageToken")]
1462 pub next_page_token: Option<String>,
1463}
1464
1465impl common::ResponseResult for ListDevicesResponse {}
1466
1467/// Response to a request to list enrollment tokens for a given enterprise.
1468///
1469/// # Activities
1470///
1471/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1472/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1473///
1474/// * [enrollment tokens list enterprises](EnterpriseEnrollmentTokenListCall) (response)
1475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1476#[serde_with::serde_as]
1477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1478pub struct ListEnrollmentTokensResponse {
1479 /// The list of enrollment tokens.
1480 #[serde(rename = "enrollmentTokens")]
1481 pub enrollment_tokens: Option<Vec<EnrollmentToken>>,
1482 /// If there are more results, a token to retrieve next page of results.
1483 #[serde(rename = "nextPageToken")]
1484 pub next_page_token: Option<String>,
1485}
1486
1487impl common::ResponseResult for ListEnrollmentTokensResponse {}
1488
1489/// Response to a request to list enterprises.
1490///
1491/// # Activities
1492///
1493/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1494/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1495///
1496/// * [list enterprises](EnterpriseListCall) (response)
1497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1498#[serde_with::serde_as]
1499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1500pub struct ListEnterprisesResponse {
1501 /// The list of enterprises.
1502 pub enterprises: Option<Vec<Enterprise>>,
1503 /// If there are more results, a token to retrieve next page of results.
1504 #[serde(rename = "nextPageToken")]
1505 pub next_page_token: Option<String>,
1506}
1507
1508impl common::ResponseResult for ListEnterprisesResponse {}
1509
1510/// Response to a request to list migration tokens for a given enterprise.
1511///
1512/// # Activities
1513///
1514/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1515/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1516///
1517/// * [migration tokens list enterprises](EnterpriseMigrationTokenListCall) (response)
1518#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1519#[serde_with::serde_as]
1520#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1521pub struct ListMigrationTokensResponse {
1522 /// The migration tokens from the specified enterprise.
1523 #[serde(rename = "migrationTokens")]
1524 pub migration_tokens: Option<Vec<MigrationToken>>,
1525 /// A token, which can be sent as page_token to retrieve the next page. If this field is omitted, there are no subsequent pages.
1526 #[serde(rename = "nextPageToken")]
1527 pub next_page_token: Option<String>,
1528}
1529
1530impl common::ResponseResult for ListMigrationTokensResponse {}
1531
1532/// The response message for Operations.ListOperations.
1533///
1534/// # Activities
1535///
1536/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1537/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1538///
1539/// * [devices operations list enterprises](EnterpriseDeviceOperationListCall) (response)
1540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1541#[serde_with::serde_as]
1542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1543pub struct ListOperationsResponse {
1544 /// The standard List next-page token.
1545 #[serde(rename = "nextPageToken")]
1546 pub next_page_token: Option<String>,
1547 /// A list of operations that matches the specified filter in the request.
1548 pub operations: Option<Vec<Operation>>,
1549}
1550
1551impl common::ResponseResult for ListOperationsResponse {}
1552
1553/// Response to a request to list policies for a given enterprise.
1554///
1555/// # Activities
1556///
1557/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1558/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1559///
1560/// * [policies list enterprises](EnterprisePolicyListCall) (response)
1561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1562#[serde_with::serde_as]
1563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1564pub struct ListPoliciesResponse {
1565 /// If there are more results, a token to retrieve next page of results.
1566 #[serde(rename = "nextPageToken")]
1567 pub next_page_token: Option<String>,
1568 /// The list of policies.
1569 pub policies: Option<Vec<Policy>>,
1570}
1571
1572impl common::ResponseResult for ListPoliciesResponse {}
1573
1574/// Response to a request to list web apps for a given enterprise.
1575///
1576/// # Activities
1577///
1578/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1579/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1580///
1581/// * [web apps list enterprises](EnterpriseWebAppListCall) (response)
1582#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1583#[serde_with::serde_as]
1584#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1585pub struct ListWebAppsResponse {
1586 /// If there are more results, a token to retrieve next page of results.
1587 #[serde(rename = "nextPageToken")]
1588 pub next_page_token: Option<String>,
1589 /// The list of web apps.
1590 #[serde(rename = "webApps")]
1591 pub web_apps: Option<Vec<WebApp>>,
1592}
1593
1594impl common::ResponseResult for ListWebAppsResponse {}
1595
1596/// The managed configurations template for the app, saved from the managed configurations iframe.
1597///
1598/// This type is not used in any activity, and only used as *part* of another schema.
1599///
1600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1601#[serde_with::serde_as]
1602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1603pub struct ManagedConfigurationTemplate {
1604 /// Optional, a map containing configuration variables defined for the configuration.
1605 #[serde(rename = "configurationVariables")]
1606 pub configuration_variables: Option<HashMap<String, String>>,
1607 /// The ID of the managed configurations template.
1608 #[serde(rename = "templateId")]
1609 pub template_id: Option<String>,
1610}
1611
1612impl common::Part for ManagedConfigurationTemplate {}
1613
1614/// Managed property.
1615///
1616/// This type is not used in any activity, and only used as *part* of another schema.
1617///
1618#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1619#[serde_with::serde_as]
1620#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1621pub struct ManagedProperty {
1622 /// The default value of the property. BUNDLE_ARRAY properties don't have a default value.
1623 #[serde(rename = "defaultValue")]
1624 pub default_value: Option<serde_json::Value>,
1625 /// A longer description of the property, providing more detail of what it affects. Localized.
1626 pub description: Option<String>,
1627 /// For CHOICE or MULTISELECT properties, the list of possible entries.
1628 pub entries: Option<Vec<ManagedPropertyEntry>>,
1629 /// The unique key that the app uses to identify the property, e.g. "com.google.android.gm.fieldname".
1630 pub key: Option<String>,
1631 /// For BUNDLE_ARRAY properties, the list of nested properties. A BUNDLE_ARRAY property is at most two levels deep.
1632 #[serde(rename = "nestedProperties")]
1633 pub nested_properties: Option<Vec<ManagedProperty>>,
1634 /// The name of the property. Localized.
1635 pub title: Option<String>,
1636 /// The type of the property.
1637 #[serde(rename = "type")]
1638 pub type_: Option<String>,
1639}
1640
1641impl common::Part for ManagedProperty {}
1642
1643/// An entry of a managed property.
1644///
1645/// This type is not used in any activity, and only used as *part* of another schema.
1646///
1647#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1648#[serde_with::serde_as]
1649#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1650pub struct ManagedPropertyEntry {
1651 /// The human-readable name of the value. Localized.
1652 pub name: Option<String>,
1653 /// The machine-readable value of the entry, which should be used in the configuration. Not localized.
1654 pub value: Option<String>,
1655}
1656
1657impl common::Part for ManagedPropertyEntry {}
1658
1659/// An event related to memory and storage measurements.To distinguish between new and old events, we recommend using the createTime field.
1660///
1661/// This type is not used in any activity, and only used as *part* of another schema.
1662///
1663#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1664#[serde_with::serde_as]
1665#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1666pub struct MemoryEvent {
1667 /// The number of free bytes in the medium, or for EXTERNAL_STORAGE_DETECTED, the total capacity in bytes of the storage medium.
1668 #[serde(rename = "byteCount")]
1669 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1670 pub byte_count: Option<i64>,
1671 /// The creation time of the event.
1672 #[serde(rename = "createTime")]
1673 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1674 /// Event type.
1675 #[serde(rename = "eventType")]
1676 pub event_type: Option<String>,
1677}
1678
1679impl common::Part for MemoryEvent {}
1680
1681/// Information about device memory and storage.
1682///
1683/// This type is not used in any activity, and only used as *part* of another schema.
1684///
1685#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1686#[serde_with::serde_as]
1687#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1688pub struct MemoryInfo {
1689 /// Total internal storage on device in bytes.
1690 #[serde(rename = "totalInternalStorage")]
1691 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1692 pub total_internal_storage: Option<i64>,
1693 /// Total RAM on device in bytes.
1694 #[serde(rename = "totalRam")]
1695 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1696 pub total_ram: Option<i64>,
1697}
1698
1699impl common::Part for MemoryInfo {}
1700
1701/// A token to initiate the migration of a device from being managed by a third-party DPC to being managed by Android Management API. A migration token is valid only for a single device. See the guide (https://developers.google.com/android/management/dpc-migration) for more details.
1702///
1703/// # Activities
1704///
1705/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1706/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1707///
1708/// * [migration tokens create enterprises](EnterpriseMigrationTokenCreateCall) (request|response)
1709/// * [migration tokens get enterprises](EnterpriseMigrationTokenGetCall) (response)
1710#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1711#[serde_with::serde_as]
1712#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1713pub struct MigrationToken {
1714 /// Immutable. Optional EMM-specified additional data. Once the device is migrated this will be populated in the migrationAdditionalData field of the Device resource. This must be at most 1024 characters.
1715 #[serde(rename = "additionalData")]
1716 pub additional_data: Option<String>,
1717 /// Output only. Time when this migration token was created.
1718 #[serde(rename = "createTime")]
1719 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1720 /// Output only. Once this migration token is used to migrate a device, the name of the resulting Device resource will be populated here, in the form enterprises/{enterprise}/devices/{device}.
1721 pub device: Option<String>,
1722 /// Required. Immutable. The id of the device, as in the Play EMM API. This corresponds to the deviceId parameter in Play EMM API's Devices.get (https://developers.google.com/android/work/play/emm-api/v1/devices/get#parameters) call.
1723 #[serde(rename = "deviceId")]
1724 pub device_id: Option<String>,
1725 /// Immutable. The time when this migration token expires. This can be at most seven days from the time of creation. The migration token is deleted seven days after it expires.
1726 #[serde(rename = "expireTime")]
1727 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1728 /// Required. Immutable. The management mode of the device or profile being migrated.
1729 #[serde(rename = "managementMode")]
1730 pub management_mode: Option<String>,
1731 /// Output only. The name of the migration token, which is generated by the server during creation, in the form enterprises/{enterprise}/migrationTokens/{migration_token}.
1732 pub name: Option<String>,
1733 /// Required. Immutable. The name of the policy initially applied to the enrolled device, in the form enterprises/{enterprise}/policies/{policy}.
1734 pub policy: Option<String>,
1735 /// Input only. The time that this migration token is valid for. This is input-only, and for returning a migration token the server will populate the expireTime field. This can be at most seven days. The default is seven days.
1736 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1737 pub ttl: Option<chrono::Duration>,
1738 /// Required. Immutable. The user id of the Managed Google Play account on the device, as in the Play EMM API. This corresponds to the userId parameter in Play EMM API's Devices.get (https://developers.google.com/android/work/play/emm-api/v1/devices/get#parameters) call.
1739 #[serde(rename = "userId")]
1740 pub user_id: Option<String>,
1741 /// Output only. The value of the migration token.
1742 pub value: Option<String>,
1743}
1744
1745impl common::RequestValue for MigrationToken {}
1746impl common::ResponseResult for MigrationToken {}
1747
1748/// Device network info.
1749///
1750/// This type is not used in any activity, and only used as *part* of another schema.
1751///
1752#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1753#[serde_with::serde_as]
1754#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1755pub struct NetworkInfo {
1756 /// IMEI number of the GSM device. For example, A1000031212.
1757 pub imei: Option<String>,
1758 /// MEID number of the CDMA device. For example, A00000292788E1.
1759 pub meid: Option<String>,
1760 /// Alphabetic name of current registered operator. For example, Vodafone.
1761 #[serde(rename = "networkOperatorName")]
1762 pub network_operator_name: Option<String>,
1763 /// Provides telephony information associated with each SIM card on the device. Only supported on fully managed devices starting from Android API level 23.
1764 #[serde(rename = "telephonyInfos")]
1765 pub telephony_infos: Option<Vec<TelephonyInfo>>,
1766 /// Wi-Fi MAC address of the device. For example, 7c:11:11:11:11:11.
1767 #[serde(rename = "wifiMacAddress")]
1768 pub wifi_mac_address: Option<String>,
1769}
1770
1771impl common::Part for NetworkInfo {}
1772
1773/// Provides detail about non-compliance with a policy setting.
1774///
1775/// This type is not used in any activity, and only used as *part* of another schema.
1776///
1777#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1778#[serde_with::serde_as]
1779#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1780pub struct NonComplianceDetail {
1781 /// If the policy setting could not be applied, the current value of the setting on the device.
1782 #[serde(rename = "currentValue")]
1783 pub current_value: Option<serde_json::Value>,
1784 /// For settings with nested fields, if a particular nested field is out of compliance, this specifies the full path to the offending field. The path is formatted in the same way the policy JSON field would be referenced in JavaScript, that is: 1) For object-typed fields, the field name is followed by a dot then by a subfield name. 2) For array-typed fields, the field name is followed by the array index enclosed in brackets. For example, to indicate a problem with the url field in the externalData field in the 3rd application, the path would be applications[2].externalData.url
1785 #[serde(rename = "fieldPath")]
1786 pub field_path: Option<String>,
1787 /// If package_name is set and the non-compliance reason is APP_NOT_INSTALLED or APP_NOT_UPDATED, the detailed reason the app can't be installed or updated.
1788 #[serde(rename = "installationFailureReason")]
1789 pub installation_failure_reason: Option<String>,
1790 /// The reason the device is not in compliance with the setting.
1791 #[serde(rename = "nonComplianceReason")]
1792 pub non_compliance_reason: Option<String>,
1793 /// The package name indicating which app is out of compliance, if applicable.
1794 #[serde(rename = "packageName")]
1795 pub package_name: Option<String>,
1796 /// The name of the policy setting. This is the JSON field name of a top-level Policy field.
1797 #[serde(rename = "settingName")]
1798 pub setting_name: Option<String>,
1799 /// Additional context for specific_non_compliance_reason.
1800 #[serde(rename = "specificNonComplianceContext")]
1801 pub specific_non_compliance_context: Option<SpecificNonComplianceContext>,
1802 /// The policy-specific reason the device is not in compliance with the setting.
1803 #[serde(rename = "specificNonComplianceReason")]
1804 pub specific_non_compliance_reason: Option<String>,
1805}
1806
1807impl common::Part for NonComplianceDetail {}
1808
1809/// A compliance rule condition which is satisfied if there exists any matching NonComplianceDetail for the device. A NonComplianceDetail matches a NonComplianceDetailCondition if all the fields which are set within the NonComplianceDetailCondition match the corresponding NonComplianceDetail fields.
1810///
1811/// This type is not used in any activity, and only used as *part* of another schema.
1812///
1813#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1814#[serde_with::serde_as]
1815#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1816pub struct NonComplianceDetailCondition {
1817 /// The reason the device is not in compliance with the setting. If not set, then this condition matches any reason.
1818 #[serde(rename = "nonComplianceReason")]
1819 pub non_compliance_reason: Option<String>,
1820 /// The package name of the app that's out of compliance. If not set, then this condition matches any package name.
1821 #[serde(rename = "packageName")]
1822 pub package_name: Option<String>,
1823 /// The name of the policy setting. This is the JSON field name of a top-level Policy field. If not set, then this condition matches any setting name.
1824 #[serde(rename = "settingName")]
1825 pub setting_name: Option<String>,
1826}
1827
1828impl common::Part for NonComplianceDetailCondition {}
1829
1830/// This feature is not generally available.
1831///
1832/// This type is not used in any activity, and only used as *part* of another schema.
1833///
1834#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1835#[serde_with::serde_as]
1836#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1837pub struct OncCertificateProvider {
1838 /// This feature is not generally available.
1839 #[serde(rename = "certificateReferences")]
1840 pub certificate_references: Option<Vec<String>>,
1841 /// This feature is not generally available.
1842 #[serde(rename = "contentProviderEndpoint")]
1843 pub content_provider_endpoint: Option<ContentProviderEndpoint>,
1844}
1845
1846impl common::Part for OncCertificateProvider {}
1847
1848/// Additional context for non-compliance related to Wi-Fi configuration.
1849///
1850/// This type is not used in any activity, and only used as *part* of another schema.
1851///
1852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1853#[serde_with::serde_as]
1854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1855pub struct OncWifiContext {
1856 /// The GUID of non-compliant Wi-Fi configuration.
1857 #[serde(rename = "wifiGuid")]
1858 pub wifi_guid: Option<String>,
1859}
1860
1861impl common::Part for OncWifiContext {}
1862
1863/// This resource represents a long-running operation that is the result of a network API call.
1864///
1865/// # Activities
1866///
1867/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1868/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1869///
1870/// * [devices operations get enterprises](EnterpriseDeviceOperationGetCall) (response)
1871/// * [devices issue command enterprises](EnterpriseDeviceIssueCommandCall) (response)
1872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1873#[serde_with::serde_as]
1874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1875pub struct Operation {
1876 /// If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.
1877 pub done: Option<bool>,
1878 /// The error result of the operation in case of failure or cancellation.
1879 pub error: Option<Status>,
1880 /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
1881 pub metadata: Option<HashMap<String, serde_json::Value>>,
1882 /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the name should be a resource name ending with operations/{unique_id}.
1883 pub name: Option<String>,
1884 /// The normal, successful response of the operation. If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is standard Get/Create/Update, the response should be the resource. For other methods, the response should have the type XxxResponse, where Xxx is the original method name. For example, if the original method name is TakeSnapshot(), the inferred response type is TakeSnapshotResponse.
1885 pub response: Option<HashMap<String, serde_json::Value>>,
1886}
1887
1888impl common::ResponseResult for Operation {}
1889
1890/// A list of package names.
1891///
1892/// This type is not used in any activity, and only used as *part* of another schema.
1893///
1894#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1895#[serde_with::serde_as]
1896#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1897pub struct PackageNameList {
1898 /// A list of package names.
1899 #[serde(rename = "packageNames")]
1900 pub package_names: Option<Vec<String>>,
1901}
1902
1903impl common::Part for PackageNameList {}
1904
1905/// Additional context for non-compliance related to password policies.
1906///
1907/// This type is not used in any activity, and only used as *part* of another schema.
1908///
1909#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1910#[serde_with::serde_as]
1911#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1912pub struct PasswordPoliciesContext {
1913 /// The scope of non-compliant password.
1914 #[serde(rename = "passwordPolicyScope")]
1915 pub password_policy_scope: Option<String>,
1916}
1917
1918impl common::Part for PasswordPoliciesContext {}
1919
1920/// Requirements for the password used to unlock a device.
1921///
1922/// This type is not used in any activity, and only used as *part* of another schema.
1923///
1924#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1925#[serde_with::serde_as]
1926#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1927pub struct PasswordRequirements {
1928 /// Number of incorrect device-unlock passwords that can be entered before a device is wiped. A value of 0 means there is no restriction.
1929 #[serde(rename = "maximumFailedPasswordsForWipe")]
1930 pub maximum_failed_passwords_for_wipe: Option<i32>,
1931 /// Password expiration timeout.
1932 #[serde(rename = "passwordExpirationTimeout")]
1933 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1934 pub password_expiration_timeout: Option<chrono::Duration>,
1935 /// The length of the password history. After setting this field, the user won't be able to enter a new password that is the same as any password in the history. A value of 0 means there is no restriction.
1936 #[serde(rename = "passwordHistoryLength")]
1937 pub password_history_length: Option<i32>,
1938 /// The minimum allowed password length. A value of 0 means there is no restriction. Only enforced when password_quality is NUMERIC, NUMERIC_COMPLEX, ALPHABETIC, ALPHANUMERIC, or COMPLEX.
1939 #[serde(rename = "passwordMinimumLength")]
1940 pub password_minimum_length: Option<i32>,
1941 /// Minimum number of letters required in the password. Only enforced when password_quality is COMPLEX.
1942 #[serde(rename = "passwordMinimumLetters")]
1943 pub password_minimum_letters: Option<i32>,
1944 /// Minimum number of lower case letters required in the password. Only enforced when password_quality is COMPLEX.
1945 #[serde(rename = "passwordMinimumLowerCase")]
1946 pub password_minimum_lower_case: Option<i32>,
1947 /// Minimum number of non-letter characters (numerical digits or symbols) required in the password. Only enforced when password_quality is COMPLEX.
1948 #[serde(rename = "passwordMinimumNonLetter")]
1949 pub password_minimum_non_letter: Option<i32>,
1950 /// Minimum number of numerical digits required in the password. Only enforced when password_quality is COMPLEX.
1951 #[serde(rename = "passwordMinimumNumeric")]
1952 pub password_minimum_numeric: Option<i32>,
1953 /// Minimum number of symbols required in the password. Only enforced when password_quality is COMPLEX.
1954 #[serde(rename = "passwordMinimumSymbols")]
1955 pub password_minimum_symbols: Option<i32>,
1956 /// Minimum number of upper case letters required in the password. Only enforced when password_quality is COMPLEX.
1957 #[serde(rename = "passwordMinimumUpperCase")]
1958 pub password_minimum_upper_case: Option<i32>,
1959 /// The required password quality.
1960 #[serde(rename = "passwordQuality")]
1961 pub password_quality: Option<String>,
1962 /// The scope that the password requirement applies to.
1963 #[serde(rename = "passwordScope")]
1964 pub password_scope: Option<String>,
1965 /// The length of time after a device or work profile is unlocked using a strong form of authentication (password, PIN, pattern) that it can be unlocked using any other authentication method (e.g. fingerprint, trust agents, face). After the specified time period elapses, only strong forms of authentication can be used to unlock the device or work profile.
1966 #[serde(rename = "requirePasswordUnlock")]
1967 pub require_password_unlock: Option<String>,
1968 /// Controls whether a unified lock is allowed for the device and the work profile, on devices running Android 9 and above with a work profile. This can be set only if password_scope is set to SCOPE_PROFILE, the policy will be rejected otherwise. If user has not set a separate work lock and this field is set to REQUIRE_SEPARATE_WORK_LOCK, a NonComplianceDetail is reported with nonComplianceReason set to USER_ACTION.
1969 #[serde(rename = "unifiedLockSettings")]
1970 pub unified_lock_settings: Option<String>,
1971}
1972
1973impl common::Part for PasswordRequirements {}
1974
1975/// The result of an attempt to clear the data of a single app.
1976///
1977/// This type is not used in any activity, and only used as *part* of another schema.
1978///
1979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1980#[serde_with::serde_as]
1981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1982pub struct PerAppResult {
1983 /// The result of an attempt to clear the data of a single app.
1984 #[serde(rename = "clearingResult")]
1985 pub clearing_result: Option<String>,
1986}
1987
1988impl common::Part for PerAppResult {}
1989
1990/// Configuration for an Android permission and its grant state.
1991///
1992/// This type is not used in any activity, and only used as *part* of another schema.
1993///
1994#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1995#[serde_with::serde_as]
1996#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1997pub struct PermissionGrant {
1998 /// The Android permission or group, e.g. android.permission.READ_CALENDAR or android.permission_group.CALENDAR.
1999 pub permission: Option<String>,
2000 /// The policy for granting the permission.
2001 pub policy: Option<String>,
2002}
2003
2004impl common::Part for PermissionGrant {}
2005
2006/// A default activity for handling intents that match a particular intent filter. Note: To set up a kiosk, use InstallType to KIOSK rather than use persistent preferred activities.
2007///
2008/// This type is not used in any activity, and only used as *part* of another schema.
2009///
2010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2011#[serde_with::serde_as]
2012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2013pub struct PersistentPreferredActivity {
2014 /// The intent actions to match in the filter. If any actions are included in the filter, then an intent's action must be one of those values for it to match. If no actions are included, the intent action is ignored.
2015 pub actions: Option<Vec<String>>,
2016 /// The intent categories to match in the filter. An intent includes the categories that it requires, all of which must be included in the filter in order to match. In other words, adding a category to the filter has no impact on matching unless that category is specified in the intent.
2017 pub categories: Option<Vec<String>>,
2018 /// The activity that should be the default intent handler. This should be an Android component name, e.g. com.android.enterprise.app/.MainActivity. Alternatively, the value may be the package name of an app, which causes Android Device Policy to choose an appropriate activity from the app to handle the intent.
2019 #[serde(rename = "receiverActivity")]
2020 pub receiver_activity: Option<String>,
2021}
2022
2023impl common::Part for PersistentPreferredActivity {}
2024
2025/// Policies for apps in the personal profile of a company-owned device with a work profile.
2026///
2027/// This type is not used in any activity, and only used as *part* of another schema.
2028///
2029#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2030#[serde_with::serde_as]
2031#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2032pub struct PersonalApplicationPolicy {
2033 /// The type of installation to perform.
2034 #[serde(rename = "installType")]
2035 pub install_type: Option<String>,
2036 /// The package name of the application.
2037 #[serde(rename = "packageName")]
2038 pub package_name: Option<String>,
2039}
2040
2041impl common::Part for PersonalApplicationPolicy {}
2042
2043/// Policies controlling personal usage on a company-owned device with a work profile.
2044///
2045/// This type is not used in any activity, and only used as *part* of another schema.
2046///
2047#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2048#[serde_with::serde_as]
2049#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2050pub struct PersonalUsagePolicies {
2051 /// Account types that can't be managed by the user.
2052 #[serde(rename = "accountTypesWithManagementDisabled")]
2053 pub account_types_with_management_disabled: Option<Vec<String>>,
2054 /// If true, the camera is disabled on the personal profile.
2055 #[serde(rename = "cameraDisabled")]
2056 pub camera_disabled: Option<bool>,
2057 /// Controls how long the work profile can stay off. The minimum duration must be at least 3 days. Other details are as follows: - If the duration is set to 0, the feature is turned off. - If the duration is set to a value smaller than the minimum duration, the feature returns an error. *Note:* If you want to avoid personal profiles being suspended during long periods of off-time, you can temporarily set a large value for this parameter.
2058 #[serde(rename = "maxDaysWithWorkOff")]
2059 pub max_days_with_work_off: Option<i32>,
2060 /// Policy applied to applications in the personal profile.
2061 #[serde(rename = "personalApplications")]
2062 pub personal_applications: Option<Vec<PersonalApplicationPolicy>>,
2063 /// Used together with personalApplications to control how apps in the personal profile are allowed or blocked.
2064 #[serde(rename = "personalPlayStoreMode")]
2065 pub personal_play_store_mode: Option<String>,
2066 /// If true, screen capture is disabled for all users.
2067 #[serde(rename = "screenCaptureDisabled")]
2068 pub screen_capture_disabled: Option<bool>,
2069}
2070
2071impl common::Part for PersonalUsagePolicies {}
2072
2073/// A policy resource represents a group of settings that govern the behavior of a managed device and the apps installed on it.
2074///
2075/// # Activities
2076///
2077/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2078/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2079///
2080/// * [policies get enterprises](EnterprisePolicyGetCall) (response)
2081/// * [policies patch enterprises](EnterprisePolicyPatchCall) (request|response)
2082#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2083#[serde_with::serde_as]
2084#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2085pub struct Policy {
2086 /// Account types that can't be managed by the user.
2087 #[serde(rename = "accountTypesWithManagementDisabled")]
2088 pub account_types_with_management_disabled: Option<Vec<String>>,
2089 /// Whether adding new users and profiles is disabled.
2090 #[serde(rename = "addUserDisabled")]
2091 pub add_user_disabled: Option<bool>,
2092 /// Whether adjusting the master volume is disabled. Also mutes the device.
2093 #[serde(rename = "adjustVolumeDisabled")]
2094 pub adjust_volume_disabled: Option<bool>,
2095 /// Advanced security settings. In most cases, setting these is not needed.
2096 #[serde(rename = "advancedSecurityOverrides")]
2097 pub advanced_security_overrides: Option<AdvancedSecurityOverrides>,
2098 /// Configuration for an always-on VPN connection. Use with vpn_config_disabled to prevent modification of this setting.
2099 #[serde(rename = "alwaysOnVpnPackage")]
2100 pub always_on_vpn_package: Option<AlwaysOnVpnPackage>,
2101 /// This setting is not supported. Any value is ignored.
2102 #[serde(rename = "androidDevicePolicyTracks")]
2103 pub android_device_policy_tracks: Option<Vec<String>>,
2104 /// Recommended alternative: autoUpdateMode which is set per app, provides greater flexibility around update frequency.When autoUpdateMode is set to AUTO_UPDATE_POSTPONED or AUTO_UPDATE_HIGH_PRIORITY, this field has no effect.The app auto update policy, which controls when automatic app updates can be applied.
2105 #[serde(rename = "appAutoUpdatePolicy")]
2106 pub app_auto_update_policy: Option<String>,
2107 /// Policy applied to apps. This can have at most 3,000 elements.
2108 pub applications: Option<Vec<ApplicationPolicy>>,
2109 /// Whether auto date, time, and time zone are enabled on a company-owned device. If this is set, then autoTimeRequired is ignored.
2110 #[serde(rename = "autoDateAndTimeZone")]
2111 pub auto_date_and_time_zone: Option<String>,
2112 /// Whether auto time is required, which prevents the user from manually setting the date and time. If autoDateAndTimeZone is set, this field is ignored.
2113 #[serde(rename = "autoTimeRequired")]
2114 pub auto_time_required: Option<bool>,
2115 /// Whether applications other than the ones configured in applications are blocked from being installed. When set, applications that were installed under a previous policy but no longer appear in the policy are automatically uninstalled.
2116 #[serde(rename = "blockApplicationsEnabled")]
2117 pub block_applications_enabled: Option<bool>,
2118 /// Whether configuring bluetooth is disabled.
2119 #[serde(rename = "bluetoothConfigDisabled")]
2120 pub bluetooth_config_disabled: Option<bool>,
2121 /// Whether bluetooth contact sharing is disabled.
2122 #[serde(rename = "bluetoothContactSharingDisabled")]
2123 pub bluetooth_contact_sharing_disabled: Option<bool>,
2124 /// Whether bluetooth is disabled. Prefer this setting over bluetooth_config_disabled because bluetooth_config_disabled can be bypassed by the user.
2125 #[serde(rename = "bluetoothDisabled")]
2126 pub bluetooth_disabled: Option<bool>,
2127 /// Controls the use of the camera and whether the user has access to the camera access toggle.
2128 #[serde(rename = "cameraAccess")]
2129 pub camera_access: Option<String>,
2130 /// If camera_access is set to any value other than CAMERA_ACCESS_UNSPECIFIED, this has no effect. Otherwise this field controls whether cameras are disabled: If true, all cameras are disabled, otherwise they are available. For fully managed devices this field applies for all apps on the device. For work profiles, this field applies only to apps in the work profile, and the camera access of apps outside the work profile is unaffected.
2131 #[serde(rename = "cameraDisabled")]
2132 pub camera_disabled: Option<bool>,
2133 /// Whether configuring cell broadcast is disabled.
2134 #[serde(rename = "cellBroadcastsConfigDisabled")]
2135 pub cell_broadcasts_config_disabled: Option<bool>,
2136 /// Rules for determining apps' access to private keys. See ChoosePrivateKeyRule for details. This must be empty if any application has CERT_SELECTION delegation scope.
2137 #[serde(rename = "choosePrivateKeyRules")]
2138 pub choose_private_key_rules: Option<Vec<ChoosePrivateKeyRule>>,
2139 /// Rules declaring which mitigating actions to take when a device is not compliant with its policy. When the conditions for multiple rules are satisfied, all of the mitigating actions for the rules are taken. There is a maximum limit of 100 rules. Use policy enforcement rules instead.
2140 #[serde(rename = "complianceRules")]
2141 pub compliance_rules: Option<Vec<ComplianceRule>>,
2142 /// Whether creating windows besides app windows is disabled.
2143 #[serde(rename = "createWindowsDisabled")]
2144 pub create_windows_disabled: Option<bool>,
2145 /// Controls which apps are allowed to act as credential providers on Android 14 and above. These apps store credentials, see this (https://developer.android.com/training/sign-in/passkeys) and this (https://developer.android.com/reference/androidx/credentials/CredentialManager) for details. See also credentialProviderPolicy.
2146 #[serde(rename = "credentialProviderPolicyDefault")]
2147 pub credential_provider_policy_default: Option<String>,
2148 /// Whether configuring user credentials is disabled.
2149 #[serde(rename = "credentialsConfigDisabled")]
2150 pub credentials_config_disabled: Option<bool>,
2151 /// Cross-profile policies applied on the device.
2152 #[serde(rename = "crossProfilePolicies")]
2153 pub cross_profile_policies: Option<CrossProfilePolicies>,
2154 /// Whether roaming data services are disabled.
2155 #[serde(rename = "dataRoamingDisabled")]
2156 pub data_roaming_disabled: Option<bool>,
2157 /// Whether the user is allowed to enable debugging features.
2158 #[serde(rename = "debuggingFeaturesAllowed")]
2159 pub debugging_features_allowed: Option<bool>,
2160 /// The default permission policy for runtime permission requests.
2161 #[serde(rename = "defaultPermissionPolicy")]
2162 pub default_permission_policy: Option<String>,
2163 /// Covers controls for device connectivity such as Wi-Fi, USB data access, keyboard/mouse connections, and more.
2164 #[serde(rename = "deviceConnectivityManagement")]
2165 pub device_connectivity_management: Option<DeviceConnectivityManagement>,
2166 /// The device owner information to be shown on the lock screen.
2167 #[serde(rename = "deviceOwnerLockScreenInfo")]
2168 pub device_owner_lock_screen_info: Option<UserFacingMessage>,
2169 /// Covers controls for radio state such as Wi-Fi, bluetooth, and more.
2170 #[serde(rename = "deviceRadioState")]
2171 pub device_radio_state: Option<DeviceRadioState>,
2172 /// Optional. Controls for the display settings.
2173 #[serde(rename = "displaySettings")]
2174 pub display_settings: Option<DisplaySettings>,
2175 /// Whether encryption is enabled
2176 #[serde(rename = "encryptionPolicy")]
2177 pub encryption_policy: Option<String>,
2178 /// Whether app verification is force-enabled.
2179 #[serde(rename = "ensureVerifyAppsEnabled")]
2180 pub ensure_verify_apps_enabled: Option<bool>,
2181 /// Whether factory resetting from settings is disabled.
2182 #[serde(rename = "factoryResetDisabled")]
2183 pub factory_reset_disabled: Option<bool>,
2184 /// Email addresses of device administrators for factory reset protection. When the device is factory reset, it will require one of these admins to log in with the Google account email and password to unlock the device. If no admins are specified, the device won't provide factory reset protection.
2185 #[serde(rename = "frpAdminEmails")]
2186 pub frp_admin_emails: Option<Vec<String>>,
2187 /// Whether the user is allowed to have fun. Controls whether the Easter egg game in Settings is disabled.
2188 #[serde(rename = "funDisabled")]
2189 pub fun_disabled: Option<bool>,
2190 /// Whether user installation of apps is disabled.
2191 #[serde(rename = "installAppsDisabled")]
2192 pub install_apps_disabled: Option<bool>,
2193 /// This field has no effect.
2194 #[serde(rename = "installUnknownSourcesAllowed")]
2195 pub install_unknown_sources_allowed: Option<bool>,
2196 /// If true, this disables the Lock Screen (https://source.android.com/docs/core/display/multi_display/lock-screen) for primary and/or secondary displays.
2197 #[serde(rename = "keyguardDisabled")]
2198 pub keyguard_disabled: Option<bool>,
2199 /// Disabled keyguard customizations, such as widgets.
2200 #[serde(rename = "keyguardDisabledFeatures")]
2201 pub keyguard_disabled_features: Option<Vec<String>>,
2202 /// Whether the kiosk custom launcher is enabled. This replaces the home screen with a launcher that locks down the device to the apps installed via the applications setting. Apps appear on a single page in alphabetical order. Use kioskCustomization to further configure the kiosk device behavior.
2203 #[serde(rename = "kioskCustomLauncherEnabled")]
2204 pub kiosk_custom_launcher_enabled: Option<bool>,
2205 /// Settings controlling the behavior of a device in kiosk mode. To enable kiosk mode, set kioskCustomLauncherEnabled to true or specify an app in the policy with installType KIOSK.
2206 #[serde(rename = "kioskCustomization")]
2207 pub kiosk_customization: Option<KioskCustomization>,
2208 /// The degree of location detection enabled.
2209 #[serde(rename = "locationMode")]
2210 pub location_mode: Option<String>,
2211 /// A message displayed to the user in the device administators settings screen.
2212 #[serde(rename = "longSupportMessage")]
2213 pub long_support_message: Option<UserFacingMessage>,
2214 /// Maximum time in milliseconds for user activity until the device locks. A value of 0 means there is no restriction.
2215 #[serde(rename = "maximumTimeToLock")]
2216 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2217 pub maximum_time_to_lock: Option<i64>,
2218 /// Controls the use of the microphone and whether the user has access to the microphone access toggle. This applies only on fully managed devices.
2219 #[serde(rename = "microphoneAccess")]
2220 pub microphone_access: Option<String>,
2221 /// The minimum allowed Android API level.
2222 #[serde(rename = "minimumApiLevel")]
2223 pub minimum_api_level: Option<i32>,
2224 /// Whether configuring mobile networks is disabled.
2225 #[serde(rename = "mobileNetworksConfigDisabled")]
2226 pub mobile_networks_config_disabled: Option<bool>,
2227 /// Whether adding or removing accounts is disabled.
2228 #[serde(rename = "modifyAccountsDisabled")]
2229 pub modify_accounts_disabled: Option<bool>,
2230 /// Whether the user mounting physical external media is disabled.
2231 #[serde(rename = "mountPhysicalMediaDisabled")]
2232 pub mount_physical_media_disabled: Option<bool>,
2233 /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}.
2234 pub name: Option<String>,
2235 /// Whether the network escape hatch is enabled. If a network connection can't be made at boot time, the escape hatch prompts the user to temporarily connect to a network in order to refresh the device policy. After applying policy, the temporary network will be forgotten and the device will continue booting. This prevents being unable to connect to a network if there is no suitable network in the last policy and the device boots into an app in lock task mode, or the user is otherwise unable to reach device settings.Note: Setting wifiConfigDisabled to true will override this setting under specific circumstances. Please see wifiConfigDisabled for further details. Setting configureWifi to DISALLOW_CONFIGURING_WIFI will override this setting under specific circumstances. Please see DISALLOW_CONFIGURING_WIFI for further details.
2236 #[serde(rename = "networkEscapeHatchEnabled")]
2237 pub network_escape_hatch_enabled: Option<bool>,
2238 /// Whether resetting network settings is disabled.
2239 #[serde(rename = "networkResetDisabled")]
2240 pub network_reset_disabled: Option<bool>,
2241 /// This feature is not generally available.
2242 #[serde(rename = "oncCertificateProviders")]
2243 pub onc_certificate_providers: Option<Vec<OncCertificateProvider>>,
2244 /// Network configuration for the device. See configure networks for more information.
2245 #[serde(rename = "openNetworkConfiguration")]
2246 pub open_network_configuration: Option<HashMap<String, serde_json::Value>>,
2247 /// Whether using NFC to beam data from apps is disabled.
2248 #[serde(rename = "outgoingBeamDisabled")]
2249 pub outgoing_beam_disabled: Option<bool>,
2250 /// Whether outgoing calls are disabled.
2251 #[serde(rename = "outgoingCallsDisabled")]
2252 pub outgoing_calls_disabled: Option<bool>,
2253 /// Password requirement policies. Different policies can be set for work profile or fully managed devices by setting the password_scope field in the policy.
2254 #[serde(rename = "passwordPolicies")]
2255 pub password_policies: Option<Vec<PasswordRequirements>>,
2256 /// Password requirements. The field password_requirements.require_password_unlock must not be set. DEPRECATED - Use passwordPolicies.Note:Complexity-based values of PasswordQuality, that is, COMPLEXITY_LOW, COMPLEXITY_MEDIUM, and COMPLEXITY_HIGH, cannot be used here. unified_lock_settings cannot be used here.
2257 #[serde(rename = "passwordRequirements")]
2258 pub password_requirements: Option<PasswordRequirements>,
2259 /// Explicit permission or group grants or denials for all apps. These values override the default_permission_policy.
2260 #[serde(rename = "permissionGrants")]
2261 pub permission_grants: Option<Vec<PermissionGrant>>,
2262 /// Specifies permitted accessibility services. If the field is not set, any accessibility service can be used. If the field is set, only the accessibility services in this list and the system's built-in accessibility service can be used. In particular, if the field is set to empty, only the system's built-in accessibility servicess can be used. This can be set on fully managed devices and on work profiles. When applied to a work profile, this affects both the personal profile and the work profile.
2263 #[serde(rename = "permittedAccessibilityServices")]
2264 pub permitted_accessibility_services: Option<PackageNameList>,
2265 /// If present, only the input methods provided by packages in this list are permitted. If this field is present, but the list is empty, then only system input methods are permitted.
2266 #[serde(rename = "permittedInputMethods")]
2267 pub permitted_input_methods: Option<PackageNameList>,
2268 /// Default intent handler activities.
2269 #[serde(rename = "persistentPreferredActivities")]
2270 pub persistent_preferred_activities: Option<Vec<PersistentPreferredActivity>>,
2271 /// Policies managing personal usage on a company-owned device.
2272 #[serde(rename = "personalUsagePolicies")]
2273 pub personal_usage_policies: Option<PersonalUsagePolicies>,
2274 /// This mode controls which apps are available to the user in the Play Store and the behavior on the device when apps are removed from the policy.
2275 #[serde(rename = "playStoreMode")]
2276 pub play_store_mode: Option<String>,
2277 /// Rules that define the behavior when a particular policy can not be applied on device
2278 #[serde(rename = "policyEnforcementRules")]
2279 pub policy_enforcement_rules: Option<Vec<PolicyEnforcementRule>>,
2280 /// Controls whether preferential network service is enabled on the work profile. For example, an organization may have an agreement with a carrier that all of the work data from its employees' devices will be sent via a network service dedicated for enterprise use. An example of a supported preferential network service is the enterprise slice on 5G networks. This has no effect on fully managed devices.
2281 #[serde(rename = "preferentialNetworkService")]
2282 pub preferential_network_service: Option<String>,
2283 /// Optional. Controls whether printing is allowed. This is supported on devices running Android 9 and above. .
2284 #[serde(rename = "printingPolicy")]
2285 pub printing_policy: Option<String>,
2286 /// Allows showing UI on a device for a user to choose a private key alias if there are no matching rules in ChoosePrivateKeyRules. For devices below Android P, setting this may leave enterprise keys vulnerable. This value will have no effect if any application has CERT_SELECTION delegation scope.
2287 #[serde(rename = "privateKeySelectionEnabled")]
2288 pub private_key_selection_enabled: Option<bool>,
2289 /// The network-independent global HTTP proxy. Typically proxies should be configured per-network in open_network_configuration. However for unusual configurations like general internal filtering a global HTTP proxy may be useful. If the proxy is not accessible, network access may break. The global proxy is only a recommendation and some apps may ignore it.
2290 #[serde(rename = "recommendedGlobalProxy")]
2291 pub recommended_global_proxy: Option<ProxyInfo>,
2292 /// Whether removing other users is disabled.
2293 #[serde(rename = "removeUserDisabled")]
2294 pub remove_user_disabled: Option<bool>,
2295 /// Whether rebooting the device into safe boot is disabled.
2296 #[serde(rename = "safeBootDisabled")]
2297 pub safe_boot_disabled: Option<bool>,
2298 /// Whether screen capture is disabled.
2299 #[serde(rename = "screenCaptureDisabled")]
2300 pub screen_capture_disabled: Option<bool>,
2301 /// Whether changing the user icon is disabled.
2302 #[serde(rename = "setUserIconDisabled")]
2303 pub set_user_icon_disabled: Option<bool>,
2304 /// Whether changing the wallpaper is disabled.
2305 #[serde(rename = "setWallpaperDisabled")]
2306 pub set_wallpaper_disabled: Option<bool>,
2307 /// Action to take during the setup process. At most one action may be specified.
2308 #[serde(rename = "setupActions")]
2309 pub setup_actions: Option<Vec<SetupAction>>,
2310 /// Whether location sharing is disabled. share_location_disabled is supported for both fully managed devices and personally owned work profiles.
2311 #[serde(rename = "shareLocationDisabled")]
2312 pub share_location_disabled: Option<bool>,
2313 /// A message displayed to the user in the settings screen wherever functionality has been disabled by the admin. If the message is longer than 200 characters it may be truncated.
2314 #[serde(rename = "shortSupportMessage")]
2315 pub short_support_message: Option<UserFacingMessage>,
2316 /// Flag to skip hints on the first use. Enterprise admin can enable the system recommendation for apps to skip their user tutorial and other introductory hints on first start-up.
2317 #[serde(rename = "skipFirstUseHintsEnabled")]
2318 pub skip_first_use_hints_enabled: Option<bool>,
2319 /// Whether sending and receiving SMS messages is disabled.
2320 #[serde(rename = "smsDisabled")]
2321 pub sms_disabled: Option<bool>,
2322 /// Whether the status bar is disabled. This disables notifications, quick settings, and other screen overlays that allow escape from full-screen mode. DEPRECATED. To disable the status bar on a kiosk device, use InstallType KIOSK or kioskCustomLauncherEnabled.
2323 #[serde(rename = "statusBarDisabled")]
2324 pub status_bar_disabled: Option<bool>,
2325 /// Status reporting settings
2326 #[serde(rename = "statusReportingSettings")]
2327 pub status_reporting_settings: Option<StatusReportingSettings>,
2328 /// The battery plugged in modes for which the device stays on. When using this setting, it is recommended to clear maximum_time_to_lock so that the device doesn't lock itself while it stays on.
2329 #[serde(rename = "stayOnPluggedModes")]
2330 pub stay_on_plugged_modes: Option<Vec<String>>,
2331 /// The system update policy, which controls how OS updates are applied. If the update type is WINDOWED, the update window will automatically apply to Play app updates as well.Note: Google Play system updates (https://source.android.com/docs/core/ota/modular-system) (also called Mainline updates) are automatically downloaded and require a device reboot to be installed. Refer to the mainline section in Manage system updates (https://developer.android.com/work/dpc/system-updates#mainline) for further details.
2332 #[serde(rename = "systemUpdate")]
2333 pub system_update: Option<SystemUpdate>,
2334 /// Whether configuring tethering and portable hotspots is disabled. If tetheringSettings is set to anything other than TETHERING_SETTINGS_UNSPECIFIED, this setting is ignored.
2335 #[serde(rename = "tetheringConfigDisabled")]
2336 pub tethering_config_disabled: Option<bool>,
2337 /// Whether user uninstallation of applications is disabled. This prevents apps from being uninstalled, even those removed using applications
2338 #[serde(rename = "uninstallAppsDisabled")]
2339 pub uninstall_apps_disabled: Option<bool>,
2340 /// If microphone_access is set to any value other than MICROPHONE_ACCESS_UNSPECIFIED, this has no effect. Otherwise this field controls whether microphones are disabled: If true, all microphones are disabled, otherwise they are available. This is available only on fully managed devices.
2341 #[serde(rename = "unmuteMicrophoneDisabled")]
2342 pub unmute_microphone_disabled: Option<bool>,
2343 /// Configuration of device activity logging.
2344 #[serde(rename = "usageLog")]
2345 pub usage_log: Option<UsageLog>,
2346 /// Whether transferring files over USB is disabled. This is supported only on company-owned devices.
2347 #[serde(rename = "usbFileTransferDisabled")]
2348 pub usb_file_transfer_disabled: Option<bool>,
2349 /// Whether USB storage is enabled. Deprecated.
2350 #[serde(rename = "usbMassStorageEnabled")]
2351 pub usb_mass_storage_enabled: Option<bool>,
2352 /// The version of the policy. This is a read-only field. The version is incremented each time the policy is updated.
2353 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2354 pub version: Option<i64>,
2355 /// Whether configuring VPN is disabled.
2356 #[serde(rename = "vpnConfigDisabled")]
2357 pub vpn_config_disabled: Option<bool>,
2358 /// Whether configuring Wi-Fi networks is disabled. Supported on fully managed devices and work profiles on company-owned devices. For fully managed devices, setting this to true removes all configured networks and retains only the networks configured using openNetworkConfiguration. For work profiles on company-owned devices, existing configured networks are not affected and the user is not allowed to add, remove, or modify Wi-Fi networks. If configureWifi is set to anything other than CONFIGURE_WIFI_UNSPECIFIED, this setting is ignored. Note: If a network connection can't be made at boot time and configuring Wi-Fi is disabled then network escape hatch will be shown in order to refresh the device policy (see networkEscapeHatchEnabled).
2359 #[serde(rename = "wifiConfigDisabled")]
2360 pub wifi_config_disabled: Option<bool>,
2361 /// DEPRECATED - Use wifi_config_disabled.
2362 #[serde(rename = "wifiConfigsLockdownEnabled")]
2363 pub wifi_configs_lockdown_enabled: Option<bool>,
2364}
2365
2366impl common::RequestValue for Policy {}
2367impl common::ResponseResult for Policy {}
2368
2369/// A rule that defines the actions to take if a device or work profile is not compliant with the policy specified in settingName. In the case of multiple matching or multiple triggered enforcement rules, a merge will occur with the most severe action being taken. However, all triggered rules are still kept track of: this includes initial trigger time and all associated non-compliance details. In the situation where the most severe enforcement rule is satisfied, the next most appropriate action is applied.
2370///
2371/// This type is not used in any activity, and only used as *part* of another schema.
2372///
2373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2374#[serde_with::serde_as]
2375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2376pub struct PolicyEnforcementRule {
2377 /// An action to block access to apps and data on a company owned device or in a work profile. This action also triggers a user-facing notification with information (where possible) on how to correct the compliance issue. Note: wipeAction must also be specified.
2378 #[serde(rename = "blockAction")]
2379 pub block_action: Option<BlockAction>,
2380 /// The top-level policy to enforce. For example, applications or passwordPolicies.
2381 #[serde(rename = "settingName")]
2382 pub setting_name: Option<String>,
2383 /// An action to reset a company owned device or delete a work profile. Note: blockAction must also be specified.
2384 #[serde(rename = "wipeAction")]
2385 pub wipe_action: Option<WipeAction>,
2386}
2387
2388impl common::Part for PolicyEnforcementRule {}
2389
2390/// Additional details regarding the security posture of the device.
2391///
2392/// This type is not used in any activity, and only used as *part* of another schema.
2393///
2394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2395#[serde_with::serde_as]
2396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2397pub struct PostureDetail {
2398 /// Corresponding admin-facing advice to mitigate this security risk and improve the security posture of the device.
2399 pub advice: Option<Vec<UserFacingMessage>>,
2400 /// A specific security risk that negatively affects the security posture of the device.
2401 #[serde(rename = "securityRisk")]
2402 pub security_risk: Option<String>,
2403}
2404
2405impl common::Part for PostureDetail {}
2406
2407/// A power management event.
2408///
2409/// This type is not used in any activity, and only used as *part* of another schema.
2410///
2411#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2412#[serde_with::serde_as]
2413#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2414pub struct PowerManagementEvent {
2415 /// For BATTERY_LEVEL_COLLECTED events, the battery level as a percentage.
2416 #[serde(rename = "batteryLevel")]
2417 pub battery_level: Option<f32>,
2418 /// The creation time of the event.
2419 #[serde(rename = "createTime")]
2420 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2421 /// Event type.
2422 #[serde(rename = "eventType")]
2423 pub event_type: Option<String>,
2424}
2425
2426impl common::Part for PowerManagementEvent {}
2427
2428/// Information about a device that is available during setup.
2429///
2430/// # Activities
2431///
2432/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2433/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2434///
2435/// * [get provisioning info](ProvisioningInfoGetCall) (response)
2436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2437#[serde_with::serde_as]
2438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2439pub struct ProvisioningInfo {
2440 /// The API level of the Android platform version running on the device.
2441 #[serde(rename = "apiLevel")]
2442 pub api_level: Option<i32>,
2443 /// The email address of the authenticated user (only present for Google Account provisioning method).
2444 #[serde(rename = "authenticatedUserEmail")]
2445 pub authenticated_user_email: Option<String>,
2446 /// The brand of the device. For example, Google.
2447 pub brand: Option<String>,
2448 /// The name of the enterprise in the form enterprises/{enterprise}.
2449 pub enterprise: Option<String>,
2450 /// For corporate-owned devices, IMEI number of the GSM device. For example, A1000031212.
2451 pub imei: Option<String>,
2452 /// The management mode of the device or profile.
2453 #[serde(rename = "managementMode")]
2454 pub management_mode: Option<String>,
2455 /// For corporate-owned devices, MEID number of the CDMA device. For example, A00000292788E1.
2456 pub meid: Option<String>,
2457 /// The model of the device. For example, Asus Nexus 7.
2458 pub model: Option<String>,
2459 /// The name of this resource in the form provisioningInfo/{provisioning_info}.
2460 pub name: Option<String>,
2461 /// Ownership of the managed device.
2462 pub ownership: Option<String>,
2463 /// For corporate-owned devices, The device serial number.
2464 #[serde(rename = "serialNumber")]
2465 pub serial_number: Option<String>,
2466}
2467
2468impl common::ResponseResult for ProvisioningInfo {}
2469
2470/// Configuration info for an HTTP proxy. For a direct proxy, set the host, port, and excluded_hosts fields. For a PAC script proxy, set the pac_uri field.
2471///
2472/// This type is not used in any activity, and only used as *part* of another schema.
2473///
2474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2475#[serde_with::serde_as]
2476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2477pub struct ProxyInfo {
2478 /// For a direct proxy, the hosts for which the proxy is bypassed. The host names may contain wildcards such as *.example.com.
2479 #[serde(rename = "excludedHosts")]
2480 pub excluded_hosts: Option<Vec<String>>,
2481 /// The host of the direct proxy.
2482 pub host: Option<String>,
2483 /// The URI of the PAC script used to configure the proxy.
2484 #[serde(rename = "pacUri")]
2485 pub pac_uri: Option<String>,
2486 /// The port of the direct proxy.
2487 pub port: Option<i32>,
2488}
2489
2490impl common::Part for ProxyInfo {}
2491
2492/// Controls for the screen brightness settings.
2493///
2494/// This type is not used in any activity, and only used as *part* of another schema.
2495///
2496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2497#[serde_with::serde_as]
2498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2499pub struct ScreenBrightnessSettings {
2500 /// Optional. The screen brightness between 1 and 255 where 1 is the lowest and 255 is the highest brightness. A value of 0 (default) means no screen brightness set. Any other value is rejected. screenBrightnessMode must be either BRIGHTNESS_AUTOMATIC or BRIGHTNESS_FIXED to set this. Supported on Android 9 and above on fully managed devices. A NonComplianceDetail with API_LEVEL is reported if the Android version is less than 9.
2501 #[serde(rename = "screenBrightness")]
2502 pub screen_brightness: Option<i32>,
2503 /// Optional. Controls the screen brightness mode.
2504 #[serde(rename = "screenBrightnessMode")]
2505 pub screen_brightness_mode: Option<String>,
2506}
2507
2508impl common::Part for ScreenBrightnessSettings {}
2509
2510/// Controls the screen timeout settings.
2511///
2512/// This type is not used in any activity, and only used as *part* of another schema.
2513///
2514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2515#[serde_with::serde_as]
2516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2517pub struct ScreenTimeoutSettings {
2518 /// Optional. Controls the screen timeout duration. The screen timeout duration must be greater than 0, otherwise it is rejected. Additionally, it should not be greater than maximumTimeToLock, otherwise the screen timeout is set to maximumTimeToLock and a NonComplianceDetail with INVALID_VALUE reason and SCREEN_TIMEOUT_GREATER_THAN_MAXIMUM_TIME_TO_LOCK specific reason is reported. If the screen timeout is less than a certain lower bound, it is set to the lower bound. The lower bound may vary across devices. If this is set, screenTimeoutMode must be SCREEN_TIMEOUT_ENFORCED. Supported on Android 9 and above on fully managed devices. A NonComplianceDetail with API_LEVEL is reported if the Android version is less than 9.
2519 #[serde(rename = "screenTimeout")]
2520 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2521 pub screen_timeout: Option<chrono::Duration>,
2522 /// Optional. Controls whether the user is allowed to configure the screen timeout.
2523 #[serde(rename = "screenTimeoutMode")]
2524 pub screen_timeout_mode: Option<String>,
2525}
2526
2527impl common::Part for ScreenTimeoutSettings {}
2528
2529/// The security posture of the device, as determined by the current device state and the policies applied.
2530///
2531/// This type is not used in any activity, and only used as *part* of another schema.
2532///
2533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2534#[serde_with::serde_as]
2535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2536pub struct SecurityPosture {
2537 /// Device's security posture value.
2538 #[serde(rename = "devicePosture")]
2539 pub device_posture: Option<String>,
2540 /// Additional details regarding the security posture of the device.
2541 #[serde(rename = "postureDetails")]
2542 pub posture_details: Option<Vec<PostureDetail>>,
2543}
2544
2545impl common::Part for SecurityPosture {}
2546
2547/// An action executed during setup.
2548///
2549/// This type is not used in any activity, and only used as *part* of another schema.
2550///
2551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2552#[serde_with::serde_as]
2553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2554pub struct SetupAction {
2555 /// Description of this action.
2556 pub description: Option<UserFacingMessage>,
2557 /// An action to launch an app. The app will be launched with an intent containing an extra with key com.google.android.apps.work.clouddpc.EXTRA_LAUNCHED_AS_SETUP_ACTION set to the boolean value true to indicate that this is a setup action flow. If SetupAction references an app, the corresponding installType in the application policy must be set as REQUIRED_FOR_SETUP or said setup will fail.
2558 #[serde(rename = "launchApp")]
2559 pub launch_app: Option<LaunchAppAction>,
2560 /// Title of this action.
2561 pub title: Option<UserFacingMessage>,
2562}
2563
2564impl common::Part for SetupAction {}
2565
2566/// A resource containing sign in details for an enterprise. Use enterprises to manage SigninDetails for a given enterprise.For an enterprise, we can have any number of SigninDetails that is uniquely identified by combination of the following three fields (signin_url, allow_personal_usage, token_tag). One cannot create two SigninDetails with the same (signin_url, allow_personal_usage, token_tag). (token_tag is an optional field).Patch: The operation updates the current list of SigninDetails with the new list of SigninDetails. If the stored SigninDetail configuration is passed, it returns the same signin_enrollment_token and qr_code. If we pass multiple identical SigninDetail configurations that are not stored, it will store the first one amongst those SigninDetail configurations. if the configuration already exists we cannot request it more than once in a particular patch API call, otherwise it will give a duplicate key error and the whole operation will fail. If we remove certain SigninDetail configuration from the request then it will get removed from the storage. We can then request another signin_enrollment_token and qr_code for the same SigninDetail configuration.
2567///
2568/// This type is not used in any activity, and only used as *part* of another schema.
2569///
2570#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2571#[serde_with::serde_as]
2572#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2573pub struct SigninDetail {
2574 /// Controls whether personal usage is allowed on a device provisioned with this enrollment token.For company-owned devices: Enabling personal usage allows the user to set up a work profile on the device. Disabling personal usage requires the user provision the device as a fully managed device.For personally-owned devices: Enabling personal usage allows the user to set up a work profile on the device. Disabling personal usage will prevent the device from provisioning. Personal usage cannot be disabled on personally-owned device.
2575 #[serde(rename = "allowPersonalUsage")]
2576 pub allow_personal_usage: Option<String>,
2577 /// A JSON string whose UTF-8 representation can be used to generate a QR code to enroll a device with this enrollment token. To enroll a device using NFC, the NFC record must contain a serialized java.util.Properties representation of the properties in the JSON. This is a read-only field generated by the server.
2578 #[serde(rename = "qrCode")]
2579 pub qr_code: Option<String>,
2580 /// An enterprise wide enrollment token used to trigger custom sign-in flow. This is a read-only field generated by the server.
2581 #[serde(rename = "signinEnrollmentToken")]
2582 pub signin_enrollment_token: Option<String>,
2583 /// Sign-in URL for authentication when device is provisioned with a sign-in enrollment token. The sign-in endpoint should finish authentication flow with a URL in the form of https://enterprise.google.com/android/enroll?et= for a successful login, or https://enterprise.google.com/android/enroll/invalid for a failed login.
2584 #[serde(rename = "signinUrl")]
2585 pub signin_url: Option<String>,
2586 /// An EMM-specified metadata to distinguish between instances of SigninDetail.
2587 #[serde(rename = "tokenTag")]
2588 pub token_tag: Option<String>,
2589}
2590
2591impl common::Part for SigninDetail {}
2592
2593/// An enterprise signup URL.
2594///
2595/// # Activities
2596///
2597/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2598/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2599///
2600/// * [create signup urls](SignupUrlCreateCall) (response)
2601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2602#[serde_with::serde_as]
2603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2604pub struct SignupUrl {
2605 /// The name of the resource. Use this value in the signupUrl field when calling enterprises.create to complete the enterprise signup flow.
2606 pub name: Option<String>,
2607 /// A URL where an enterprise admin can register their enterprise. The page can't be rendered in an iframe.
2608 pub url: Option<String>,
2609}
2610
2611impl common::Resource for SignupUrl {}
2612impl common::ResponseResult for SignupUrl {}
2613
2614/// Information about device software.
2615///
2616/// This type is not used in any activity, and only used as *part* of another schema.
2617///
2618#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2619#[serde_with::serde_as]
2620#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2621pub struct SoftwareInfo {
2622 /// Android build ID string meant for displaying to the user. For example, shamu-userdebug 6.0.1 MOB30I 2756745 dev-keys.
2623 #[serde(rename = "androidBuildNumber")]
2624 pub android_build_number: Option<String>,
2625 /// Build time.
2626 #[serde(rename = "androidBuildTime")]
2627 pub android_build_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2628 /// The Android Device Policy app version code.
2629 #[serde(rename = "androidDevicePolicyVersionCode")]
2630 pub android_device_policy_version_code: Option<i32>,
2631 /// The Android Device Policy app version as displayed to the user.
2632 #[serde(rename = "androidDevicePolicyVersionName")]
2633 pub android_device_policy_version_name: Option<String>,
2634 /// The user-visible Android version string. For example, 6.0.1.
2635 #[serde(rename = "androidVersion")]
2636 pub android_version: Option<String>,
2637 /// The system bootloader version number, e.g. 0.6.7.
2638 #[serde(rename = "bootloaderVersion")]
2639 pub bootloader_version: Option<String>,
2640 /// SHA-256 hash of android.content.pm.Signature (https://developer.android.com/reference/android/content/pm/Signature.html) associated with the system package, which can be used to verify that the system build hasn't been modified.
2641 #[serde(rename = "deviceBuildSignature")]
2642 pub device_build_signature: Option<String>,
2643 /// Kernel version, for example, 2.6.32.9-g103d848.
2644 #[serde(rename = "deviceKernelVersion")]
2645 pub device_kernel_version: Option<String>,
2646 /// An IETF BCP 47 language code for the primary locale on the device.
2647 #[serde(rename = "primaryLanguageCode")]
2648 pub primary_language_code: Option<String>,
2649 /// Security patch level, e.g. 2016-05-01.
2650 #[serde(rename = "securityPatchLevel")]
2651 pub security_patch_level: Option<String>,
2652 /// Information about a potential pending system update.
2653 #[serde(rename = "systemUpdateInfo")]
2654 pub system_update_info: Option<SystemUpdateInfo>,
2655}
2656
2657impl common::Part for SoftwareInfo {}
2658
2659/// Additional context for SpecificNonComplianceReason.
2660///
2661/// This type is not used in any activity, and only used as *part* of another schema.
2662///
2663#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2664#[serde_with::serde_as]
2665#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2666pub struct SpecificNonComplianceContext {
2667 /// Additional context for non-compliance related to Wi-Fi configuration. See ONC_WIFI_INVALID_VALUE and ONC_WIFI_API_LEVEL
2668 #[serde(rename = "oncWifiContext")]
2669 pub onc_wifi_context: Option<OncWifiContext>,
2670 /// Additional context for non-compliance related to password policies. See PASSWORD_POLICIES_PASSWORD_EXPIRED and PASSWORD_POLICIES_PASSWORD_NOT_SUFFICIENT.
2671 #[serde(rename = "passwordPoliciesContext")]
2672 pub password_policies_context: Option<PasswordPoliciesContext>,
2673}
2674
2675impl common::Part for SpecificNonComplianceContext {}
2676
2677/// Parameters associated with the START_LOST_MODE command to put the device into lost mode. At least one of the parameters, not including the organization name, must be provided in order for the device to be put into lost mode.
2678///
2679/// This type is not used in any activity, and only used as *part* of another schema.
2680///
2681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2682#[serde_with::serde_as]
2683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2684pub struct StartLostModeParams {
2685 /// The email address displayed to the user when the device is in lost mode.
2686 #[serde(rename = "lostEmailAddress")]
2687 pub lost_email_address: Option<String>,
2688 /// The message displayed to the user when the device is in lost mode.
2689 #[serde(rename = "lostMessage")]
2690 pub lost_message: Option<UserFacingMessage>,
2691 /// The organization name displayed to the user when the device is in lost mode.
2692 #[serde(rename = "lostOrganization")]
2693 pub lost_organization: Option<UserFacingMessage>,
2694 /// The phone number that will be called when the device is in lost mode and the call owner button is tapped.
2695 #[serde(rename = "lostPhoneNumber")]
2696 pub lost_phone_number: Option<UserFacingMessage>,
2697 /// The street address displayed to the user when the device is in lost mode.
2698 #[serde(rename = "lostStreetAddress")]
2699 pub lost_street_address: Option<UserFacingMessage>,
2700}
2701
2702impl common::Part for StartLostModeParams {}
2703
2704/// Status of the START_LOST_MODE command to put the device into lost mode.
2705///
2706/// This type is not used in any activity, and only used as *part* of another schema.
2707///
2708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2709#[serde_with::serde_as]
2710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2711pub struct StartLostModeStatus {
2712 /// The status. See StartLostModeStatus.
2713 pub status: Option<String>,
2714}
2715
2716impl common::Part for StartLostModeStatus {}
2717
2718/// 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).
2719///
2720/// This type is not used in any activity, and only used as *part* of another schema.
2721///
2722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2723#[serde_with::serde_as]
2724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2725pub struct Status {
2726 /// The status code, which should be an enum value of google.rpc.Code.
2727 pub code: Option<i32>,
2728 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2729 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2730 /// 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.
2731 pub message: Option<String>,
2732}
2733
2734impl common::Part for Status {}
2735
2736/// Settings controlling the behavior of status reports.
2737///
2738/// This type is not used in any activity, and only used as *part* of another schema.
2739///
2740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2741#[serde_with::serde_as]
2742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2743pub struct StatusReportingSettings {
2744 /// Application reporting settings. Only applicable if application_reports_enabled is true.
2745 #[serde(rename = "applicationReportingSettings")]
2746 pub application_reporting_settings: Option<ApplicationReportingSettings>,
2747 /// Whether app reports are enabled.
2748 #[serde(rename = "applicationReportsEnabled")]
2749 pub application_reports_enabled: Option<bool>,
2750 /// Whether Common Criteria Mode reporting is enabled.
2751 #[serde(rename = "commonCriteriaModeEnabled")]
2752 pub common_criteria_mode_enabled: Option<bool>,
2753 /// Whether device settings reporting is enabled.
2754 #[serde(rename = "deviceSettingsEnabled")]
2755 pub device_settings_enabled: Option<bool>,
2756 /// Whether displays reporting is enabled. Report data is not available for personally owned devices with work profiles.
2757 #[serde(rename = "displayInfoEnabled")]
2758 pub display_info_enabled: Option<bool>,
2759 /// Whether hardware status reporting is enabled. Report data is not available for personally owned devices with work profiles.
2760 #[serde(rename = "hardwareStatusEnabled")]
2761 pub hardware_status_enabled: Option<bool>,
2762 /// Whether memory event reporting is enabled.
2763 #[serde(rename = "memoryInfoEnabled")]
2764 pub memory_info_enabled: Option<bool>,
2765 /// Whether network info reporting is enabled.
2766 #[serde(rename = "networkInfoEnabled")]
2767 pub network_info_enabled: Option<bool>,
2768 /// Whether power management event reporting is enabled. Report data is not available for personally owned devices with work profiles.
2769 #[serde(rename = "powerManagementEventsEnabled")]
2770 pub power_management_events_enabled: Option<bool>,
2771 /// Whether software info reporting is enabled.
2772 #[serde(rename = "softwareInfoEnabled")]
2773 pub software_info_enabled: Option<bool>,
2774 /// Whether system properties reporting is enabled.
2775 #[serde(rename = "systemPropertiesEnabled")]
2776 pub system_properties_enabled: Option<bool>,
2777}
2778
2779impl common::Part for StatusReportingSettings {}
2780
2781/// Parameters associated with the STOP_LOST_MODE command to take the device out of lost mode.
2782///
2783/// This type is not used in any activity, and only used as *part* of another schema.
2784///
2785#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2786#[serde_with::serde_as]
2787#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2788pub struct StopLostModeParams {
2789 _never_set: Option<bool>,
2790}
2791
2792impl common::Part for StopLostModeParams {}
2793
2794/// Status of the STOP_LOST_MODE command to take the device out of lost mode.
2795///
2796/// This type is not used in any activity, and only used as *part* of another schema.
2797///
2798#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2799#[serde_with::serde_as]
2800#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2801pub struct StopLostModeStatus {
2802 /// The status. See StopLostModeStatus.
2803 pub status: Option<String>,
2804}
2805
2806impl common::Part for StopLostModeStatus {}
2807
2808/// Configuration for managing system updatesNote: Google Play system updates (https://source.android.com/docs/core/ota/modular-system) (also called Mainline updates) are automatically downloaded but require a device reboot to be installed. Refer to the mainline section in Manage system updates (https://developer.android.com/work/dpc/system-updates#mainline) for further details.
2809///
2810/// This type is not used in any activity, and only used as *part* of another schema.
2811///
2812#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2813#[serde_with::serde_as]
2814#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2815pub struct SystemUpdate {
2816 /// If the type is WINDOWED, the end of the maintenance window, measured as the number of minutes after midnight in device's local time. This value must be between 0 and 1439, inclusive. If this value is less than start_minutes, then the maintenance window spans midnight. If the maintenance window specified is smaller than 30 minutes, the actual window is extended to 30 minutes beyond the start time.
2817 #[serde(rename = "endMinutes")]
2818 pub end_minutes: Option<i32>,
2819 /// An annually repeating time period in which over-the-air (OTA) system updates are postponed to freeze the OS version running on a device. To prevent freezing the device indefinitely, each freeze period must be separated by at least 60 days.
2820 #[serde(rename = "freezePeriods")]
2821 pub freeze_periods: Option<Vec<FreezePeriod>>,
2822 /// If the type is WINDOWED, the start of the maintenance window, measured as the number of minutes after midnight in the device's local time. This value must be between 0 and 1439, inclusive.
2823 #[serde(rename = "startMinutes")]
2824 pub start_minutes: Option<i32>,
2825 /// The type of system update to configure.
2826 #[serde(rename = "type")]
2827 pub type_: Option<String>,
2828}
2829
2830impl common::Part for SystemUpdate {}
2831
2832/// Information about a potential pending system update.
2833///
2834/// This type is not used in any activity, and only used as *part* of another schema.
2835///
2836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2837#[serde_with::serde_as]
2838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2839pub struct SystemUpdateInfo {
2840 /// The time when the update was first available. A zero value indicates that this field is not set. This field is set only if an update is available (that is, updateStatus is neither UPDATE_STATUS_UNKNOWN nor UP_TO_DATE).
2841 #[serde(rename = "updateReceivedTime")]
2842 pub update_received_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2843 /// The status of an update: whether an update exists and what type it is.
2844 #[serde(rename = "updateStatus")]
2845 pub update_status: Option<String>,
2846}
2847
2848impl common::Part for SystemUpdateInfo {}
2849
2850/// Telephony information associated with a given SIM card on the device. Only supported on fully managed devices starting from Android API level 23.
2851///
2852/// This type is not used in any activity, and only used as *part* of another schema.
2853///
2854#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2855#[serde_with::serde_as]
2856#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2857pub struct TelephonyInfo {
2858 /// The carrier name associated with this SIM card.
2859 #[serde(rename = "carrierName")]
2860 pub carrier_name: Option<String>,
2861 /// The phone number associated with this SIM card.
2862 #[serde(rename = "phoneNumber")]
2863 pub phone_number: Option<String>,
2864}
2865
2866impl common::Part for TelephonyInfo {}
2867
2868/// A terms and conditions page to be accepted during provisioning.
2869///
2870/// This type is not used in any activity, and only used as *part* of another schema.
2871///
2872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2873#[serde_with::serde_as]
2874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2875pub struct TermsAndConditions {
2876 /// A well-formatted HTML string. It will be parsed on the client with android.text.Html#fromHtml.
2877 pub content: Option<UserFacingMessage>,
2878 /// A short header which appears above the HTML content.
2879 pub header: Option<UserFacingMessage>,
2880}
2881
2882impl common::Part for TermsAndConditions {}
2883
2884/// Controls types of device activity logs collected from the device and reported via Pub/Sub notification (https://developers.google.com/android/management/notifications).
2885///
2886/// This type is not used in any activity, and only used as *part* of another schema.
2887///
2888#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2889#[serde_with::serde_as]
2890#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2891pub struct UsageLog {
2892 /// Specifies which log types are enabled. Note that users will receive on-device messaging when usage logging is enabled.
2893 #[serde(rename = "enabledLogTypes")]
2894 pub enabled_log_types: Option<Vec<String>>,
2895 /// Specifies which of the enabled log types can be uploaded over mobile data. By default logs are queued for upload when the device connects to WiFi.
2896 #[serde(rename = "uploadOnCellularAllowed")]
2897 pub upload_on_cellular_allowed: Option<Vec<String>>,
2898}
2899
2900impl common::Part for UsageLog {}
2901
2902/// A user belonging to an enterprise.
2903///
2904/// This type is not used in any activity, and only used as *part* of another schema.
2905///
2906#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2907#[serde_with::serde_as]
2908#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2909pub struct User {
2910 /// A unique identifier you create for this user, such as user342 or asset#44418. This field must be set when the user is created and can't be updated. This field must not contain personally identifiable information (PII). This identifier must be 1024 characters or less; otherwise, the update policy request will fail.
2911 #[serde(rename = "accountIdentifier")]
2912 pub account_identifier: Option<String>,
2913}
2914
2915impl common::Part for User {}
2916
2917/// Provides a user-facing message with locale info. The maximum message length is 4096 characters.
2918///
2919/// This type is not used in any activity, and only used as *part* of another schema.
2920///
2921#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2922#[serde_with::serde_as]
2923#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2924pub struct UserFacingMessage {
2925 /// The default message displayed if no localized message is specified or the user's locale doesn't match with any of the localized messages. A default message must be provided if any localized messages are provided.
2926 #[serde(rename = "defaultMessage")]
2927 pub default_message: Option<String>,
2928 /// A map containing pairs, where locale is a well-formed BCP 47 language (https://www.w3.org/International/articles/language-tags/) code, such as en-US, es-ES, or fr.
2929 #[serde(rename = "localizedMessages")]
2930 pub localized_messages: Option<HashMap<String, String>>,
2931}
2932
2933impl common::Part for UserFacingMessage {}
2934
2935/// A web app.
2936///
2937/// # Activities
2938///
2939/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2940/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2941///
2942/// * [web apps create enterprises](EnterpriseWebAppCreateCall) (request|response)
2943/// * [web apps get enterprises](EnterpriseWebAppGetCall) (response)
2944/// * [web apps patch enterprises](EnterpriseWebAppPatchCall) (request|response)
2945#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2946#[serde_with::serde_as]
2947#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2948pub struct WebApp {
2949 /// The display mode of the web app.
2950 #[serde(rename = "displayMode")]
2951 pub display_mode: Option<String>,
2952 /// A list of icons for the web app. Must have at least one element.
2953 pub icons: Option<Vec<WebAppIcon>>,
2954 /// The name of the web app, which is generated by the server during creation in the form enterprises/{enterpriseId}/webApps/{packageName}.
2955 pub name: Option<String>,
2956 /// The start URL, i.e. the URL that should load when the user opens the application.
2957 #[serde(rename = "startUrl")]
2958 pub start_url: Option<String>,
2959 /// The title of the web app as displayed to the user (e.g., amongst a list of other applications, or as a label for an icon).
2960 pub title: Option<String>,
2961 /// The current version of the app.Note that the version can automatically increase during the lifetime of the web app, while Google does internal housekeeping to keep the web app up-to-date.
2962 #[serde(rename = "versionCode")]
2963 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2964 pub version_code: Option<i64>,
2965}
2966
2967impl common::RequestValue for WebApp {}
2968impl common::ResponseResult for WebApp {}
2969
2970/// An icon for a web app. Supported formats are: png, jpg and webp.
2971///
2972/// This type is not used in any activity, and only used as *part* of another schema.
2973///
2974#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2975#[serde_with::serde_as]
2976#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2977pub struct WebAppIcon {
2978 /// The actual bytes of the image in a base64url encoded string (c.f. RFC4648, section 5 "Base 64 Encoding with URL and Filename Safe Alphabet"). - The image type can be png or jpg. - The image should ideally be square. - The image should ideally have a size of 512x512.
2979 #[serde(rename = "imageData")]
2980 pub image_data: Option<String>,
2981}
2982
2983impl common::Part for WebAppIcon {}
2984
2985/// A web token used to access the managed Google Play iframe.
2986///
2987/// # Activities
2988///
2989/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2990/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2991///
2992/// * [web tokens create enterprises](EnterpriseWebTokenCreateCall) (request|response)
2993#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2994#[serde_with::serde_as]
2995#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2996pub struct WebToken {
2997 /// The features to enable. Use this if you want to control exactly which feature(s) will be activated; leave empty to allow all features.Restrictions / things to note: - If no features are listed here, all features are enabled — this is the default behavior where you give access to all features to your admins. - This must not contain any FEATURE_UNSPECIFIED values. - Repeated values are ignored
2998 #[serde(rename = "enabledFeatures")]
2999 pub enabled_features: Option<Vec<String>>,
3000 /// The name of the web token, which is generated by the server during creation in the form enterprises/{enterpriseId}/webTokens/{webTokenId}.
3001 pub name: Option<String>,
3002 /// The URL of the parent frame hosting the iframe with the embedded UI. To prevent XSS, the iframe may not be hosted at other URLs. The URL must use the https scheme.
3003 #[serde(rename = "parentFrameUrl")]
3004 pub parent_frame_url: Option<String>,
3005 /// Permissions available to an admin in the embedded UI. An admin must have all of these permissions in order to view the UI. This field is deprecated.
3006 pub permissions: Option<Vec<String>>,
3007 /// The token value which is used in the hosting page to generate the iframe with the embedded UI. This is a read-only field generated by the server.
3008 pub value: Option<String>,
3009}
3010
3011impl common::RequestValue for WebToken {}
3012impl common::ResponseResult for WebToken {}
3013
3014/// Represents a Wi-Fi SSID.
3015///
3016/// This type is not used in any activity, and only used as *part* of another schema.
3017///
3018#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3019#[serde_with::serde_as]
3020#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3021pub struct WifiSsid {
3022 /// Required. Wi-Fi SSID represented as a string.
3023 #[serde(rename = "wifiSsid")]
3024 pub wifi_ssid: Option<String>,
3025}
3026
3027impl common::Part for WifiSsid {}
3028
3029/// Restrictions on which Wi-Fi SSIDs the device can connect to. Note that this does not affect which networks can be configured on the device. Supported on company-owned devices running Android 13 and above.
3030///
3031/// This type is not used in any activity, and only used as *part* of another schema.
3032///
3033#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3034#[serde_with::serde_as]
3035#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3036pub struct WifiSsidPolicy {
3037 /// Type of the Wi-Fi SSID policy to be applied.
3038 #[serde(rename = "wifiSsidPolicyType")]
3039 pub wifi_ssid_policy_type: Option<String>,
3040 /// Optional. List of Wi-Fi SSIDs that should be applied in the policy. This field must be non-empty when WifiSsidPolicyType is set to WIFI_SSID_ALLOWLIST. If this is set to a non-empty list, then a nonComplianceDetail detail with API_LEVEL is reported if the Android version is less than 13 and a nonComplianceDetail with MANAGEMENT_MODE is reported for non-company-owned devices.
3041 #[serde(rename = "wifiSsids")]
3042 pub wifi_ssids: Option<Vec<WifiSsid>>,
3043}
3044
3045impl common::Part for WifiSsidPolicy {}
3046
3047/// An action to reset a company owned device or delete a work profile. Note: blockAction must also be specified.
3048///
3049/// This type is not used in any activity, and only used as *part* of another schema.
3050///
3051#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3052#[serde_with::serde_as]
3053#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3054pub struct WipeAction {
3055 /// Whether the factory-reset protection data is preserved on the device. This setting doesn’t apply to work profiles.
3056 #[serde(rename = "preserveFrp")]
3057 pub preserve_frp: Option<bool>,
3058 /// Number of days the policy is non-compliant before the device or work profile is wiped. wipeAfterDays must be greater than blockAfterDays.
3059 #[serde(rename = "wipeAfterDays")]
3060 pub wipe_after_days: Option<i32>,
3061}
3062
3063impl common::Part for WipeAction {}
3064
3065// ###################
3066// MethodBuilders ###
3067// #################
3068
3069/// A builder providing access to all methods supported on *enterprise* resources.
3070/// It is not used directly, but through the [`AndroidManagement`] hub.
3071///
3072/// # Example
3073///
3074/// Instantiate a resource builder
3075///
3076/// ```test_harness,no_run
3077/// extern crate hyper;
3078/// extern crate hyper_rustls;
3079/// extern crate google_androidmanagement1 as androidmanagement1;
3080///
3081/// # async fn dox() {
3082/// use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3083///
3084/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3085/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3086/// secret,
3087/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3088/// ).build().await.unwrap();
3089///
3090/// let client = hyper_util::client::legacy::Client::builder(
3091/// hyper_util::rt::TokioExecutor::new()
3092/// )
3093/// .build(
3094/// hyper_rustls::HttpsConnectorBuilder::new()
3095/// .with_native_roots()
3096/// .unwrap()
3097/// .https_or_http()
3098/// .enable_http1()
3099/// .build()
3100/// );
3101/// let mut hub = AndroidManagement::new(client, auth);
3102/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3103/// // like `applications_get(...)`, `create(...)`, `delete(...)`, `devices_delete(...)`, `devices_get(...)`, `devices_issue_command(...)`, `devices_list(...)`, `devices_operations_cancel(...)`, `devices_operations_get(...)`, `devices_operations_list(...)`, `devices_patch(...)`, `enrollment_tokens_create(...)`, `enrollment_tokens_delete(...)`, `enrollment_tokens_get(...)`, `enrollment_tokens_list(...)`, `get(...)`, `list(...)`, `migration_tokens_create(...)`, `migration_tokens_get(...)`, `migration_tokens_list(...)`, `patch(...)`, `policies_delete(...)`, `policies_get(...)`, `policies_list(...)`, `policies_patch(...)`, `web_apps_create(...)`, `web_apps_delete(...)`, `web_apps_get(...)`, `web_apps_list(...)`, `web_apps_patch(...)` and `web_tokens_create(...)`
3104/// // to build up your call.
3105/// let rb = hub.enterprises();
3106/// # }
3107/// ```
3108pub struct EnterpriseMethods<'a, C>
3109where
3110 C: 'a,
3111{
3112 hub: &'a AndroidManagement<C>,
3113}
3114
3115impl<'a, C> common::MethodsBuilder for EnterpriseMethods<'a, C> {}
3116
3117impl<'a, C> EnterpriseMethods<'a, C> {
3118 /// Create a builder to help you perform the following task:
3119 ///
3120 /// Gets info about an application.
3121 ///
3122 /// # Arguments
3123 ///
3124 /// * `name` - The name of the application in the form enterprises/{enterpriseId}/applications/{package_name}.
3125 pub fn applications_get(&self, name: &str) -> EnterpriseApplicationGetCall<'a, C> {
3126 EnterpriseApplicationGetCall {
3127 hub: self.hub,
3128 _name: name.to_string(),
3129 _language_code: Default::default(),
3130 _delegate: Default::default(),
3131 _additional_params: Default::default(),
3132 _scopes: Default::default(),
3133 }
3134 }
3135
3136 /// Create a builder to help you perform the following task:
3137 ///
3138 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.
3139 ///
3140 /// # Arguments
3141 ///
3142 /// * `name` - The name of the operation resource to be cancelled.
3143 pub fn devices_operations_cancel(
3144 &self,
3145 name: &str,
3146 ) -> EnterpriseDeviceOperationCancelCall<'a, C> {
3147 EnterpriseDeviceOperationCancelCall {
3148 hub: self.hub,
3149 _name: name.to_string(),
3150 _delegate: Default::default(),
3151 _additional_params: Default::default(),
3152 _scopes: Default::default(),
3153 }
3154 }
3155
3156 /// Create a builder to help you perform the following task:
3157 ///
3158 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3159 ///
3160 /// # Arguments
3161 ///
3162 /// * `name` - The name of the operation resource.
3163 pub fn devices_operations_get(&self, name: &str) -> EnterpriseDeviceOperationGetCall<'a, C> {
3164 EnterpriseDeviceOperationGetCall {
3165 hub: self.hub,
3166 _name: name.to_string(),
3167 _delegate: Default::default(),
3168 _additional_params: Default::default(),
3169 _scopes: Default::default(),
3170 }
3171 }
3172
3173 /// Create a builder to help you perform the following task:
3174 ///
3175 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED.
3176 ///
3177 /// # Arguments
3178 ///
3179 /// * `name` - The name of the operation's parent resource.
3180 pub fn devices_operations_list(&self, name: &str) -> EnterpriseDeviceOperationListCall<'a, C> {
3181 EnterpriseDeviceOperationListCall {
3182 hub: self.hub,
3183 _name: name.to_string(),
3184 _page_token: Default::default(),
3185 _page_size: Default::default(),
3186 _filter: Default::default(),
3187 _delegate: Default::default(),
3188 _additional_params: Default::default(),
3189 _scopes: Default::default(),
3190 }
3191 }
3192
3193 /// Create a builder to help you perform the following task:
3194 ///
3195 /// Deletes a device. This operation wipes the device. Deleted devices do not show up in enterprises.devices.list calls and a 404 is returned from enterprises.devices.get.
3196 ///
3197 /// # Arguments
3198 ///
3199 /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
3200 pub fn devices_delete(&self, name: &str) -> EnterpriseDeviceDeleteCall<'a, C> {
3201 EnterpriseDeviceDeleteCall {
3202 hub: self.hub,
3203 _name: name.to_string(),
3204 _wipe_reason_message: Default::default(),
3205 _wipe_data_flags: Default::default(),
3206 _delegate: Default::default(),
3207 _additional_params: Default::default(),
3208 _scopes: Default::default(),
3209 }
3210 }
3211
3212 /// Create a builder to help you perform the following task:
3213 ///
3214 /// Gets a device. Deleted devices will respond with a 404 error.
3215 ///
3216 /// # Arguments
3217 ///
3218 /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
3219 pub fn devices_get(&self, name: &str) -> EnterpriseDeviceGetCall<'a, C> {
3220 EnterpriseDeviceGetCall {
3221 hub: self.hub,
3222 _name: name.to_string(),
3223 _delegate: Default::default(),
3224 _additional_params: Default::default(),
3225 _scopes: Default::default(),
3226 }
3227 }
3228
3229 /// Create a builder to help you perform the following task:
3230 ///
3231 /// Issues a command to a device. The Operation resource returned contains a Command in its metadata field. Use the get operation method to get the status of the command.
3232 ///
3233 /// # Arguments
3234 ///
3235 /// * `request` - No description provided.
3236 /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
3237 pub fn devices_issue_command(
3238 &self,
3239 request: Command,
3240 name: &str,
3241 ) -> EnterpriseDeviceIssueCommandCall<'a, C> {
3242 EnterpriseDeviceIssueCommandCall {
3243 hub: self.hub,
3244 _request: request,
3245 _name: name.to_string(),
3246 _delegate: Default::default(),
3247 _additional_params: Default::default(),
3248 _scopes: Default::default(),
3249 }
3250 }
3251
3252 /// Create a builder to help you perform the following task:
3253 ///
3254 /// Lists devices for a given enterprise. Deleted devices are not returned in the response.
3255 ///
3256 /// # Arguments
3257 ///
3258 /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}.
3259 pub fn devices_list(&self, parent: &str) -> EnterpriseDeviceListCall<'a, C> {
3260 EnterpriseDeviceListCall {
3261 hub: self.hub,
3262 _parent: parent.to_string(),
3263 _page_token: Default::default(),
3264 _page_size: Default::default(),
3265 _delegate: Default::default(),
3266 _additional_params: Default::default(),
3267 _scopes: Default::default(),
3268 }
3269 }
3270
3271 /// Create a builder to help you perform the following task:
3272 ///
3273 /// Updates a device.
3274 ///
3275 /// # Arguments
3276 ///
3277 /// * `request` - No description provided.
3278 /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
3279 pub fn devices_patch(&self, request: Device, name: &str) -> EnterpriseDevicePatchCall<'a, C> {
3280 EnterpriseDevicePatchCall {
3281 hub: self.hub,
3282 _request: request,
3283 _name: name.to_string(),
3284 _update_mask: Default::default(),
3285 _delegate: Default::default(),
3286 _additional_params: Default::default(),
3287 _scopes: Default::default(),
3288 }
3289 }
3290
3291 /// Create a builder to help you perform the following task:
3292 ///
3293 /// Creates an enrollment token for a given enterprise. It's up to the caller's responsibility to manage the lifecycle of newly created tokens and deleting them when they're not intended to be used anymore. Once an enrollment token has been created, it's not possible to retrieve the token's content anymore using AM API. It is recommended for EMMs to securely store the token if it's intended to be reused.
3294 ///
3295 /// # Arguments
3296 ///
3297 /// * `request` - No description provided.
3298 /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}.
3299 pub fn enrollment_tokens_create(
3300 &self,
3301 request: EnrollmentToken,
3302 parent: &str,
3303 ) -> EnterpriseEnrollmentTokenCreateCall<'a, C> {
3304 EnterpriseEnrollmentTokenCreateCall {
3305 hub: self.hub,
3306 _request: request,
3307 _parent: parent.to_string(),
3308 _delegate: Default::default(),
3309 _additional_params: Default::default(),
3310 _scopes: Default::default(),
3311 }
3312 }
3313
3314 /// Create a builder to help you perform the following task:
3315 ///
3316 /// Deletes an enrollment token. This operation invalidates the token, preventing its future use.
3317 ///
3318 /// # Arguments
3319 ///
3320 /// * `name` - The name of the enrollment token in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}.
3321 pub fn enrollment_tokens_delete(
3322 &self,
3323 name: &str,
3324 ) -> EnterpriseEnrollmentTokenDeleteCall<'a, C> {
3325 EnterpriseEnrollmentTokenDeleteCall {
3326 hub: self.hub,
3327 _name: name.to_string(),
3328 _delegate: Default::default(),
3329 _additional_params: Default::default(),
3330 _scopes: Default::default(),
3331 }
3332 }
3333
3334 /// Create a builder to help you perform the following task:
3335 ///
3336 /// Gets an active, unexpired enrollment token. A partial view of the enrollment token is returned. Only the following fields are populated: name, expirationTimestamp, allowPersonalUsage, value, qrCode. This method is meant to help manage active enrollment tokens lifecycle. For security reasons, it's recommended to delete active enrollment tokens as soon as they're not intended to be used anymore.
3337 ///
3338 /// # Arguments
3339 ///
3340 /// * `name` - Required. The name of the enrollment token in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}.
3341 pub fn enrollment_tokens_get(&self, name: &str) -> EnterpriseEnrollmentTokenGetCall<'a, C> {
3342 EnterpriseEnrollmentTokenGetCall {
3343 hub: self.hub,
3344 _name: name.to_string(),
3345 _delegate: Default::default(),
3346 _additional_params: Default::default(),
3347 _scopes: Default::default(),
3348 }
3349 }
3350
3351 /// Create a builder to help you perform the following task:
3352 ///
3353 /// Lists active, unexpired enrollment tokens for a given enterprise. The list items contain only a partial view of EnrollmentToken object. Only the following fields are populated: name, expirationTimestamp, allowPersonalUsage, value, qrCode. This method is meant to help manage active enrollment tokens lifecycle. For security reasons, it's recommended to delete active enrollment tokens as soon as they're not intended to be used anymore.
3354 ///
3355 /// # Arguments
3356 ///
3357 /// * `parent` - Required. The name of the enterprise in the form enterprises/{enterpriseId}.
3358 pub fn enrollment_tokens_list(&self, parent: &str) -> EnterpriseEnrollmentTokenListCall<'a, C> {
3359 EnterpriseEnrollmentTokenListCall {
3360 hub: self.hub,
3361 _parent: parent.to_string(),
3362 _page_token: Default::default(),
3363 _page_size: Default::default(),
3364 _delegate: Default::default(),
3365 _additional_params: Default::default(),
3366 _scopes: Default::default(),
3367 }
3368 }
3369
3370 /// Create a builder to help you perform the following task:
3371 ///
3372 /// Creates a migration token, to migrate an existing device from being managed by the EMM's Device Policy Controller (DPC) to being managed by the Android Management API. See the guide (https://developers.google.com/android/management/dpc-migration) for more details.
3373 ///
3374 /// # Arguments
3375 ///
3376 /// * `request` - No description provided.
3377 /// * `parent` - Required. The enterprise in which this migration token is created. This must be the same enterprise which already manages the device in the Play EMM API. Format: enterprises/{enterprise}
3378 pub fn migration_tokens_create(
3379 &self,
3380 request: MigrationToken,
3381 parent: &str,
3382 ) -> EnterpriseMigrationTokenCreateCall<'a, C> {
3383 EnterpriseMigrationTokenCreateCall {
3384 hub: self.hub,
3385 _request: request,
3386 _parent: parent.to_string(),
3387 _delegate: Default::default(),
3388 _additional_params: Default::default(),
3389 _scopes: Default::default(),
3390 }
3391 }
3392
3393 /// Create a builder to help you perform the following task:
3394 ///
3395 /// Gets a migration token.
3396 ///
3397 /// # Arguments
3398 ///
3399 /// * `name` - Required. The name of the migration token to retrieve. Format: enterprises/{enterprise}/migrationTokens/{migration_token}
3400 pub fn migration_tokens_get(&self, name: &str) -> EnterpriseMigrationTokenGetCall<'a, C> {
3401 EnterpriseMigrationTokenGetCall {
3402 hub: self.hub,
3403 _name: name.to_string(),
3404 _delegate: Default::default(),
3405 _additional_params: Default::default(),
3406 _scopes: Default::default(),
3407 }
3408 }
3409
3410 /// Create a builder to help you perform the following task:
3411 ///
3412 /// Lists migration tokens.
3413 ///
3414 /// # Arguments
3415 ///
3416 /// * `parent` - Required. The enterprise which the migration tokens belong to. Format: enterprises/{enterprise}
3417 pub fn migration_tokens_list(&self, parent: &str) -> EnterpriseMigrationTokenListCall<'a, C> {
3418 EnterpriseMigrationTokenListCall {
3419 hub: self.hub,
3420 _parent: parent.to_string(),
3421 _page_token: Default::default(),
3422 _page_size: Default::default(),
3423 _delegate: Default::default(),
3424 _additional_params: Default::default(),
3425 _scopes: Default::default(),
3426 }
3427 }
3428
3429 /// Create a builder to help you perform the following task:
3430 ///
3431 /// Deletes a policy. This operation is only permitted if no devices are currently referencing the policy.
3432 ///
3433 /// # Arguments
3434 ///
3435 /// * `name` - The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}.
3436 pub fn policies_delete(&self, name: &str) -> EnterprisePolicyDeleteCall<'a, C> {
3437 EnterprisePolicyDeleteCall {
3438 hub: self.hub,
3439 _name: name.to_string(),
3440 _delegate: Default::default(),
3441 _additional_params: Default::default(),
3442 _scopes: Default::default(),
3443 }
3444 }
3445
3446 /// Create a builder to help you perform the following task:
3447 ///
3448 /// Gets a policy.
3449 ///
3450 /// # Arguments
3451 ///
3452 /// * `name` - The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}.
3453 pub fn policies_get(&self, name: &str) -> EnterprisePolicyGetCall<'a, C> {
3454 EnterprisePolicyGetCall {
3455 hub: self.hub,
3456 _name: name.to_string(),
3457 _delegate: Default::default(),
3458 _additional_params: Default::default(),
3459 _scopes: Default::default(),
3460 }
3461 }
3462
3463 /// Create a builder to help you perform the following task:
3464 ///
3465 /// Lists policies for a given enterprise.
3466 ///
3467 /// # Arguments
3468 ///
3469 /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}.
3470 pub fn policies_list(&self, parent: &str) -> EnterprisePolicyListCall<'a, C> {
3471 EnterprisePolicyListCall {
3472 hub: self.hub,
3473 _parent: parent.to_string(),
3474 _page_token: Default::default(),
3475 _page_size: Default::default(),
3476 _delegate: Default::default(),
3477 _additional_params: Default::default(),
3478 _scopes: Default::default(),
3479 }
3480 }
3481
3482 /// Create a builder to help you perform the following task:
3483 ///
3484 /// Updates or creates a policy.
3485 ///
3486 /// # Arguments
3487 ///
3488 /// * `request` - No description provided.
3489 /// * `name` - The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}.
3490 pub fn policies_patch(&self, request: Policy, name: &str) -> EnterprisePolicyPatchCall<'a, C> {
3491 EnterprisePolicyPatchCall {
3492 hub: self.hub,
3493 _request: request,
3494 _name: name.to_string(),
3495 _update_mask: Default::default(),
3496 _delegate: Default::default(),
3497 _additional_params: Default::default(),
3498 _scopes: Default::default(),
3499 }
3500 }
3501
3502 /// Create a builder to help you perform the following task:
3503 ///
3504 /// Creates a web app.
3505 ///
3506 /// # Arguments
3507 ///
3508 /// * `request` - No description provided.
3509 /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}.
3510 pub fn web_apps_create(
3511 &self,
3512 request: WebApp,
3513 parent: &str,
3514 ) -> EnterpriseWebAppCreateCall<'a, C> {
3515 EnterpriseWebAppCreateCall {
3516 hub: self.hub,
3517 _request: request,
3518 _parent: parent.to_string(),
3519 _delegate: Default::default(),
3520 _additional_params: Default::default(),
3521 _scopes: Default::default(),
3522 }
3523 }
3524
3525 /// Create a builder to help you perform the following task:
3526 ///
3527 /// Deletes a web app.
3528 ///
3529 /// # Arguments
3530 ///
3531 /// * `name` - The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}.
3532 pub fn web_apps_delete(&self, name: &str) -> EnterpriseWebAppDeleteCall<'a, C> {
3533 EnterpriseWebAppDeleteCall {
3534 hub: self.hub,
3535 _name: name.to_string(),
3536 _delegate: Default::default(),
3537 _additional_params: Default::default(),
3538 _scopes: Default::default(),
3539 }
3540 }
3541
3542 /// Create a builder to help you perform the following task:
3543 ///
3544 /// Gets a web app.
3545 ///
3546 /// # Arguments
3547 ///
3548 /// * `name` - The name of the web app in the form enterprises/{enterpriseId}/webApp/{packageName}.
3549 pub fn web_apps_get(&self, name: &str) -> EnterpriseWebAppGetCall<'a, C> {
3550 EnterpriseWebAppGetCall {
3551 hub: self.hub,
3552 _name: name.to_string(),
3553 _delegate: Default::default(),
3554 _additional_params: Default::default(),
3555 _scopes: Default::default(),
3556 }
3557 }
3558
3559 /// Create a builder to help you perform the following task:
3560 ///
3561 /// Lists web apps for a given enterprise.
3562 ///
3563 /// # Arguments
3564 ///
3565 /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}.
3566 pub fn web_apps_list(&self, parent: &str) -> EnterpriseWebAppListCall<'a, C> {
3567 EnterpriseWebAppListCall {
3568 hub: self.hub,
3569 _parent: parent.to_string(),
3570 _page_token: Default::default(),
3571 _page_size: Default::default(),
3572 _delegate: Default::default(),
3573 _additional_params: Default::default(),
3574 _scopes: Default::default(),
3575 }
3576 }
3577
3578 /// Create a builder to help you perform the following task:
3579 ///
3580 /// Updates a web app.
3581 ///
3582 /// # Arguments
3583 ///
3584 /// * `request` - No description provided.
3585 /// * `name` - The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}.
3586 pub fn web_apps_patch(&self, request: WebApp, name: &str) -> EnterpriseWebAppPatchCall<'a, C> {
3587 EnterpriseWebAppPatchCall {
3588 hub: self.hub,
3589 _request: request,
3590 _name: name.to_string(),
3591 _update_mask: Default::default(),
3592 _delegate: Default::default(),
3593 _additional_params: Default::default(),
3594 _scopes: Default::default(),
3595 }
3596 }
3597
3598 /// Create a builder to help you perform the following task:
3599 ///
3600 /// Creates a web token to access an embeddable managed Google Play web UI for a given enterprise.
3601 ///
3602 /// # Arguments
3603 ///
3604 /// * `request` - No description provided.
3605 /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}.
3606 pub fn web_tokens_create(
3607 &self,
3608 request: WebToken,
3609 parent: &str,
3610 ) -> EnterpriseWebTokenCreateCall<'a, C> {
3611 EnterpriseWebTokenCreateCall {
3612 hub: self.hub,
3613 _request: request,
3614 _parent: parent.to_string(),
3615 _delegate: Default::default(),
3616 _additional_params: Default::default(),
3617 _scopes: Default::default(),
3618 }
3619 }
3620
3621 /// Create a builder to help you perform the following task:
3622 ///
3623 /// Creates an enterprise. This is the last step in the enterprise signup flow. See also: SigninDetail
3624 ///
3625 /// # Arguments
3626 ///
3627 /// * `request` - No description provided.
3628 pub fn create(&self, request: Enterprise) -> EnterpriseCreateCall<'a, C> {
3629 EnterpriseCreateCall {
3630 hub: self.hub,
3631 _request: request,
3632 _signup_url_name: Default::default(),
3633 _project_id: Default::default(),
3634 _enterprise_token: Default::default(),
3635 _agreement_accepted: Default::default(),
3636 _delegate: Default::default(),
3637 _additional_params: Default::default(),
3638 _scopes: Default::default(),
3639 }
3640 }
3641
3642 /// Create a builder to help you perform the following task:
3643 ///
3644 /// Permanently deletes an enterprise and all accounts and data associated with it. Warning: this will result in a cascaded deletion of all AM API devices associated with the deleted enterprise. Only available for EMM-managed enterprises.
3645 ///
3646 /// # Arguments
3647 ///
3648 /// * `name` - The name of the enterprise in the form enterprises/{enterpriseId}.
3649 pub fn delete(&self, name: &str) -> EnterpriseDeleteCall<'a, C> {
3650 EnterpriseDeleteCall {
3651 hub: self.hub,
3652 _name: name.to_string(),
3653 _delegate: Default::default(),
3654 _additional_params: Default::default(),
3655 _scopes: Default::default(),
3656 }
3657 }
3658
3659 /// Create a builder to help you perform the following task:
3660 ///
3661 /// Gets an enterprise.
3662 ///
3663 /// # Arguments
3664 ///
3665 /// * `name` - The name of the enterprise in the form enterprises/{enterpriseId}.
3666 pub fn get(&self, name: &str) -> EnterpriseGetCall<'a, C> {
3667 EnterpriseGetCall {
3668 hub: self.hub,
3669 _name: name.to_string(),
3670 _delegate: Default::default(),
3671 _additional_params: Default::default(),
3672 _scopes: Default::default(),
3673 }
3674 }
3675
3676 /// Create a builder to help you perform the following task:
3677 ///
3678 /// Lists EMM-managed enterprises. Only BASIC fields are returned.
3679 pub fn list(&self) -> EnterpriseListCall<'a, C> {
3680 EnterpriseListCall {
3681 hub: self.hub,
3682 _view: Default::default(),
3683 _project_id: Default::default(),
3684 _page_token: Default::default(),
3685 _page_size: Default::default(),
3686 _delegate: Default::default(),
3687 _additional_params: Default::default(),
3688 _scopes: Default::default(),
3689 }
3690 }
3691
3692 /// Create a builder to help you perform the following task:
3693 ///
3694 /// Updates an enterprise. See also: SigninDetail
3695 ///
3696 /// # Arguments
3697 ///
3698 /// * `request` - No description provided.
3699 /// * `name` - The name of the enterprise in the form enterprises/{enterpriseId}.
3700 pub fn patch(&self, request: Enterprise, name: &str) -> EnterprisePatchCall<'a, C> {
3701 EnterprisePatchCall {
3702 hub: self.hub,
3703 _request: request,
3704 _name: name.to_string(),
3705 _update_mask: Default::default(),
3706 _delegate: Default::default(),
3707 _additional_params: Default::default(),
3708 _scopes: Default::default(),
3709 }
3710 }
3711}
3712
3713/// A builder providing access to all methods supported on *provisioningInfo* resources.
3714/// It is not used directly, but through the [`AndroidManagement`] hub.
3715///
3716/// # Example
3717///
3718/// Instantiate a resource builder
3719///
3720/// ```test_harness,no_run
3721/// extern crate hyper;
3722/// extern crate hyper_rustls;
3723/// extern crate google_androidmanagement1 as androidmanagement1;
3724///
3725/// # async fn dox() {
3726/// use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3727///
3728/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3729/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3730/// secret,
3731/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3732/// ).build().await.unwrap();
3733///
3734/// let client = hyper_util::client::legacy::Client::builder(
3735/// hyper_util::rt::TokioExecutor::new()
3736/// )
3737/// .build(
3738/// hyper_rustls::HttpsConnectorBuilder::new()
3739/// .with_native_roots()
3740/// .unwrap()
3741/// .https_or_http()
3742/// .enable_http1()
3743/// .build()
3744/// );
3745/// let mut hub = AndroidManagement::new(client, auth);
3746/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3747/// // like `get(...)`
3748/// // to build up your call.
3749/// let rb = hub.provisioning_info();
3750/// # }
3751/// ```
3752pub struct ProvisioningInfoMethods<'a, C>
3753where
3754 C: 'a,
3755{
3756 hub: &'a AndroidManagement<C>,
3757}
3758
3759impl<'a, C> common::MethodsBuilder for ProvisioningInfoMethods<'a, C> {}
3760
3761impl<'a, C> ProvisioningInfoMethods<'a, C> {
3762 /// Create a builder to help you perform the following task:
3763 ///
3764 /// Get the device provisioning information by the identifier provided in the sign-in url.
3765 ///
3766 /// # Arguments
3767 ///
3768 /// * `name` - Required. The identifier that Android Device Policy passes to the 3P sign-in page in the form of provisioningInfo/{provisioning_info}.
3769 pub fn get(&self, name: &str) -> ProvisioningInfoGetCall<'a, C> {
3770 ProvisioningInfoGetCall {
3771 hub: self.hub,
3772 _name: name.to_string(),
3773 _delegate: Default::default(),
3774 _additional_params: Default::default(),
3775 _scopes: Default::default(),
3776 }
3777 }
3778}
3779
3780/// A builder providing access to all methods supported on *signupUrl* resources.
3781/// It is not used directly, but through the [`AndroidManagement`] hub.
3782///
3783/// # Example
3784///
3785/// Instantiate a resource builder
3786///
3787/// ```test_harness,no_run
3788/// extern crate hyper;
3789/// extern crate hyper_rustls;
3790/// extern crate google_androidmanagement1 as androidmanagement1;
3791///
3792/// # async fn dox() {
3793/// use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3794///
3795/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3796/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3797/// secret,
3798/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3799/// ).build().await.unwrap();
3800///
3801/// let client = hyper_util::client::legacy::Client::builder(
3802/// hyper_util::rt::TokioExecutor::new()
3803/// )
3804/// .build(
3805/// hyper_rustls::HttpsConnectorBuilder::new()
3806/// .with_native_roots()
3807/// .unwrap()
3808/// .https_or_http()
3809/// .enable_http1()
3810/// .build()
3811/// );
3812/// let mut hub = AndroidManagement::new(client, auth);
3813/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3814/// // like `create(...)`
3815/// // to build up your call.
3816/// let rb = hub.signup_urls();
3817/// # }
3818/// ```
3819pub struct SignupUrlMethods<'a, C>
3820where
3821 C: 'a,
3822{
3823 hub: &'a AndroidManagement<C>,
3824}
3825
3826impl<'a, C> common::MethodsBuilder for SignupUrlMethods<'a, C> {}
3827
3828impl<'a, C> SignupUrlMethods<'a, C> {
3829 /// Create a builder to help you perform the following task:
3830 ///
3831 /// Creates an enterprise signup URL.
3832 pub fn create(&self) -> SignupUrlCreateCall<'a, C> {
3833 SignupUrlCreateCall {
3834 hub: self.hub,
3835 _project_id: Default::default(),
3836 _callback_url: Default::default(),
3837 _admin_email: Default::default(),
3838 _delegate: Default::default(),
3839 _additional_params: Default::default(),
3840 _scopes: Default::default(),
3841 }
3842 }
3843}
3844
3845// ###################
3846// CallBuilders ###
3847// #################
3848
3849/// Gets info about an application.
3850///
3851/// A builder for the *applications.get* method supported by a *enterprise* resource.
3852/// It is not used directly, but through a [`EnterpriseMethods`] instance.
3853///
3854/// # Example
3855///
3856/// Instantiate a resource method builder
3857///
3858/// ```test_harness,no_run
3859/// # extern crate hyper;
3860/// # extern crate hyper_rustls;
3861/// # extern crate google_androidmanagement1 as androidmanagement1;
3862/// # async fn dox() {
3863/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3864///
3865/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3866/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3867/// # secret,
3868/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3869/// # ).build().await.unwrap();
3870///
3871/// # let client = hyper_util::client::legacy::Client::builder(
3872/// # hyper_util::rt::TokioExecutor::new()
3873/// # )
3874/// # .build(
3875/// # hyper_rustls::HttpsConnectorBuilder::new()
3876/// # .with_native_roots()
3877/// # .unwrap()
3878/// # .https_or_http()
3879/// # .enable_http1()
3880/// # .build()
3881/// # );
3882/// # let mut hub = AndroidManagement::new(client, auth);
3883/// // You can configure optional parameters by calling the respective setters at will, and
3884/// // execute the final call using `doit()`.
3885/// // Values shown here are possibly random and not representative !
3886/// let result = hub.enterprises().applications_get("name")
3887/// .language_code("Lorem")
3888/// .doit().await;
3889/// # }
3890/// ```
3891pub struct EnterpriseApplicationGetCall<'a, C>
3892where
3893 C: 'a,
3894{
3895 hub: &'a AndroidManagement<C>,
3896 _name: String,
3897 _language_code: Option<String>,
3898 _delegate: Option<&'a mut dyn common::Delegate>,
3899 _additional_params: HashMap<String, String>,
3900 _scopes: BTreeSet<String>,
3901}
3902
3903impl<'a, C> common::CallBuilder for EnterpriseApplicationGetCall<'a, C> {}
3904
3905impl<'a, C> EnterpriseApplicationGetCall<'a, C>
3906where
3907 C: common::Connector,
3908{
3909 /// Perform the operation you have build so far.
3910 pub async fn doit(mut self) -> common::Result<(common::Response, Application)> {
3911 use std::borrow::Cow;
3912 use std::io::{Read, Seek};
3913
3914 use common::{url::Params, ToParts};
3915 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3916
3917 let mut dd = common::DefaultDelegate;
3918 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3919 dlg.begin(common::MethodInfo {
3920 id: "androidmanagement.enterprises.applications.get",
3921 http_method: hyper::Method::GET,
3922 });
3923
3924 for &field in ["alt", "name", "languageCode"].iter() {
3925 if self._additional_params.contains_key(field) {
3926 dlg.finished(false);
3927 return Err(common::Error::FieldClash(field));
3928 }
3929 }
3930
3931 let mut params = Params::with_capacity(4 + self._additional_params.len());
3932 params.push("name", self._name);
3933 if let Some(value) = self._language_code.as_ref() {
3934 params.push("languageCode", value);
3935 }
3936
3937 params.extend(self._additional_params.iter());
3938
3939 params.push("alt", "json");
3940 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3941 if self._scopes.is_empty() {
3942 self._scopes.insert(Scope::Full.as_ref().to_string());
3943 }
3944
3945 #[allow(clippy::single_element_loop)]
3946 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3947 url = params.uri_replacement(url, param_name, find_this, true);
3948 }
3949 {
3950 let to_remove = ["name"];
3951 params.remove_params(&to_remove);
3952 }
3953
3954 let url = params.parse_with_url(&url);
3955
3956 loop {
3957 let token = match self
3958 .hub
3959 .auth
3960 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3961 .await
3962 {
3963 Ok(token) => token,
3964 Err(e) => match dlg.token(e) {
3965 Ok(token) => token,
3966 Err(e) => {
3967 dlg.finished(false);
3968 return Err(common::Error::MissingToken(e));
3969 }
3970 },
3971 };
3972 let mut req_result = {
3973 let client = &self.hub.client;
3974 dlg.pre_request();
3975 let mut req_builder = hyper::Request::builder()
3976 .method(hyper::Method::GET)
3977 .uri(url.as_str())
3978 .header(USER_AGENT, self.hub._user_agent.clone());
3979
3980 if let Some(token) = token.as_ref() {
3981 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3982 }
3983
3984 let request = req_builder
3985 .header(CONTENT_LENGTH, 0_u64)
3986 .body(common::to_body::<String>(None));
3987
3988 client.request(request.unwrap()).await
3989 };
3990
3991 match req_result {
3992 Err(err) => {
3993 if let common::Retry::After(d) = dlg.http_error(&err) {
3994 sleep(d).await;
3995 continue;
3996 }
3997 dlg.finished(false);
3998 return Err(common::Error::HttpError(err));
3999 }
4000 Ok(res) => {
4001 let (mut parts, body) = res.into_parts();
4002 let mut body = common::Body::new(body);
4003 if !parts.status.is_success() {
4004 let bytes = common::to_bytes(body).await.unwrap_or_default();
4005 let error = serde_json::from_str(&common::to_string(&bytes));
4006 let response = common::to_response(parts, bytes.into());
4007
4008 if let common::Retry::After(d) =
4009 dlg.http_failure(&response, error.as_ref().ok())
4010 {
4011 sleep(d).await;
4012 continue;
4013 }
4014
4015 dlg.finished(false);
4016
4017 return Err(match error {
4018 Ok(value) => common::Error::BadRequest(value),
4019 _ => common::Error::Failure(response),
4020 });
4021 }
4022 let response = {
4023 let bytes = common::to_bytes(body).await.unwrap_or_default();
4024 let encoded = common::to_string(&bytes);
4025 match serde_json::from_str(&encoded) {
4026 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4027 Err(error) => {
4028 dlg.response_json_decode_error(&encoded, &error);
4029 return Err(common::Error::JsonDecodeError(
4030 encoded.to_string(),
4031 error,
4032 ));
4033 }
4034 }
4035 };
4036
4037 dlg.finished(true);
4038 return Ok(response);
4039 }
4040 }
4041 }
4042 }
4043
4044 /// The name of the application in the form enterprises/{enterpriseId}/applications/{package_name}.
4045 ///
4046 /// Sets the *name* path property to the given value.
4047 ///
4048 /// Even though the property as already been set when instantiating this call,
4049 /// we provide this method for API completeness.
4050 pub fn name(mut self, new_value: &str) -> EnterpriseApplicationGetCall<'a, C> {
4051 self._name = new_value.to_string();
4052 self
4053 }
4054 /// The preferred language for localized application info, as a BCP47 tag (e.g. "en-US", "de"). If not specified the default language of the application will be used.
4055 ///
4056 /// Sets the *language code* query property to the given value.
4057 pub fn language_code(mut self, new_value: &str) -> EnterpriseApplicationGetCall<'a, C> {
4058 self._language_code = Some(new_value.to_string());
4059 self
4060 }
4061 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4062 /// while executing the actual API request.
4063 ///
4064 /// ````text
4065 /// It should be used to handle progress information, and to implement a certain level of resilience.
4066 /// ````
4067 ///
4068 /// Sets the *delegate* property to the given value.
4069 pub fn delegate(
4070 mut self,
4071 new_value: &'a mut dyn common::Delegate,
4072 ) -> EnterpriseApplicationGetCall<'a, C> {
4073 self._delegate = Some(new_value);
4074 self
4075 }
4076
4077 /// Set any additional parameter of the query string used in the request.
4078 /// It should be used to set parameters which are not yet available through their own
4079 /// setters.
4080 ///
4081 /// Please note that this method must not be used to set any of the known parameters
4082 /// which have their own setter method. If done anyway, the request will fail.
4083 ///
4084 /// # Additional Parameters
4085 ///
4086 /// * *$.xgafv* (query-string) - V1 error format.
4087 /// * *access_token* (query-string) - OAuth access token.
4088 /// * *alt* (query-string) - Data format for response.
4089 /// * *callback* (query-string) - JSONP
4090 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4091 /// * *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.
4092 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4093 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4094 /// * *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.
4095 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4096 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4097 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseApplicationGetCall<'a, C>
4098 where
4099 T: AsRef<str>,
4100 {
4101 self._additional_params
4102 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4103 self
4104 }
4105
4106 /// Identifies the authorization scope for the method you are building.
4107 ///
4108 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4109 /// [`Scope::Full`].
4110 ///
4111 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4112 /// tokens for more than one scope.
4113 ///
4114 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4115 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4116 /// sufficient, a read-write scope will do as well.
4117 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseApplicationGetCall<'a, C>
4118 where
4119 St: AsRef<str>,
4120 {
4121 self._scopes.insert(String::from(scope.as_ref()));
4122 self
4123 }
4124 /// Identifies the authorization scope(s) for the method you are building.
4125 ///
4126 /// See [`Self::add_scope()`] for details.
4127 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseApplicationGetCall<'a, C>
4128 where
4129 I: IntoIterator<Item = St>,
4130 St: AsRef<str>,
4131 {
4132 self._scopes
4133 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4134 self
4135 }
4136
4137 /// Removes all scopes, and no default scope will be used either.
4138 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4139 /// for details).
4140 pub fn clear_scopes(mut self) -> EnterpriseApplicationGetCall<'a, C> {
4141 self._scopes.clear();
4142 self
4143 }
4144}
4145
4146/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.
4147///
4148/// A builder for the *devices.operations.cancel* method supported by a *enterprise* resource.
4149/// It is not used directly, but through a [`EnterpriseMethods`] instance.
4150///
4151/// # Example
4152///
4153/// Instantiate a resource method builder
4154///
4155/// ```test_harness,no_run
4156/// # extern crate hyper;
4157/// # extern crate hyper_rustls;
4158/// # extern crate google_androidmanagement1 as androidmanagement1;
4159/// # async fn dox() {
4160/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4161///
4162/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4163/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4164/// # secret,
4165/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4166/// # ).build().await.unwrap();
4167///
4168/// # let client = hyper_util::client::legacy::Client::builder(
4169/// # hyper_util::rt::TokioExecutor::new()
4170/// # )
4171/// # .build(
4172/// # hyper_rustls::HttpsConnectorBuilder::new()
4173/// # .with_native_roots()
4174/// # .unwrap()
4175/// # .https_or_http()
4176/// # .enable_http1()
4177/// # .build()
4178/// # );
4179/// # let mut hub = AndroidManagement::new(client, auth);
4180/// // You can configure optional parameters by calling the respective setters at will, and
4181/// // execute the final call using `doit()`.
4182/// // Values shown here are possibly random and not representative !
4183/// let result = hub.enterprises().devices_operations_cancel("name")
4184/// .doit().await;
4185/// # }
4186/// ```
4187pub struct EnterpriseDeviceOperationCancelCall<'a, C>
4188where
4189 C: 'a,
4190{
4191 hub: &'a AndroidManagement<C>,
4192 _name: String,
4193 _delegate: Option<&'a mut dyn common::Delegate>,
4194 _additional_params: HashMap<String, String>,
4195 _scopes: BTreeSet<String>,
4196}
4197
4198impl<'a, C> common::CallBuilder for EnterpriseDeviceOperationCancelCall<'a, C> {}
4199
4200impl<'a, C> EnterpriseDeviceOperationCancelCall<'a, C>
4201where
4202 C: common::Connector,
4203{
4204 /// Perform the operation you have build so far.
4205 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4206 use std::borrow::Cow;
4207 use std::io::{Read, Seek};
4208
4209 use common::{url::Params, ToParts};
4210 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4211
4212 let mut dd = common::DefaultDelegate;
4213 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4214 dlg.begin(common::MethodInfo {
4215 id: "androidmanagement.enterprises.devices.operations.cancel",
4216 http_method: hyper::Method::POST,
4217 });
4218
4219 for &field in ["alt", "name"].iter() {
4220 if self._additional_params.contains_key(field) {
4221 dlg.finished(false);
4222 return Err(common::Error::FieldClash(field));
4223 }
4224 }
4225
4226 let mut params = Params::with_capacity(3 + self._additional_params.len());
4227 params.push("name", self._name);
4228
4229 params.extend(self._additional_params.iter());
4230
4231 params.push("alt", "json");
4232 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
4233 if self._scopes.is_empty() {
4234 self._scopes.insert(Scope::Full.as_ref().to_string());
4235 }
4236
4237 #[allow(clippy::single_element_loop)]
4238 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4239 url = params.uri_replacement(url, param_name, find_this, true);
4240 }
4241 {
4242 let to_remove = ["name"];
4243 params.remove_params(&to_remove);
4244 }
4245
4246 let url = params.parse_with_url(&url);
4247
4248 loop {
4249 let token = match self
4250 .hub
4251 .auth
4252 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4253 .await
4254 {
4255 Ok(token) => token,
4256 Err(e) => match dlg.token(e) {
4257 Ok(token) => token,
4258 Err(e) => {
4259 dlg.finished(false);
4260 return Err(common::Error::MissingToken(e));
4261 }
4262 },
4263 };
4264 let mut req_result = {
4265 let client = &self.hub.client;
4266 dlg.pre_request();
4267 let mut req_builder = hyper::Request::builder()
4268 .method(hyper::Method::POST)
4269 .uri(url.as_str())
4270 .header(USER_AGENT, self.hub._user_agent.clone());
4271
4272 if let Some(token) = token.as_ref() {
4273 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4274 }
4275
4276 let request = req_builder
4277 .header(CONTENT_LENGTH, 0_u64)
4278 .body(common::to_body::<String>(None));
4279
4280 client.request(request.unwrap()).await
4281 };
4282
4283 match req_result {
4284 Err(err) => {
4285 if let common::Retry::After(d) = dlg.http_error(&err) {
4286 sleep(d).await;
4287 continue;
4288 }
4289 dlg.finished(false);
4290 return Err(common::Error::HttpError(err));
4291 }
4292 Ok(res) => {
4293 let (mut parts, body) = res.into_parts();
4294 let mut body = common::Body::new(body);
4295 if !parts.status.is_success() {
4296 let bytes = common::to_bytes(body).await.unwrap_or_default();
4297 let error = serde_json::from_str(&common::to_string(&bytes));
4298 let response = common::to_response(parts, bytes.into());
4299
4300 if let common::Retry::After(d) =
4301 dlg.http_failure(&response, error.as_ref().ok())
4302 {
4303 sleep(d).await;
4304 continue;
4305 }
4306
4307 dlg.finished(false);
4308
4309 return Err(match error {
4310 Ok(value) => common::Error::BadRequest(value),
4311 _ => common::Error::Failure(response),
4312 });
4313 }
4314 let response = {
4315 let bytes = common::to_bytes(body).await.unwrap_or_default();
4316 let encoded = common::to_string(&bytes);
4317 match serde_json::from_str(&encoded) {
4318 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4319 Err(error) => {
4320 dlg.response_json_decode_error(&encoded, &error);
4321 return Err(common::Error::JsonDecodeError(
4322 encoded.to_string(),
4323 error,
4324 ));
4325 }
4326 }
4327 };
4328
4329 dlg.finished(true);
4330 return Ok(response);
4331 }
4332 }
4333 }
4334 }
4335
4336 /// The name of the operation resource to be cancelled.
4337 ///
4338 /// Sets the *name* path property to the given value.
4339 ///
4340 /// Even though the property as already been set when instantiating this call,
4341 /// we provide this method for API completeness.
4342 pub fn name(mut self, new_value: &str) -> EnterpriseDeviceOperationCancelCall<'a, C> {
4343 self._name = new_value.to_string();
4344 self
4345 }
4346 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4347 /// while executing the actual API request.
4348 ///
4349 /// ````text
4350 /// It should be used to handle progress information, and to implement a certain level of resilience.
4351 /// ````
4352 ///
4353 /// Sets the *delegate* property to the given value.
4354 pub fn delegate(
4355 mut self,
4356 new_value: &'a mut dyn common::Delegate,
4357 ) -> EnterpriseDeviceOperationCancelCall<'a, C> {
4358 self._delegate = Some(new_value);
4359 self
4360 }
4361
4362 /// Set any additional parameter of the query string used in the request.
4363 /// It should be used to set parameters which are not yet available through their own
4364 /// setters.
4365 ///
4366 /// Please note that this method must not be used to set any of the known parameters
4367 /// which have their own setter method. If done anyway, the request will fail.
4368 ///
4369 /// # Additional Parameters
4370 ///
4371 /// * *$.xgafv* (query-string) - V1 error format.
4372 /// * *access_token* (query-string) - OAuth access token.
4373 /// * *alt* (query-string) - Data format for response.
4374 /// * *callback* (query-string) - JSONP
4375 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4376 /// * *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.
4377 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4378 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4379 /// * *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.
4380 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4381 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4382 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceOperationCancelCall<'a, C>
4383 where
4384 T: AsRef<str>,
4385 {
4386 self._additional_params
4387 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4388 self
4389 }
4390
4391 /// Identifies the authorization scope for the method you are building.
4392 ///
4393 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4394 /// [`Scope::Full`].
4395 ///
4396 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4397 /// tokens for more than one scope.
4398 ///
4399 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4400 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4401 /// sufficient, a read-write scope will do as well.
4402 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceOperationCancelCall<'a, C>
4403 where
4404 St: AsRef<str>,
4405 {
4406 self._scopes.insert(String::from(scope.as_ref()));
4407 self
4408 }
4409 /// Identifies the authorization scope(s) for the method you are building.
4410 ///
4411 /// See [`Self::add_scope()`] for details.
4412 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceOperationCancelCall<'a, C>
4413 where
4414 I: IntoIterator<Item = St>,
4415 St: AsRef<str>,
4416 {
4417 self._scopes
4418 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4419 self
4420 }
4421
4422 /// Removes all scopes, and no default scope will be used either.
4423 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4424 /// for details).
4425 pub fn clear_scopes(mut self) -> EnterpriseDeviceOperationCancelCall<'a, C> {
4426 self._scopes.clear();
4427 self
4428 }
4429}
4430
4431/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
4432///
4433/// A builder for the *devices.operations.get* method supported by a *enterprise* resource.
4434/// It is not used directly, but through a [`EnterpriseMethods`] instance.
4435///
4436/// # Example
4437///
4438/// Instantiate a resource method builder
4439///
4440/// ```test_harness,no_run
4441/// # extern crate hyper;
4442/// # extern crate hyper_rustls;
4443/// # extern crate google_androidmanagement1 as androidmanagement1;
4444/// # async fn dox() {
4445/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4446///
4447/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4448/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4449/// # secret,
4450/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4451/// # ).build().await.unwrap();
4452///
4453/// # let client = hyper_util::client::legacy::Client::builder(
4454/// # hyper_util::rt::TokioExecutor::new()
4455/// # )
4456/// # .build(
4457/// # hyper_rustls::HttpsConnectorBuilder::new()
4458/// # .with_native_roots()
4459/// # .unwrap()
4460/// # .https_or_http()
4461/// # .enable_http1()
4462/// # .build()
4463/// # );
4464/// # let mut hub = AndroidManagement::new(client, auth);
4465/// // You can configure optional parameters by calling the respective setters at will, and
4466/// // execute the final call using `doit()`.
4467/// // Values shown here are possibly random and not representative !
4468/// let result = hub.enterprises().devices_operations_get("name")
4469/// .doit().await;
4470/// # }
4471/// ```
4472pub struct EnterpriseDeviceOperationGetCall<'a, C>
4473where
4474 C: 'a,
4475{
4476 hub: &'a AndroidManagement<C>,
4477 _name: String,
4478 _delegate: Option<&'a mut dyn common::Delegate>,
4479 _additional_params: HashMap<String, String>,
4480 _scopes: BTreeSet<String>,
4481}
4482
4483impl<'a, C> common::CallBuilder for EnterpriseDeviceOperationGetCall<'a, C> {}
4484
4485impl<'a, C> EnterpriseDeviceOperationGetCall<'a, C>
4486where
4487 C: common::Connector,
4488{
4489 /// Perform the operation you have build so far.
4490 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4491 use std::borrow::Cow;
4492 use std::io::{Read, Seek};
4493
4494 use common::{url::Params, ToParts};
4495 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4496
4497 let mut dd = common::DefaultDelegate;
4498 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4499 dlg.begin(common::MethodInfo {
4500 id: "androidmanagement.enterprises.devices.operations.get",
4501 http_method: hyper::Method::GET,
4502 });
4503
4504 for &field in ["alt", "name"].iter() {
4505 if self._additional_params.contains_key(field) {
4506 dlg.finished(false);
4507 return Err(common::Error::FieldClash(field));
4508 }
4509 }
4510
4511 let mut params = Params::with_capacity(3 + self._additional_params.len());
4512 params.push("name", self._name);
4513
4514 params.extend(self._additional_params.iter());
4515
4516 params.push("alt", "json");
4517 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4518 if self._scopes.is_empty() {
4519 self._scopes.insert(Scope::Full.as_ref().to_string());
4520 }
4521
4522 #[allow(clippy::single_element_loop)]
4523 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4524 url = params.uri_replacement(url, param_name, find_this, true);
4525 }
4526 {
4527 let to_remove = ["name"];
4528 params.remove_params(&to_remove);
4529 }
4530
4531 let url = params.parse_with_url(&url);
4532
4533 loop {
4534 let token = match self
4535 .hub
4536 .auth
4537 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4538 .await
4539 {
4540 Ok(token) => token,
4541 Err(e) => match dlg.token(e) {
4542 Ok(token) => token,
4543 Err(e) => {
4544 dlg.finished(false);
4545 return Err(common::Error::MissingToken(e));
4546 }
4547 },
4548 };
4549 let mut req_result = {
4550 let client = &self.hub.client;
4551 dlg.pre_request();
4552 let mut req_builder = hyper::Request::builder()
4553 .method(hyper::Method::GET)
4554 .uri(url.as_str())
4555 .header(USER_AGENT, self.hub._user_agent.clone());
4556
4557 if let Some(token) = token.as_ref() {
4558 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4559 }
4560
4561 let request = req_builder
4562 .header(CONTENT_LENGTH, 0_u64)
4563 .body(common::to_body::<String>(None));
4564
4565 client.request(request.unwrap()).await
4566 };
4567
4568 match req_result {
4569 Err(err) => {
4570 if let common::Retry::After(d) = dlg.http_error(&err) {
4571 sleep(d).await;
4572 continue;
4573 }
4574 dlg.finished(false);
4575 return Err(common::Error::HttpError(err));
4576 }
4577 Ok(res) => {
4578 let (mut parts, body) = res.into_parts();
4579 let mut body = common::Body::new(body);
4580 if !parts.status.is_success() {
4581 let bytes = common::to_bytes(body).await.unwrap_or_default();
4582 let error = serde_json::from_str(&common::to_string(&bytes));
4583 let response = common::to_response(parts, bytes.into());
4584
4585 if let common::Retry::After(d) =
4586 dlg.http_failure(&response, error.as_ref().ok())
4587 {
4588 sleep(d).await;
4589 continue;
4590 }
4591
4592 dlg.finished(false);
4593
4594 return Err(match error {
4595 Ok(value) => common::Error::BadRequest(value),
4596 _ => common::Error::Failure(response),
4597 });
4598 }
4599 let response = {
4600 let bytes = common::to_bytes(body).await.unwrap_or_default();
4601 let encoded = common::to_string(&bytes);
4602 match serde_json::from_str(&encoded) {
4603 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4604 Err(error) => {
4605 dlg.response_json_decode_error(&encoded, &error);
4606 return Err(common::Error::JsonDecodeError(
4607 encoded.to_string(),
4608 error,
4609 ));
4610 }
4611 }
4612 };
4613
4614 dlg.finished(true);
4615 return Ok(response);
4616 }
4617 }
4618 }
4619 }
4620
4621 /// The name of the operation resource.
4622 ///
4623 /// Sets the *name* path property to the given value.
4624 ///
4625 /// Even though the property as already been set when instantiating this call,
4626 /// we provide this method for API completeness.
4627 pub fn name(mut self, new_value: &str) -> EnterpriseDeviceOperationGetCall<'a, C> {
4628 self._name = new_value.to_string();
4629 self
4630 }
4631 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4632 /// while executing the actual API request.
4633 ///
4634 /// ````text
4635 /// It should be used to handle progress information, and to implement a certain level of resilience.
4636 /// ````
4637 ///
4638 /// Sets the *delegate* property to the given value.
4639 pub fn delegate(
4640 mut self,
4641 new_value: &'a mut dyn common::Delegate,
4642 ) -> EnterpriseDeviceOperationGetCall<'a, C> {
4643 self._delegate = Some(new_value);
4644 self
4645 }
4646
4647 /// Set any additional parameter of the query string used in the request.
4648 /// It should be used to set parameters which are not yet available through their own
4649 /// setters.
4650 ///
4651 /// Please note that this method must not be used to set any of the known parameters
4652 /// which have their own setter method. If done anyway, the request will fail.
4653 ///
4654 /// # Additional Parameters
4655 ///
4656 /// * *$.xgafv* (query-string) - V1 error format.
4657 /// * *access_token* (query-string) - OAuth access token.
4658 /// * *alt* (query-string) - Data format for response.
4659 /// * *callback* (query-string) - JSONP
4660 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4661 /// * *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.
4662 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4663 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4664 /// * *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.
4665 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4666 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4667 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceOperationGetCall<'a, C>
4668 where
4669 T: AsRef<str>,
4670 {
4671 self._additional_params
4672 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4673 self
4674 }
4675
4676 /// Identifies the authorization scope for the method you are building.
4677 ///
4678 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4679 /// [`Scope::Full`].
4680 ///
4681 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4682 /// tokens for more than one scope.
4683 ///
4684 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4685 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4686 /// sufficient, a read-write scope will do as well.
4687 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceOperationGetCall<'a, C>
4688 where
4689 St: AsRef<str>,
4690 {
4691 self._scopes.insert(String::from(scope.as_ref()));
4692 self
4693 }
4694 /// Identifies the authorization scope(s) for the method you are building.
4695 ///
4696 /// See [`Self::add_scope()`] for details.
4697 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceOperationGetCall<'a, C>
4698 where
4699 I: IntoIterator<Item = St>,
4700 St: AsRef<str>,
4701 {
4702 self._scopes
4703 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4704 self
4705 }
4706
4707 /// Removes all scopes, and no default scope will be used either.
4708 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4709 /// for details).
4710 pub fn clear_scopes(mut self) -> EnterpriseDeviceOperationGetCall<'a, C> {
4711 self._scopes.clear();
4712 self
4713 }
4714}
4715
4716/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED.
4717///
4718/// A builder for the *devices.operations.list* method supported by a *enterprise* resource.
4719/// It is not used directly, but through a [`EnterpriseMethods`] instance.
4720///
4721/// # Example
4722///
4723/// Instantiate a resource method builder
4724///
4725/// ```test_harness,no_run
4726/// # extern crate hyper;
4727/// # extern crate hyper_rustls;
4728/// # extern crate google_androidmanagement1 as androidmanagement1;
4729/// # async fn dox() {
4730/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4731///
4732/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4733/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4734/// # secret,
4735/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4736/// # ).build().await.unwrap();
4737///
4738/// # let client = hyper_util::client::legacy::Client::builder(
4739/// # hyper_util::rt::TokioExecutor::new()
4740/// # )
4741/// # .build(
4742/// # hyper_rustls::HttpsConnectorBuilder::new()
4743/// # .with_native_roots()
4744/// # .unwrap()
4745/// # .https_or_http()
4746/// # .enable_http1()
4747/// # .build()
4748/// # );
4749/// # let mut hub = AndroidManagement::new(client, auth);
4750/// // You can configure optional parameters by calling the respective setters at will, and
4751/// // execute the final call using `doit()`.
4752/// // Values shown here are possibly random and not representative !
4753/// let result = hub.enterprises().devices_operations_list("name")
4754/// .page_token("ea")
4755/// .page_size(-55)
4756/// .filter("invidunt")
4757/// .doit().await;
4758/// # }
4759/// ```
4760pub struct EnterpriseDeviceOperationListCall<'a, C>
4761where
4762 C: 'a,
4763{
4764 hub: &'a AndroidManagement<C>,
4765 _name: String,
4766 _page_token: Option<String>,
4767 _page_size: Option<i32>,
4768 _filter: Option<String>,
4769 _delegate: Option<&'a mut dyn common::Delegate>,
4770 _additional_params: HashMap<String, String>,
4771 _scopes: BTreeSet<String>,
4772}
4773
4774impl<'a, C> common::CallBuilder for EnterpriseDeviceOperationListCall<'a, C> {}
4775
4776impl<'a, C> EnterpriseDeviceOperationListCall<'a, C>
4777where
4778 C: common::Connector,
4779{
4780 /// Perform the operation you have build so far.
4781 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
4782 use std::borrow::Cow;
4783 use std::io::{Read, Seek};
4784
4785 use common::{url::Params, ToParts};
4786 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4787
4788 let mut dd = common::DefaultDelegate;
4789 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4790 dlg.begin(common::MethodInfo {
4791 id: "androidmanagement.enterprises.devices.operations.list",
4792 http_method: hyper::Method::GET,
4793 });
4794
4795 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
4796 if self._additional_params.contains_key(field) {
4797 dlg.finished(false);
4798 return Err(common::Error::FieldClash(field));
4799 }
4800 }
4801
4802 let mut params = Params::with_capacity(6 + self._additional_params.len());
4803 params.push("name", self._name);
4804 if let Some(value) = self._page_token.as_ref() {
4805 params.push("pageToken", value);
4806 }
4807 if let Some(value) = self._page_size.as_ref() {
4808 params.push("pageSize", value.to_string());
4809 }
4810 if let Some(value) = self._filter.as_ref() {
4811 params.push("filter", value);
4812 }
4813
4814 params.extend(self._additional_params.iter());
4815
4816 params.push("alt", "json");
4817 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4818 if self._scopes.is_empty() {
4819 self._scopes.insert(Scope::Full.as_ref().to_string());
4820 }
4821
4822 #[allow(clippy::single_element_loop)]
4823 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4824 url = params.uri_replacement(url, param_name, find_this, true);
4825 }
4826 {
4827 let to_remove = ["name"];
4828 params.remove_params(&to_remove);
4829 }
4830
4831 let url = params.parse_with_url(&url);
4832
4833 loop {
4834 let token = match self
4835 .hub
4836 .auth
4837 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4838 .await
4839 {
4840 Ok(token) => token,
4841 Err(e) => match dlg.token(e) {
4842 Ok(token) => token,
4843 Err(e) => {
4844 dlg.finished(false);
4845 return Err(common::Error::MissingToken(e));
4846 }
4847 },
4848 };
4849 let mut req_result = {
4850 let client = &self.hub.client;
4851 dlg.pre_request();
4852 let mut req_builder = hyper::Request::builder()
4853 .method(hyper::Method::GET)
4854 .uri(url.as_str())
4855 .header(USER_AGENT, self.hub._user_agent.clone());
4856
4857 if let Some(token) = token.as_ref() {
4858 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4859 }
4860
4861 let request = req_builder
4862 .header(CONTENT_LENGTH, 0_u64)
4863 .body(common::to_body::<String>(None));
4864
4865 client.request(request.unwrap()).await
4866 };
4867
4868 match req_result {
4869 Err(err) => {
4870 if let common::Retry::After(d) = dlg.http_error(&err) {
4871 sleep(d).await;
4872 continue;
4873 }
4874 dlg.finished(false);
4875 return Err(common::Error::HttpError(err));
4876 }
4877 Ok(res) => {
4878 let (mut parts, body) = res.into_parts();
4879 let mut body = common::Body::new(body);
4880 if !parts.status.is_success() {
4881 let bytes = common::to_bytes(body).await.unwrap_or_default();
4882 let error = serde_json::from_str(&common::to_string(&bytes));
4883 let response = common::to_response(parts, bytes.into());
4884
4885 if let common::Retry::After(d) =
4886 dlg.http_failure(&response, error.as_ref().ok())
4887 {
4888 sleep(d).await;
4889 continue;
4890 }
4891
4892 dlg.finished(false);
4893
4894 return Err(match error {
4895 Ok(value) => common::Error::BadRequest(value),
4896 _ => common::Error::Failure(response),
4897 });
4898 }
4899 let response = {
4900 let bytes = common::to_bytes(body).await.unwrap_or_default();
4901 let encoded = common::to_string(&bytes);
4902 match serde_json::from_str(&encoded) {
4903 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4904 Err(error) => {
4905 dlg.response_json_decode_error(&encoded, &error);
4906 return Err(common::Error::JsonDecodeError(
4907 encoded.to_string(),
4908 error,
4909 ));
4910 }
4911 }
4912 };
4913
4914 dlg.finished(true);
4915 return Ok(response);
4916 }
4917 }
4918 }
4919 }
4920
4921 /// The name of the operation's parent resource.
4922 ///
4923 /// Sets the *name* path property to the given value.
4924 ///
4925 /// Even though the property as already been set when instantiating this call,
4926 /// we provide this method for API completeness.
4927 pub fn name(mut self, new_value: &str) -> EnterpriseDeviceOperationListCall<'a, C> {
4928 self._name = new_value.to_string();
4929 self
4930 }
4931 /// The standard list page token.
4932 ///
4933 /// Sets the *page token* query property to the given value.
4934 pub fn page_token(mut self, new_value: &str) -> EnterpriseDeviceOperationListCall<'a, C> {
4935 self._page_token = Some(new_value.to_string());
4936 self
4937 }
4938 /// The standard list page size.
4939 ///
4940 /// Sets the *page size* query property to the given value.
4941 pub fn page_size(mut self, new_value: i32) -> EnterpriseDeviceOperationListCall<'a, C> {
4942 self._page_size = Some(new_value);
4943 self
4944 }
4945 /// The standard list filter.
4946 ///
4947 /// Sets the *filter* query property to the given value.
4948 pub fn filter(mut self, new_value: &str) -> EnterpriseDeviceOperationListCall<'a, C> {
4949 self._filter = Some(new_value.to_string());
4950 self
4951 }
4952 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4953 /// while executing the actual API request.
4954 ///
4955 /// ````text
4956 /// It should be used to handle progress information, and to implement a certain level of resilience.
4957 /// ````
4958 ///
4959 /// Sets the *delegate* property to the given value.
4960 pub fn delegate(
4961 mut self,
4962 new_value: &'a mut dyn common::Delegate,
4963 ) -> EnterpriseDeviceOperationListCall<'a, C> {
4964 self._delegate = Some(new_value);
4965 self
4966 }
4967
4968 /// Set any additional parameter of the query string used in the request.
4969 /// It should be used to set parameters which are not yet available through their own
4970 /// setters.
4971 ///
4972 /// Please note that this method must not be used to set any of the known parameters
4973 /// which have their own setter method. If done anyway, the request will fail.
4974 ///
4975 /// # Additional Parameters
4976 ///
4977 /// * *$.xgafv* (query-string) - V1 error format.
4978 /// * *access_token* (query-string) - OAuth access token.
4979 /// * *alt* (query-string) - Data format for response.
4980 /// * *callback* (query-string) - JSONP
4981 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4982 /// * *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.
4983 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4984 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4985 /// * *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.
4986 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4987 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4988 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceOperationListCall<'a, C>
4989 where
4990 T: AsRef<str>,
4991 {
4992 self._additional_params
4993 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4994 self
4995 }
4996
4997 /// Identifies the authorization scope for the method you are building.
4998 ///
4999 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5000 /// [`Scope::Full`].
5001 ///
5002 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5003 /// tokens for more than one scope.
5004 ///
5005 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5006 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5007 /// sufficient, a read-write scope will do as well.
5008 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceOperationListCall<'a, C>
5009 where
5010 St: AsRef<str>,
5011 {
5012 self._scopes.insert(String::from(scope.as_ref()));
5013 self
5014 }
5015 /// Identifies the authorization scope(s) for the method you are building.
5016 ///
5017 /// See [`Self::add_scope()`] for details.
5018 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceOperationListCall<'a, C>
5019 where
5020 I: IntoIterator<Item = St>,
5021 St: AsRef<str>,
5022 {
5023 self._scopes
5024 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5025 self
5026 }
5027
5028 /// Removes all scopes, and no default scope will be used either.
5029 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5030 /// for details).
5031 pub fn clear_scopes(mut self) -> EnterpriseDeviceOperationListCall<'a, C> {
5032 self._scopes.clear();
5033 self
5034 }
5035}
5036
5037/// Deletes a device. This operation wipes the device. Deleted devices do not show up in enterprises.devices.list calls and a 404 is returned from enterprises.devices.get.
5038///
5039/// A builder for the *devices.delete* method supported by a *enterprise* resource.
5040/// It is not used directly, but through a [`EnterpriseMethods`] instance.
5041///
5042/// # Example
5043///
5044/// Instantiate a resource method builder
5045///
5046/// ```test_harness,no_run
5047/// # extern crate hyper;
5048/// # extern crate hyper_rustls;
5049/// # extern crate google_androidmanagement1 as androidmanagement1;
5050/// # async fn dox() {
5051/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5052///
5053/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5054/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5055/// # secret,
5056/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5057/// # ).build().await.unwrap();
5058///
5059/// # let client = hyper_util::client::legacy::Client::builder(
5060/// # hyper_util::rt::TokioExecutor::new()
5061/// # )
5062/// # .build(
5063/// # hyper_rustls::HttpsConnectorBuilder::new()
5064/// # .with_native_roots()
5065/// # .unwrap()
5066/// # .https_or_http()
5067/// # .enable_http1()
5068/// # .build()
5069/// # );
5070/// # let mut hub = AndroidManagement::new(client, auth);
5071/// // You can configure optional parameters by calling the respective setters at will, and
5072/// // execute the final call using `doit()`.
5073/// // Values shown here are possibly random and not representative !
5074/// let result = hub.enterprises().devices_delete("name")
5075/// .wipe_reason_message("duo")
5076/// .add_wipe_data_flags("ipsum")
5077/// .doit().await;
5078/// # }
5079/// ```
5080pub struct EnterpriseDeviceDeleteCall<'a, C>
5081where
5082 C: 'a,
5083{
5084 hub: &'a AndroidManagement<C>,
5085 _name: String,
5086 _wipe_reason_message: Option<String>,
5087 _wipe_data_flags: Vec<String>,
5088 _delegate: Option<&'a mut dyn common::Delegate>,
5089 _additional_params: HashMap<String, String>,
5090 _scopes: BTreeSet<String>,
5091}
5092
5093impl<'a, C> common::CallBuilder for EnterpriseDeviceDeleteCall<'a, C> {}
5094
5095impl<'a, C> EnterpriseDeviceDeleteCall<'a, C>
5096where
5097 C: common::Connector,
5098{
5099 /// Perform the operation you have build so far.
5100 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5101 use std::borrow::Cow;
5102 use std::io::{Read, Seek};
5103
5104 use common::{url::Params, ToParts};
5105 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5106
5107 let mut dd = common::DefaultDelegate;
5108 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5109 dlg.begin(common::MethodInfo {
5110 id: "androidmanagement.enterprises.devices.delete",
5111 http_method: hyper::Method::DELETE,
5112 });
5113
5114 for &field in ["alt", "name", "wipeReasonMessage", "wipeDataFlags"].iter() {
5115 if self._additional_params.contains_key(field) {
5116 dlg.finished(false);
5117 return Err(common::Error::FieldClash(field));
5118 }
5119 }
5120
5121 let mut params = Params::with_capacity(5 + self._additional_params.len());
5122 params.push("name", self._name);
5123 if let Some(value) = self._wipe_reason_message.as_ref() {
5124 params.push("wipeReasonMessage", value);
5125 }
5126 if !self._wipe_data_flags.is_empty() {
5127 for f in self._wipe_data_flags.iter() {
5128 params.push("wipeDataFlags", f);
5129 }
5130 }
5131
5132 params.extend(self._additional_params.iter());
5133
5134 params.push("alt", "json");
5135 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5136 if self._scopes.is_empty() {
5137 self._scopes.insert(Scope::Full.as_ref().to_string());
5138 }
5139
5140 #[allow(clippy::single_element_loop)]
5141 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5142 url = params.uri_replacement(url, param_name, find_this, true);
5143 }
5144 {
5145 let to_remove = ["name"];
5146 params.remove_params(&to_remove);
5147 }
5148
5149 let url = params.parse_with_url(&url);
5150
5151 loop {
5152 let token = match self
5153 .hub
5154 .auth
5155 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5156 .await
5157 {
5158 Ok(token) => token,
5159 Err(e) => match dlg.token(e) {
5160 Ok(token) => token,
5161 Err(e) => {
5162 dlg.finished(false);
5163 return Err(common::Error::MissingToken(e));
5164 }
5165 },
5166 };
5167 let mut req_result = {
5168 let client = &self.hub.client;
5169 dlg.pre_request();
5170 let mut req_builder = hyper::Request::builder()
5171 .method(hyper::Method::DELETE)
5172 .uri(url.as_str())
5173 .header(USER_AGENT, self.hub._user_agent.clone());
5174
5175 if let Some(token) = token.as_ref() {
5176 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5177 }
5178
5179 let request = req_builder
5180 .header(CONTENT_LENGTH, 0_u64)
5181 .body(common::to_body::<String>(None));
5182
5183 client.request(request.unwrap()).await
5184 };
5185
5186 match req_result {
5187 Err(err) => {
5188 if let common::Retry::After(d) = dlg.http_error(&err) {
5189 sleep(d).await;
5190 continue;
5191 }
5192 dlg.finished(false);
5193 return Err(common::Error::HttpError(err));
5194 }
5195 Ok(res) => {
5196 let (mut parts, body) = res.into_parts();
5197 let mut body = common::Body::new(body);
5198 if !parts.status.is_success() {
5199 let bytes = common::to_bytes(body).await.unwrap_or_default();
5200 let error = serde_json::from_str(&common::to_string(&bytes));
5201 let response = common::to_response(parts, bytes.into());
5202
5203 if let common::Retry::After(d) =
5204 dlg.http_failure(&response, error.as_ref().ok())
5205 {
5206 sleep(d).await;
5207 continue;
5208 }
5209
5210 dlg.finished(false);
5211
5212 return Err(match error {
5213 Ok(value) => common::Error::BadRequest(value),
5214 _ => common::Error::Failure(response),
5215 });
5216 }
5217 let response = {
5218 let bytes = common::to_bytes(body).await.unwrap_or_default();
5219 let encoded = common::to_string(&bytes);
5220 match serde_json::from_str(&encoded) {
5221 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5222 Err(error) => {
5223 dlg.response_json_decode_error(&encoded, &error);
5224 return Err(common::Error::JsonDecodeError(
5225 encoded.to_string(),
5226 error,
5227 ));
5228 }
5229 }
5230 };
5231
5232 dlg.finished(true);
5233 return Ok(response);
5234 }
5235 }
5236 }
5237 }
5238
5239 /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
5240 ///
5241 /// Sets the *name* path property to the given value.
5242 ///
5243 /// Even though the property as already been set when instantiating this call,
5244 /// we provide this method for API completeness.
5245 pub fn name(mut self, new_value: &str) -> EnterpriseDeviceDeleteCall<'a, C> {
5246 self._name = new_value.to_string();
5247 self
5248 }
5249 /// Optional. A short message displayed to the user before wiping the work profile on personal devices. This has no effect on company owned devices. The maximum message length is 200 characters.
5250 ///
5251 /// Sets the *wipe reason message* query property to the given value.
5252 pub fn wipe_reason_message(mut self, new_value: &str) -> EnterpriseDeviceDeleteCall<'a, C> {
5253 self._wipe_reason_message = Some(new_value.to_string());
5254 self
5255 }
5256 /// Optional flags that control the device wiping behavior.
5257 ///
5258 /// Append the given value to the *wipe data flags* query property.
5259 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5260 pub fn add_wipe_data_flags(mut self, new_value: &str) -> EnterpriseDeviceDeleteCall<'a, C> {
5261 self._wipe_data_flags.push(new_value.to_string());
5262 self
5263 }
5264 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5265 /// while executing the actual API request.
5266 ///
5267 /// ````text
5268 /// It should be used to handle progress information, and to implement a certain level of resilience.
5269 /// ````
5270 ///
5271 /// Sets the *delegate* property to the given value.
5272 pub fn delegate(
5273 mut self,
5274 new_value: &'a mut dyn common::Delegate,
5275 ) -> EnterpriseDeviceDeleteCall<'a, C> {
5276 self._delegate = Some(new_value);
5277 self
5278 }
5279
5280 /// Set any additional parameter of the query string used in the request.
5281 /// It should be used to set parameters which are not yet available through their own
5282 /// setters.
5283 ///
5284 /// Please note that this method must not be used to set any of the known parameters
5285 /// which have their own setter method. If done anyway, the request will fail.
5286 ///
5287 /// # Additional Parameters
5288 ///
5289 /// * *$.xgafv* (query-string) - V1 error format.
5290 /// * *access_token* (query-string) - OAuth access token.
5291 /// * *alt* (query-string) - Data format for response.
5292 /// * *callback* (query-string) - JSONP
5293 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5294 /// * *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.
5295 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5296 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5297 /// * *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.
5298 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5299 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5300 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceDeleteCall<'a, C>
5301 where
5302 T: AsRef<str>,
5303 {
5304 self._additional_params
5305 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5306 self
5307 }
5308
5309 /// Identifies the authorization scope for the method you are building.
5310 ///
5311 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5312 /// [`Scope::Full`].
5313 ///
5314 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5315 /// tokens for more than one scope.
5316 ///
5317 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5318 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5319 /// sufficient, a read-write scope will do as well.
5320 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceDeleteCall<'a, C>
5321 where
5322 St: AsRef<str>,
5323 {
5324 self._scopes.insert(String::from(scope.as_ref()));
5325 self
5326 }
5327 /// Identifies the authorization scope(s) for the method you are building.
5328 ///
5329 /// See [`Self::add_scope()`] for details.
5330 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceDeleteCall<'a, C>
5331 where
5332 I: IntoIterator<Item = St>,
5333 St: AsRef<str>,
5334 {
5335 self._scopes
5336 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5337 self
5338 }
5339
5340 /// Removes all scopes, and no default scope will be used either.
5341 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5342 /// for details).
5343 pub fn clear_scopes(mut self) -> EnterpriseDeviceDeleteCall<'a, C> {
5344 self._scopes.clear();
5345 self
5346 }
5347}
5348
5349/// Gets a device. Deleted devices will respond with a 404 error.
5350///
5351/// A builder for the *devices.get* method supported by a *enterprise* resource.
5352/// It is not used directly, but through a [`EnterpriseMethods`] instance.
5353///
5354/// # Example
5355///
5356/// Instantiate a resource method builder
5357///
5358/// ```test_harness,no_run
5359/// # extern crate hyper;
5360/// # extern crate hyper_rustls;
5361/// # extern crate google_androidmanagement1 as androidmanagement1;
5362/// # async fn dox() {
5363/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5364///
5365/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5366/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5367/// # secret,
5368/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5369/// # ).build().await.unwrap();
5370///
5371/// # let client = hyper_util::client::legacy::Client::builder(
5372/// # hyper_util::rt::TokioExecutor::new()
5373/// # )
5374/// # .build(
5375/// # hyper_rustls::HttpsConnectorBuilder::new()
5376/// # .with_native_roots()
5377/// # .unwrap()
5378/// # .https_or_http()
5379/// # .enable_http1()
5380/// # .build()
5381/// # );
5382/// # let mut hub = AndroidManagement::new(client, auth);
5383/// // You can configure optional parameters by calling the respective setters at will, and
5384/// // execute the final call using `doit()`.
5385/// // Values shown here are possibly random and not representative !
5386/// let result = hub.enterprises().devices_get("name")
5387/// .doit().await;
5388/// # }
5389/// ```
5390pub struct EnterpriseDeviceGetCall<'a, C>
5391where
5392 C: 'a,
5393{
5394 hub: &'a AndroidManagement<C>,
5395 _name: String,
5396 _delegate: Option<&'a mut dyn common::Delegate>,
5397 _additional_params: HashMap<String, String>,
5398 _scopes: BTreeSet<String>,
5399}
5400
5401impl<'a, C> common::CallBuilder for EnterpriseDeviceGetCall<'a, C> {}
5402
5403impl<'a, C> EnterpriseDeviceGetCall<'a, C>
5404where
5405 C: common::Connector,
5406{
5407 /// Perform the operation you have build so far.
5408 pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
5409 use std::borrow::Cow;
5410 use std::io::{Read, Seek};
5411
5412 use common::{url::Params, ToParts};
5413 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5414
5415 let mut dd = common::DefaultDelegate;
5416 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5417 dlg.begin(common::MethodInfo {
5418 id: "androidmanagement.enterprises.devices.get",
5419 http_method: hyper::Method::GET,
5420 });
5421
5422 for &field in ["alt", "name"].iter() {
5423 if self._additional_params.contains_key(field) {
5424 dlg.finished(false);
5425 return Err(common::Error::FieldClash(field));
5426 }
5427 }
5428
5429 let mut params = Params::with_capacity(3 + self._additional_params.len());
5430 params.push("name", self._name);
5431
5432 params.extend(self._additional_params.iter());
5433
5434 params.push("alt", "json");
5435 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5436 if self._scopes.is_empty() {
5437 self._scopes.insert(Scope::Full.as_ref().to_string());
5438 }
5439
5440 #[allow(clippy::single_element_loop)]
5441 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5442 url = params.uri_replacement(url, param_name, find_this, true);
5443 }
5444 {
5445 let to_remove = ["name"];
5446 params.remove_params(&to_remove);
5447 }
5448
5449 let url = params.parse_with_url(&url);
5450
5451 loop {
5452 let token = match self
5453 .hub
5454 .auth
5455 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5456 .await
5457 {
5458 Ok(token) => token,
5459 Err(e) => match dlg.token(e) {
5460 Ok(token) => token,
5461 Err(e) => {
5462 dlg.finished(false);
5463 return Err(common::Error::MissingToken(e));
5464 }
5465 },
5466 };
5467 let mut req_result = {
5468 let client = &self.hub.client;
5469 dlg.pre_request();
5470 let mut req_builder = hyper::Request::builder()
5471 .method(hyper::Method::GET)
5472 .uri(url.as_str())
5473 .header(USER_AGENT, self.hub._user_agent.clone());
5474
5475 if let Some(token) = token.as_ref() {
5476 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5477 }
5478
5479 let request = req_builder
5480 .header(CONTENT_LENGTH, 0_u64)
5481 .body(common::to_body::<String>(None));
5482
5483 client.request(request.unwrap()).await
5484 };
5485
5486 match req_result {
5487 Err(err) => {
5488 if let common::Retry::After(d) = dlg.http_error(&err) {
5489 sleep(d).await;
5490 continue;
5491 }
5492 dlg.finished(false);
5493 return Err(common::Error::HttpError(err));
5494 }
5495 Ok(res) => {
5496 let (mut parts, body) = res.into_parts();
5497 let mut body = common::Body::new(body);
5498 if !parts.status.is_success() {
5499 let bytes = common::to_bytes(body).await.unwrap_or_default();
5500 let error = serde_json::from_str(&common::to_string(&bytes));
5501 let response = common::to_response(parts, bytes.into());
5502
5503 if let common::Retry::After(d) =
5504 dlg.http_failure(&response, error.as_ref().ok())
5505 {
5506 sleep(d).await;
5507 continue;
5508 }
5509
5510 dlg.finished(false);
5511
5512 return Err(match error {
5513 Ok(value) => common::Error::BadRequest(value),
5514 _ => common::Error::Failure(response),
5515 });
5516 }
5517 let response = {
5518 let bytes = common::to_bytes(body).await.unwrap_or_default();
5519 let encoded = common::to_string(&bytes);
5520 match serde_json::from_str(&encoded) {
5521 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5522 Err(error) => {
5523 dlg.response_json_decode_error(&encoded, &error);
5524 return Err(common::Error::JsonDecodeError(
5525 encoded.to_string(),
5526 error,
5527 ));
5528 }
5529 }
5530 };
5531
5532 dlg.finished(true);
5533 return Ok(response);
5534 }
5535 }
5536 }
5537 }
5538
5539 /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
5540 ///
5541 /// Sets the *name* path property to the given value.
5542 ///
5543 /// Even though the property as already been set when instantiating this call,
5544 /// we provide this method for API completeness.
5545 pub fn name(mut self, new_value: &str) -> EnterpriseDeviceGetCall<'a, C> {
5546 self._name = new_value.to_string();
5547 self
5548 }
5549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5550 /// while executing the actual API request.
5551 ///
5552 /// ````text
5553 /// It should be used to handle progress information, and to implement a certain level of resilience.
5554 /// ````
5555 ///
5556 /// Sets the *delegate* property to the given value.
5557 pub fn delegate(
5558 mut self,
5559 new_value: &'a mut dyn common::Delegate,
5560 ) -> EnterpriseDeviceGetCall<'a, C> {
5561 self._delegate = Some(new_value);
5562 self
5563 }
5564
5565 /// Set any additional parameter of the query string used in the request.
5566 /// It should be used to set parameters which are not yet available through their own
5567 /// setters.
5568 ///
5569 /// Please note that this method must not be used to set any of the known parameters
5570 /// which have their own setter method. If done anyway, the request will fail.
5571 ///
5572 /// # Additional Parameters
5573 ///
5574 /// * *$.xgafv* (query-string) - V1 error format.
5575 /// * *access_token* (query-string) - OAuth access token.
5576 /// * *alt* (query-string) - Data format for response.
5577 /// * *callback* (query-string) - JSONP
5578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5579 /// * *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.
5580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5582 /// * *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.
5583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5585 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceGetCall<'a, C>
5586 where
5587 T: AsRef<str>,
5588 {
5589 self._additional_params
5590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5591 self
5592 }
5593
5594 /// Identifies the authorization scope for the method you are building.
5595 ///
5596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5597 /// [`Scope::Full`].
5598 ///
5599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5600 /// tokens for more than one scope.
5601 ///
5602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5604 /// sufficient, a read-write scope will do as well.
5605 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceGetCall<'a, C>
5606 where
5607 St: AsRef<str>,
5608 {
5609 self._scopes.insert(String::from(scope.as_ref()));
5610 self
5611 }
5612 /// Identifies the authorization scope(s) for the method you are building.
5613 ///
5614 /// See [`Self::add_scope()`] for details.
5615 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceGetCall<'a, C>
5616 where
5617 I: IntoIterator<Item = St>,
5618 St: AsRef<str>,
5619 {
5620 self._scopes
5621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5622 self
5623 }
5624
5625 /// Removes all scopes, and no default scope will be used either.
5626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5627 /// for details).
5628 pub fn clear_scopes(mut self) -> EnterpriseDeviceGetCall<'a, C> {
5629 self._scopes.clear();
5630 self
5631 }
5632}
5633
5634/// Issues a command to a device. The Operation resource returned contains a Command in its metadata field. Use the get operation method to get the status of the command.
5635///
5636/// A builder for the *devices.issueCommand* method supported by a *enterprise* resource.
5637/// It is not used directly, but through a [`EnterpriseMethods`] instance.
5638///
5639/// # Example
5640///
5641/// Instantiate a resource method builder
5642///
5643/// ```test_harness,no_run
5644/// # extern crate hyper;
5645/// # extern crate hyper_rustls;
5646/// # extern crate google_androidmanagement1 as androidmanagement1;
5647/// use androidmanagement1::api::Command;
5648/// # async fn dox() {
5649/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5650///
5651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5652/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5653/// # secret,
5654/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5655/// # ).build().await.unwrap();
5656///
5657/// # let client = hyper_util::client::legacy::Client::builder(
5658/// # hyper_util::rt::TokioExecutor::new()
5659/// # )
5660/// # .build(
5661/// # hyper_rustls::HttpsConnectorBuilder::new()
5662/// # .with_native_roots()
5663/// # .unwrap()
5664/// # .https_or_http()
5665/// # .enable_http1()
5666/// # .build()
5667/// # );
5668/// # let mut hub = AndroidManagement::new(client, auth);
5669/// // As the method needs a request, you would usually fill it with the desired information
5670/// // into the respective structure. Some of the parts shown here might not be applicable !
5671/// // Values shown here are possibly random and not representative !
5672/// let mut req = Command::default();
5673///
5674/// // You can configure optional parameters by calling the respective setters at will, and
5675/// // execute the final call using `doit()`.
5676/// // Values shown here are possibly random and not representative !
5677/// let result = hub.enterprises().devices_issue_command(req, "name")
5678/// .doit().await;
5679/// # }
5680/// ```
5681pub struct EnterpriseDeviceIssueCommandCall<'a, C>
5682where
5683 C: 'a,
5684{
5685 hub: &'a AndroidManagement<C>,
5686 _request: Command,
5687 _name: String,
5688 _delegate: Option<&'a mut dyn common::Delegate>,
5689 _additional_params: HashMap<String, String>,
5690 _scopes: BTreeSet<String>,
5691}
5692
5693impl<'a, C> common::CallBuilder for EnterpriseDeviceIssueCommandCall<'a, C> {}
5694
5695impl<'a, C> EnterpriseDeviceIssueCommandCall<'a, C>
5696where
5697 C: common::Connector,
5698{
5699 /// Perform the operation you have build so far.
5700 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5701 use std::borrow::Cow;
5702 use std::io::{Read, Seek};
5703
5704 use common::{url::Params, ToParts};
5705 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5706
5707 let mut dd = common::DefaultDelegate;
5708 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5709 dlg.begin(common::MethodInfo {
5710 id: "androidmanagement.enterprises.devices.issueCommand",
5711 http_method: hyper::Method::POST,
5712 });
5713
5714 for &field in ["alt", "name"].iter() {
5715 if self._additional_params.contains_key(field) {
5716 dlg.finished(false);
5717 return Err(common::Error::FieldClash(field));
5718 }
5719 }
5720
5721 let mut params = Params::with_capacity(4 + self._additional_params.len());
5722 params.push("name", self._name);
5723
5724 params.extend(self._additional_params.iter());
5725
5726 params.push("alt", "json");
5727 let mut url = self.hub._base_url.clone() + "v1/{+name}:issueCommand";
5728 if self._scopes.is_empty() {
5729 self._scopes.insert(Scope::Full.as_ref().to_string());
5730 }
5731
5732 #[allow(clippy::single_element_loop)]
5733 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5734 url = params.uri_replacement(url, param_name, find_this, true);
5735 }
5736 {
5737 let to_remove = ["name"];
5738 params.remove_params(&to_remove);
5739 }
5740
5741 let url = params.parse_with_url(&url);
5742
5743 let mut json_mime_type = mime::APPLICATION_JSON;
5744 let mut request_value_reader = {
5745 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5746 common::remove_json_null_values(&mut value);
5747 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5748 serde_json::to_writer(&mut dst, &value).unwrap();
5749 dst
5750 };
5751 let request_size = request_value_reader
5752 .seek(std::io::SeekFrom::End(0))
5753 .unwrap();
5754 request_value_reader
5755 .seek(std::io::SeekFrom::Start(0))
5756 .unwrap();
5757
5758 loop {
5759 let token = match self
5760 .hub
5761 .auth
5762 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5763 .await
5764 {
5765 Ok(token) => token,
5766 Err(e) => match dlg.token(e) {
5767 Ok(token) => token,
5768 Err(e) => {
5769 dlg.finished(false);
5770 return Err(common::Error::MissingToken(e));
5771 }
5772 },
5773 };
5774 request_value_reader
5775 .seek(std::io::SeekFrom::Start(0))
5776 .unwrap();
5777 let mut req_result = {
5778 let client = &self.hub.client;
5779 dlg.pre_request();
5780 let mut req_builder = hyper::Request::builder()
5781 .method(hyper::Method::POST)
5782 .uri(url.as_str())
5783 .header(USER_AGENT, self.hub._user_agent.clone());
5784
5785 if let Some(token) = token.as_ref() {
5786 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5787 }
5788
5789 let request = req_builder
5790 .header(CONTENT_TYPE, json_mime_type.to_string())
5791 .header(CONTENT_LENGTH, request_size as u64)
5792 .body(common::to_body(
5793 request_value_reader.get_ref().clone().into(),
5794 ));
5795
5796 client.request(request.unwrap()).await
5797 };
5798
5799 match req_result {
5800 Err(err) => {
5801 if let common::Retry::After(d) = dlg.http_error(&err) {
5802 sleep(d).await;
5803 continue;
5804 }
5805 dlg.finished(false);
5806 return Err(common::Error::HttpError(err));
5807 }
5808 Ok(res) => {
5809 let (mut parts, body) = res.into_parts();
5810 let mut body = common::Body::new(body);
5811 if !parts.status.is_success() {
5812 let bytes = common::to_bytes(body).await.unwrap_or_default();
5813 let error = serde_json::from_str(&common::to_string(&bytes));
5814 let response = common::to_response(parts, bytes.into());
5815
5816 if let common::Retry::After(d) =
5817 dlg.http_failure(&response, error.as_ref().ok())
5818 {
5819 sleep(d).await;
5820 continue;
5821 }
5822
5823 dlg.finished(false);
5824
5825 return Err(match error {
5826 Ok(value) => common::Error::BadRequest(value),
5827 _ => common::Error::Failure(response),
5828 });
5829 }
5830 let response = {
5831 let bytes = common::to_bytes(body).await.unwrap_or_default();
5832 let encoded = common::to_string(&bytes);
5833 match serde_json::from_str(&encoded) {
5834 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5835 Err(error) => {
5836 dlg.response_json_decode_error(&encoded, &error);
5837 return Err(common::Error::JsonDecodeError(
5838 encoded.to_string(),
5839 error,
5840 ));
5841 }
5842 }
5843 };
5844
5845 dlg.finished(true);
5846 return Ok(response);
5847 }
5848 }
5849 }
5850 }
5851
5852 ///
5853 /// Sets the *request* property to the given value.
5854 ///
5855 /// Even though the property as already been set when instantiating this call,
5856 /// we provide this method for API completeness.
5857 pub fn request(mut self, new_value: Command) -> EnterpriseDeviceIssueCommandCall<'a, C> {
5858 self._request = new_value;
5859 self
5860 }
5861 /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
5862 ///
5863 /// Sets the *name* path property to the given value.
5864 ///
5865 /// Even though the property as already been set when instantiating this call,
5866 /// we provide this method for API completeness.
5867 pub fn name(mut self, new_value: &str) -> EnterpriseDeviceIssueCommandCall<'a, C> {
5868 self._name = new_value.to_string();
5869 self
5870 }
5871 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5872 /// while executing the actual API request.
5873 ///
5874 /// ````text
5875 /// It should be used to handle progress information, and to implement a certain level of resilience.
5876 /// ````
5877 ///
5878 /// Sets the *delegate* property to the given value.
5879 pub fn delegate(
5880 mut self,
5881 new_value: &'a mut dyn common::Delegate,
5882 ) -> EnterpriseDeviceIssueCommandCall<'a, C> {
5883 self._delegate = Some(new_value);
5884 self
5885 }
5886
5887 /// Set any additional parameter of the query string used in the request.
5888 /// It should be used to set parameters which are not yet available through their own
5889 /// setters.
5890 ///
5891 /// Please note that this method must not be used to set any of the known parameters
5892 /// which have their own setter method. If done anyway, the request will fail.
5893 ///
5894 /// # Additional Parameters
5895 ///
5896 /// * *$.xgafv* (query-string) - V1 error format.
5897 /// * *access_token* (query-string) - OAuth access token.
5898 /// * *alt* (query-string) - Data format for response.
5899 /// * *callback* (query-string) - JSONP
5900 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5901 /// * *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.
5902 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5903 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5904 /// * *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.
5905 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5906 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5907 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceIssueCommandCall<'a, C>
5908 where
5909 T: AsRef<str>,
5910 {
5911 self._additional_params
5912 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5913 self
5914 }
5915
5916 /// Identifies the authorization scope for the method you are building.
5917 ///
5918 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5919 /// [`Scope::Full`].
5920 ///
5921 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5922 /// tokens for more than one scope.
5923 ///
5924 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5925 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5926 /// sufficient, a read-write scope will do as well.
5927 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceIssueCommandCall<'a, C>
5928 where
5929 St: AsRef<str>,
5930 {
5931 self._scopes.insert(String::from(scope.as_ref()));
5932 self
5933 }
5934 /// Identifies the authorization scope(s) for the method you are building.
5935 ///
5936 /// See [`Self::add_scope()`] for details.
5937 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceIssueCommandCall<'a, C>
5938 where
5939 I: IntoIterator<Item = St>,
5940 St: AsRef<str>,
5941 {
5942 self._scopes
5943 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5944 self
5945 }
5946
5947 /// Removes all scopes, and no default scope will be used either.
5948 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5949 /// for details).
5950 pub fn clear_scopes(mut self) -> EnterpriseDeviceIssueCommandCall<'a, C> {
5951 self._scopes.clear();
5952 self
5953 }
5954}
5955
5956/// Lists devices for a given enterprise. Deleted devices are not returned in the response.
5957///
5958/// A builder for the *devices.list* method supported by a *enterprise* resource.
5959/// It is not used directly, but through a [`EnterpriseMethods`] instance.
5960///
5961/// # Example
5962///
5963/// Instantiate a resource method builder
5964///
5965/// ```test_harness,no_run
5966/// # extern crate hyper;
5967/// # extern crate hyper_rustls;
5968/// # extern crate google_androidmanagement1 as androidmanagement1;
5969/// # async fn dox() {
5970/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5971///
5972/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5973/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5974/// # secret,
5975/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5976/// # ).build().await.unwrap();
5977///
5978/// # let client = hyper_util::client::legacy::Client::builder(
5979/// # hyper_util::rt::TokioExecutor::new()
5980/// # )
5981/// # .build(
5982/// # hyper_rustls::HttpsConnectorBuilder::new()
5983/// # .with_native_roots()
5984/// # .unwrap()
5985/// # .https_or_http()
5986/// # .enable_http1()
5987/// # .build()
5988/// # );
5989/// # let mut hub = AndroidManagement::new(client, auth);
5990/// // You can configure optional parameters by calling the respective setters at will, and
5991/// // execute the final call using `doit()`.
5992/// // Values shown here are possibly random and not representative !
5993/// let result = hub.enterprises().devices_list("parent")
5994/// .page_token("rebum.")
5995/// .page_size(-57)
5996/// .doit().await;
5997/// # }
5998/// ```
5999pub struct EnterpriseDeviceListCall<'a, C>
6000where
6001 C: 'a,
6002{
6003 hub: &'a AndroidManagement<C>,
6004 _parent: String,
6005 _page_token: Option<String>,
6006 _page_size: Option<i32>,
6007 _delegate: Option<&'a mut dyn common::Delegate>,
6008 _additional_params: HashMap<String, String>,
6009 _scopes: BTreeSet<String>,
6010}
6011
6012impl<'a, C> common::CallBuilder for EnterpriseDeviceListCall<'a, C> {}
6013
6014impl<'a, C> EnterpriseDeviceListCall<'a, C>
6015where
6016 C: common::Connector,
6017{
6018 /// Perform the operation you have build so far.
6019 pub async fn doit(mut self) -> common::Result<(common::Response, ListDevicesResponse)> {
6020 use std::borrow::Cow;
6021 use std::io::{Read, Seek};
6022
6023 use common::{url::Params, ToParts};
6024 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6025
6026 let mut dd = common::DefaultDelegate;
6027 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6028 dlg.begin(common::MethodInfo {
6029 id: "androidmanagement.enterprises.devices.list",
6030 http_method: hyper::Method::GET,
6031 });
6032
6033 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6034 if self._additional_params.contains_key(field) {
6035 dlg.finished(false);
6036 return Err(common::Error::FieldClash(field));
6037 }
6038 }
6039
6040 let mut params = Params::with_capacity(5 + self._additional_params.len());
6041 params.push("parent", self._parent);
6042 if let Some(value) = self._page_token.as_ref() {
6043 params.push("pageToken", value);
6044 }
6045 if let Some(value) = self._page_size.as_ref() {
6046 params.push("pageSize", value.to_string());
6047 }
6048
6049 params.extend(self._additional_params.iter());
6050
6051 params.push("alt", "json");
6052 let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices";
6053 if self._scopes.is_empty() {
6054 self._scopes.insert(Scope::Full.as_ref().to_string());
6055 }
6056
6057 #[allow(clippy::single_element_loop)]
6058 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6059 url = params.uri_replacement(url, param_name, find_this, true);
6060 }
6061 {
6062 let to_remove = ["parent"];
6063 params.remove_params(&to_remove);
6064 }
6065
6066 let url = params.parse_with_url(&url);
6067
6068 loop {
6069 let token = match self
6070 .hub
6071 .auth
6072 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6073 .await
6074 {
6075 Ok(token) => token,
6076 Err(e) => match dlg.token(e) {
6077 Ok(token) => token,
6078 Err(e) => {
6079 dlg.finished(false);
6080 return Err(common::Error::MissingToken(e));
6081 }
6082 },
6083 };
6084 let mut req_result = {
6085 let client = &self.hub.client;
6086 dlg.pre_request();
6087 let mut req_builder = hyper::Request::builder()
6088 .method(hyper::Method::GET)
6089 .uri(url.as_str())
6090 .header(USER_AGENT, self.hub._user_agent.clone());
6091
6092 if let Some(token) = token.as_ref() {
6093 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6094 }
6095
6096 let request = req_builder
6097 .header(CONTENT_LENGTH, 0_u64)
6098 .body(common::to_body::<String>(None));
6099
6100 client.request(request.unwrap()).await
6101 };
6102
6103 match req_result {
6104 Err(err) => {
6105 if let common::Retry::After(d) = dlg.http_error(&err) {
6106 sleep(d).await;
6107 continue;
6108 }
6109 dlg.finished(false);
6110 return Err(common::Error::HttpError(err));
6111 }
6112 Ok(res) => {
6113 let (mut parts, body) = res.into_parts();
6114 let mut body = common::Body::new(body);
6115 if !parts.status.is_success() {
6116 let bytes = common::to_bytes(body).await.unwrap_or_default();
6117 let error = serde_json::from_str(&common::to_string(&bytes));
6118 let response = common::to_response(parts, bytes.into());
6119
6120 if let common::Retry::After(d) =
6121 dlg.http_failure(&response, error.as_ref().ok())
6122 {
6123 sleep(d).await;
6124 continue;
6125 }
6126
6127 dlg.finished(false);
6128
6129 return Err(match error {
6130 Ok(value) => common::Error::BadRequest(value),
6131 _ => common::Error::Failure(response),
6132 });
6133 }
6134 let response = {
6135 let bytes = common::to_bytes(body).await.unwrap_or_default();
6136 let encoded = common::to_string(&bytes);
6137 match serde_json::from_str(&encoded) {
6138 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6139 Err(error) => {
6140 dlg.response_json_decode_error(&encoded, &error);
6141 return Err(common::Error::JsonDecodeError(
6142 encoded.to_string(),
6143 error,
6144 ));
6145 }
6146 }
6147 };
6148
6149 dlg.finished(true);
6150 return Ok(response);
6151 }
6152 }
6153 }
6154 }
6155
6156 /// The name of the enterprise in the form enterprises/{enterpriseId}.
6157 ///
6158 /// Sets the *parent* path property to the given value.
6159 ///
6160 /// Even though the property as already been set when instantiating this call,
6161 /// we provide this method for API completeness.
6162 pub fn parent(mut self, new_value: &str) -> EnterpriseDeviceListCall<'a, C> {
6163 self._parent = new_value.to_string();
6164 self
6165 }
6166 /// A token identifying a page of results returned by the server.
6167 ///
6168 /// Sets the *page token* query property to the given value.
6169 pub fn page_token(mut self, new_value: &str) -> EnterpriseDeviceListCall<'a, C> {
6170 self._page_token = Some(new_value.to_string());
6171 self
6172 }
6173 /// The requested page size. The actual page size may be fixed to a min or max value.
6174 ///
6175 /// Sets the *page size* query property to the given value.
6176 pub fn page_size(mut self, new_value: i32) -> EnterpriseDeviceListCall<'a, C> {
6177 self._page_size = Some(new_value);
6178 self
6179 }
6180 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6181 /// while executing the actual API request.
6182 ///
6183 /// ````text
6184 /// It should be used to handle progress information, and to implement a certain level of resilience.
6185 /// ````
6186 ///
6187 /// Sets the *delegate* property to the given value.
6188 pub fn delegate(
6189 mut self,
6190 new_value: &'a mut dyn common::Delegate,
6191 ) -> EnterpriseDeviceListCall<'a, C> {
6192 self._delegate = Some(new_value);
6193 self
6194 }
6195
6196 /// Set any additional parameter of the query string used in the request.
6197 /// It should be used to set parameters which are not yet available through their own
6198 /// setters.
6199 ///
6200 /// Please note that this method must not be used to set any of the known parameters
6201 /// which have their own setter method. If done anyway, the request will fail.
6202 ///
6203 /// # Additional Parameters
6204 ///
6205 /// * *$.xgafv* (query-string) - V1 error format.
6206 /// * *access_token* (query-string) - OAuth access token.
6207 /// * *alt* (query-string) - Data format for response.
6208 /// * *callback* (query-string) - JSONP
6209 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6210 /// * *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.
6211 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6212 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6213 /// * *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.
6214 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6215 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6216 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeviceListCall<'a, C>
6217 where
6218 T: AsRef<str>,
6219 {
6220 self._additional_params
6221 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6222 self
6223 }
6224
6225 /// Identifies the authorization scope for the method you are building.
6226 ///
6227 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6228 /// [`Scope::Full`].
6229 ///
6230 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6231 /// tokens for more than one scope.
6232 ///
6233 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6234 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6235 /// sufficient, a read-write scope will do as well.
6236 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeviceListCall<'a, C>
6237 where
6238 St: AsRef<str>,
6239 {
6240 self._scopes.insert(String::from(scope.as_ref()));
6241 self
6242 }
6243 /// Identifies the authorization scope(s) for the method you are building.
6244 ///
6245 /// See [`Self::add_scope()`] for details.
6246 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeviceListCall<'a, C>
6247 where
6248 I: IntoIterator<Item = St>,
6249 St: AsRef<str>,
6250 {
6251 self._scopes
6252 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6253 self
6254 }
6255
6256 /// Removes all scopes, and no default scope will be used either.
6257 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6258 /// for details).
6259 pub fn clear_scopes(mut self) -> EnterpriseDeviceListCall<'a, C> {
6260 self._scopes.clear();
6261 self
6262 }
6263}
6264
6265/// Updates a device.
6266///
6267/// A builder for the *devices.patch* method supported by a *enterprise* resource.
6268/// It is not used directly, but through a [`EnterpriseMethods`] instance.
6269///
6270/// # Example
6271///
6272/// Instantiate a resource method builder
6273///
6274/// ```test_harness,no_run
6275/// # extern crate hyper;
6276/// # extern crate hyper_rustls;
6277/// # extern crate google_androidmanagement1 as androidmanagement1;
6278/// use androidmanagement1::api::Device;
6279/// # async fn dox() {
6280/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6281///
6282/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6283/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6284/// # secret,
6285/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6286/// # ).build().await.unwrap();
6287///
6288/// # let client = hyper_util::client::legacy::Client::builder(
6289/// # hyper_util::rt::TokioExecutor::new()
6290/// # )
6291/// # .build(
6292/// # hyper_rustls::HttpsConnectorBuilder::new()
6293/// # .with_native_roots()
6294/// # .unwrap()
6295/// # .https_or_http()
6296/// # .enable_http1()
6297/// # .build()
6298/// # );
6299/// # let mut hub = AndroidManagement::new(client, auth);
6300/// // As the method needs a request, you would usually fill it with the desired information
6301/// // into the respective structure. Some of the parts shown here might not be applicable !
6302/// // Values shown here are possibly random and not representative !
6303/// let mut req = Device::default();
6304///
6305/// // You can configure optional parameters by calling the respective setters at will, and
6306/// // execute the final call using `doit()`.
6307/// // Values shown here are possibly random and not representative !
6308/// let result = hub.enterprises().devices_patch(req, "name")
6309/// .update_mask(FieldMask::new::<&str>(&[]))
6310/// .doit().await;
6311/// # }
6312/// ```
6313pub struct EnterpriseDevicePatchCall<'a, C>
6314where
6315 C: 'a,
6316{
6317 hub: &'a AndroidManagement<C>,
6318 _request: Device,
6319 _name: String,
6320 _update_mask: Option<common::FieldMask>,
6321 _delegate: Option<&'a mut dyn common::Delegate>,
6322 _additional_params: HashMap<String, String>,
6323 _scopes: BTreeSet<String>,
6324}
6325
6326impl<'a, C> common::CallBuilder for EnterpriseDevicePatchCall<'a, C> {}
6327
6328impl<'a, C> EnterpriseDevicePatchCall<'a, C>
6329where
6330 C: common::Connector,
6331{
6332 /// Perform the operation you have build so far.
6333 pub async fn doit(mut self) -> common::Result<(common::Response, Device)> {
6334 use std::borrow::Cow;
6335 use std::io::{Read, Seek};
6336
6337 use common::{url::Params, ToParts};
6338 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6339
6340 let mut dd = common::DefaultDelegate;
6341 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6342 dlg.begin(common::MethodInfo {
6343 id: "androidmanagement.enterprises.devices.patch",
6344 http_method: hyper::Method::PATCH,
6345 });
6346
6347 for &field in ["alt", "name", "updateMask"].iter() {
6348 if self._additional_params.contains_key(field) {
6349 dlg.finished(false);
6350 return Err(common::Error::FieldClash(field));
6351 }
6352 }
6353
6354 let mut params = Params::with_capacity(5 + self._additional_params.len());
6355 params.push("name", self._name);
6356 if let Some(value) = self._update_mask.as_ref() {
6357 params.push("updateMask", value.to_string());
6358 }
6359
6360 params.extend(self._additional_params.iter());
6361
6362 params.push("alt", "json");
6363 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6364 if self._scopes.is_empty() {
6365 self._scopes.insert(Scope::Full.as_ref().to_string());
6366 }
6367
6368 #[allow(clippy::single_element_loop)]
6369 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6370 url = params.uri_replacement(url, param_name, find_this, true);
6371 }
6372 {
6373 let to_remove = ["name"];
6374 params.remove_params(&to_remove);
6375 }
6376
6377 let url = params.parse_with_url(&url);
6378
6379 let mut json_mime_type = mime::APPLICATION_JSON;
6380 let mut request_value_reader = {
6381 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6382 common::remove_json_null_values(&mut value);
6383 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6384 serde_json::to_writer(&mut dst, &value).unwrap();
6385 dst
6386 };
6387 let request_size = request_value_reader
6388 .seek(std::io::SeekFrom::End(0))
6389 .unwrap();
6390 request_value_reader
6391 .seek(std::io::SeekFrom::Start(0))
6392 .unwrap();
6393
6394 loop {
6395 let token = match self
6396 .hub
6397 .auth
6398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6399 .await
6400 {
6401 Ok(token) => token,
6402 Err(e) => match dlg.token(e) {
6403 Ok(token) => token,
6404 Err(e) => {
6405 dlg.finished(false);
6406 return Err(common::Error::MissingToken(e));
6407 }
6408 },
6409 };
6410 request_value_reader
6411 .seek(std::io::SeekFrom::Start(0))
6412 .unwrap();
6413 let mut req_result = {
6414 let client = &self.hub.client;
6415 dlg.pre_request();
6416 let mut req_builder = hyper::Request::builder()
6417 .method(hyper::Method::PATCH)
6418 .uri(url.as_str())
6419 .header(USER_AGENT, self.hub._user_agent.clone());
6420
6421 if let Some(token) = token.as_ref() {
6422 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6423 }
6424
6425 let request = req_builder
6426 .header(CONTENT_TYPE, json_mime_type.to_string())
6427 .header(CONTENT_LENGTH, request_size as u64)
6428 .body(common::to_body(
6429 request_value_reader.get_ref().clone().into(),
6430 ));
6431
6432 client.request(request.unwrap()).await
6433 };
6434
6435 match req_result {
6436 Err(err) => {
6437 if let common::Retry::After(d) = dlg.http_error(&err) {
6438 sleep(d).await;
6439 continue;
6440 }
6441 dlg.finished(false);
6442 return Err(common::Error::HttpError(err));
6443 }
6444 Ok(res) => {
6445 let (mut parts, body) = res.into_parts();
6446 let mut body = common::Body::new(body);
6447 if !parts.status.is_success() {
6448 let bytes = common::to_bytes(body).await.unwrap_or_default();
6449 let error = serde_json::from_str(&common::to_string(&bytes));
6450 let response = common::to_response(parts, bytes.into());
6451
6452 if let common::Retry::After(d) =
6453 dlg.http_failure(&response, error.as_ref().ok())
6454 {
6455 sleep(d).await;
6456 continue;
6457 }
6458
6459 dlg.finished(false);
6460
6461 return Err(match error {
6462 Ok(value) => common::Error::BadRequest(value),
6463 _ => common::Error::Failure(response),
6464 });
6465 }
6466 let response = {
6467 let bytes = common::to_bytes(body).await.unwrap_or_default();
6468 let encoded = common::to_string(&bytes);
6469 match serde_json::from_str(&encoded) {
6470 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6471 Err(error) => {
6472 dlg.response_json_decode_error(&encoded, &error);
6473 return Err(common::Error::JsonDecodeError(
6474 encoded.to_string(),
6475 error,
6476 ));
6477 }
6478 }
6479 };
6480
6481 dlg.finished(true);
6482 return Ok(response);
6483 }
6484 }
6485 }
6486 }
6487
6488 ///
6489 /// Sets the *request* property to the given value.
6490 ///
6491 /// Even though the property as already been set when instantiating this call,
6492 /// we provide this method for API completeness.
6493 pub fn request(mut self, new_value: Device) -> EnterpriseDevicePatchCall<'a, C> {
6494 self._request = new_value;
6495 self
6496 }
6497 /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}.
6498 ///
6499 /// Sets the *name* path property to the given value.
6500 ///
6501 /// Even though the property as already been set when instantiating this call,
6502 /// we provide this method for API completeness.
6503 pub fn name(mut self, new_value: &str) -> EnterpriseDevicePatchCall<'a, C> {
6504 self._name = new_value.to_string();
6505 self
6506 }
6507 /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified.
6508 ///
6509 /// Sets the *update mask* query property to the given value.
6510 pub fn update_mask(mut self, new_value: common::FieldMask) -> EnterpriseDevicePatchCall<'a, C> {
6511 self._update_mask = Some(new_value);
6512 self
6513 }
6514 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6515 /// while executing the actual API request.
6516 ///
6517 /// ````text
6518 /// It should be used to handle progress information, and to implement a certain level of resilience.
6519 /// ````
6520 ///
6521 /// Sets the *delegate* property to the given value.
6522 pub fn delegate(
6523 mut self,
6524 new_value: &'a mut dyn common::Delegate,
6525 ) -> EnterpriseDevicePatchCall<'a, C> {
6526 self._delegate = Some(new_value);
6527 self
6528 }
6529
6530 /// Set any additional parameter of the query string used in the request.
6531 /// It should be used to set parameters which are not yet available through their own
6532 /// setters.
6533 ///
6534 /// Please note that this method must not be used to set any of the known parameters
6535 /// which have their own setter method. If done anyway, the request will fail.
6536 ///
6537 /// # Additional Parameters
6538 ///
6539 /// * *$.xgafv* (query-string) - V1 error format.
6540 /// * *access_token* (query-string) - OAuth access token.
6541 /// * *alt* (query-string) - Data format for response.
6542 /// * *callback* (query-string) - JSONP
6543 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6544 /// * *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.
6545 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6546 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6547 /// * *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.
6548 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6549 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6550 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDevicePatchCall<'a, C>
6551 where
6552 T: AsRef<str>,
6553 {
6554 self._additional_params
6555 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6556 self
6557 }
6558
6559 /// Identifies the authorization scope for the method you are building.
6560 ///
6561 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6562 /// [`Scope::Full`].
6563 ///
6564 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6565 /// tokens for more than one scope.
6566 ///
6567 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6568 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6569 /// sufficient, a read-write scope will do as well.
6570 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDevicePatchCall<'a, C>
6571 where
6572 St: AsRef<str>,
6573 {
6574 self._scopes.insert(String::from(scope.as_ref()));
6575 self
6576 }
6577 /// Identifies the authorization scope(s) for the method you are building.
6578 ///
6579 /// See [`Self::add_scope()`] for details.
6580 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDevicePatchCall<'a, C>
6581 where
6582 I: IntoIterator<Item = St>,
6583 St: AsRef<str>,
6584 {
6585 self._scopes
6586 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6587 self
6588 }
6589
6590 /// Removes all scopes, and no default scope will be used either.
6591 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6592 /// for details).
6593 pub fn clear_scopes(mut self) -> EnterpriseDevicePatchCall<'a, C> {
6594 self._scopes.clear();
6595 self
6596 }
6597}
6598
6599/// Creates an enrollment token for a given enterprise. It's up to the caller's responsibility to manage the lifecycle of newly created tokens and deleting them when they're not intended to be used anymore. Once an enrollment token has been created, it's not possible to retrieve the token's content anymore using AM API. It is recommended for EMMs to securely store the token if it's intended to be reused.
6600///
6601/// A builder for the *enrollmentTokens.create* method supported by a *enterprise* resource.
6602/// It is not used directly, but through a [`EnterpriseMethods`] instance.
6603///
6604/// # Example
6605///
6606/// Instantiate a resource method builder
6607///
6608/// ```test_harness,no_run
6609/// # extern crate hyper;
6610/// # extern crate hyper_rustls;
6611/// # extern crate google_androidmanagement1 as androidmanagement1;
6612/// use androidmanagement1::api::EnrollmentToken;
6613/// # async fn dox() {
6614/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6615///
6616/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6618/// # secret,
6619/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6620/// # ).build().await.unwrap();
6621///
6622/// # let client = hyper_util::client::legacy::Client::builder(
6623/// # hyper_util::rt::TokioExecutor::new()
6624/// # )
6625/// # .build(
6626/// # hyper_rustls::HttpsConnectorBuilder::new()
6627/// # .with_native_roots()
6628/// # .unwrap()
6629/// # .https_or_http()
6630/// # .enable_http1()
6631/// # .build()
6632/// # );
6633/// # let mut hub = AndroidManagement::new(client, auth);
6634/// // As the method needs a request, you would usually fill it with the desired information
6635/// // into the respective structure. Some of the parts shown here might not be applicable !
6636/// // Values shown here are possibly random and not representative !
6637/// let mut req = EnrollmentToken::default();
6638///
6639/// // You can configure optional parameters by calling the respective setters at will, and
6640/// // execute the final call using `doit()`.
6641/// // Values shown here are possibly random and not representative !
6642/// let result = hub.enterprises().enrollment_tokens_create(req, "parent")
6643/// .doit().await;
6644/// # }
6645/// ```
6646pub struct EnterpriseEnrollmentTokenCreateCall<'a, C>
6647where
6648 C: 'a,
6649{
6650 hub: &'a AndroidManagement<C>,
6651 _request: EnrollmentToken,
6652 _parent: String,
6653 _delegate: Option<&'a mut dyn common::Delegate>,
6654 _additional_params: HashMap<String, String>,
6655 _scopes: BTreeSet<String>,
6656}
6657
6658impl<'a, C> common::CallBuilder for EnterpriseEnrollmentTokenCreateCall<'a, C> {}
6659
6660impl<'a, C> EnterpriseEnrollmentTokenCreateCall<'a, C>
6661where
6662 C: common::Connector,
6663{
6664 /// Perform the operation you have build so far.
6665 pub async fn doit(mut self) -> common::Result<(common::Response, EnrollmentToken)> {
6666 use std::borrow::Cow;
6667 use std::io::{Read, Seek};
6668
6669 use common::{url::Params, ToParts};
6670 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6671
6672 let mut dd = common::DefaultDelegate;
6673 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6674 dlg.begin(common::MethodInfo {
6675 id: "androidmanagement.enterprises.enrollmentTokens.create",
6676 http_method: hyper::Method::POST,
6677 });
6678
6679 for &field in ["alt", "parent"].iter() {
6680 if self._additional_params.contains_key(field) {
6681 dlg.finished(false);
6682 return Err(common::Error::FieldClash(field));
6683 }
6684 }
6685
6686 let mut params = Params::with_capacity(4 + self._additional_params.len());
6687 params.push("parent", self._parent);
6688
6689 params.extend(self._additional_params.iter());
6690
6691 params.push("alt", "json");
6692 let mut url = self.hub._base_url.clone() + "v1/{+parent}/enrollmentTokens";
6693 if self._scopes.is_empty() {
6694 self._scopes.insert(Scope::Full.as_ref().to_string());
6695 }
6696
6697 #[allow(clippy::single_element_loop)]
6698 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6699 url = params.uri_replacement(url, param_name, find_this, true);
6700 }
6701 {
6702 let to_remove = ["parent"];
6703 params.remove_params(&to_remove);
6704 }
6705
6706 let url = params.parse_with_url(&url);
6707
6708 let mut json_mime_type = mime::APPLICATION_JSON;
6709 let mut request_value_reader = {
6710 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6711 common::remove_json_null_values(&mut value);
6712 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6713 serde_json::to_writer(&mut dst, &value).unwrap();
6714 dst
6715 };
6716 let request_size = request_value_reader
6717 .seek(std::io::SeekFrom::End(0))
6718 .unwrap();
6719 request_value_reader
6720 .seek(std::io::SeekFrom::Start(0))
6721 .unwrap();
6722
6723 loop {
6724 let token = match self
6725 .hub
6726 .auth
6727 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6728 .await
6729 {
6730 Ok(token) => token,
6731 Err(e) => match dlg.token(e) {
6732 Ok(token) => token,
6733 Err(e) => {
6734 dlg.finished(false);
6735 return Err(common::Error::MissingToken(e));
6736 }
6737 },
6738 };
6739 request_value_reader
6740 .seek(std::io::SeekFrom::Start(0))
6741 .unwrap();
6742 let mut req_result = {
6743 let client = &self.hub.client;
6744 dlg.pre_request();
6745 let mut req_builder = hyper::Request::builder()
6746 .method(hyper::Method::POST)
6747 .uri(url.as_str())
6748 .header(USER_AGENT, self.hub._user_agent.clone());
6749
6750 if let Some(token) = token.as_ref() {
6751 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6752 }
6753
6754 let request = req_builder
6755 .header(CONTENT_TYPE, json_mime_type.to_string())
6756 .header(CONTENT_LENGTH, request_size as u64)
6757 .body(common::to_body(
6758 request_value_reader.get_ref().clone().into(),
6759 ));
6760
6761 client.request(request.unwrap()).await
6762 };
6763
6764 match req_result {
6765 Err(err) => {
6766 if let common::Retry::After(d) = dlg.http_error(&err) {
6767 sleep(d).await;
6768 continue;
6769 }
6770 dlg.finished(false);
6771 return Err(common::Error::HttpError(err));
6772 }
6773 Ok(res) => {
6774 let (mut parts, body) = res.into_parts();
6775 let mut body = common::Body::new(body);
6776 if !parts.status.is_success() {
6777 let bytes = common::to_bytes(body).await.unwrap_or_default();
6778 let error = serde_json::from_str(&common::to_string(&bytes));
6779 let response = common::to_response(parts, bytes.into());
6780
6781 if let common::Retry::After(d) =
6782 dlg.http_failure(&response, error.as_ref().ok())
6783 {
6784 sleep(d).await;
6785 continue;
6786 }
6787
6788 dlg.finished(false);
6789
6790 return Err(match error {
6791 Ok(value) => common::Error::BadRequest(value),
6792 _ => common::Error::Failure(response),
6793 });
6794 }
6795 let response = {
6796 let bytes = common::to_bytes(body).await.unwrap_or_default();
6797 let encoded = common::to_string(&bytes);
6798 match serde_json::from_str(&encoded) {
6799 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6800 Err(error) => {
6801 dlg.response_json_decode_error(&encoded, &error);
6802 return Err(common::Error::JsonDecodeError(
6803 encoded.to_string(),
6804 error,
6805 ));
6806 }
6807 }
6808 };
6809
6810 dlg.finished(true);
6811 return Ok(response);
6812 }
6813 }
6814 }
6815 }
6816
6817 ///
6818 /// Sets the *request* property to the given value.
6819 ///
6820 /// Even though the property as already been set when instantiating this call,
6821 /// we provide this method for API completeness.
6822 pub fn request(
6823 mut self,
6824 new_value: EnrollmentToken,
6825 ) -> EnterpriseEnrollmentTokenCreateCall<'a, C> {
6826 self._request = new_value;
6827 self
6828 }
6829 /// The name of the enterprise in the form enterprises/{enterpriseId}.
6830 ///
6831 /// Sets the *parent* path property to the given value.
6832 ///
6833 /// Even though the property as already been set when instantiating this call,
6834 /// we provide this method for API completeness.
6835 pub fn parent(mut self, new_value: &str) -> EnterpriseEnrollmentTokenCreateCall<'a, C> {
6836 self._parent = new_value.to_string();
6837 self
6838 }
6839 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6840 /// while executing the actual API request.
6841 ///
6842 /// ````text
6843 /// It should be used to handle progress information, and to implement a certain level of resilience.
6844 /// ````
6845 ///
6846 /// Sets the *delegate* property to the given value.
6847 pub fn delegate(
6848 mut self,
6849 new_value: &'a mut dyn common::Delegate,
6850 ) -> EnterpriseEnrollmentTokenCreateCall<'a, C> {
6851 self._delegate = Some(new_value);
6852 self
6853 }
6854
6855 /// Set any additional parameter of the query string used in the request.
6856 /// It should be used to set parameters which are not yet available through their own
6857 /// setters.
6858 ///
6859 /// Please note that this method must not be used to set any of the known parameters
6860 /// which have their own setter method. If done anyway, the request will fail.
6861 ///
6862 /// # Additional Parameters
6863 ///
6864 /// * *$.xgafv* (query-string) - V1 error format.
6865 /// * *access_token* (query-string) - OAuth access token.
6866 /// * *alt* (query-string) - Data format for response.
6867 /// * *callback* (query-string) - JSONP
6868 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6869 /// * *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.
6870 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6871 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6872 /// * *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.
6873 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6874 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6875 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseEnrollmentTokenCreateCall<'a, C>
6876 where
6877 T: AsRef<str>,
6878 {
6879 self._additional_params
6880 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6881 self
6882 }
6883
6884 /// Identifies the authorization scope for the method you are building.
6885 ///
6886 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6887 /// [`Scope::Full`].
6888 ///
6889 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6890 /// tokens for more than one scope.
6891 ///
6892 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6893 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6894 /// sufficient, a read-write scope will do as well.
6895 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseEnrollmentTokenCreateCall<'a, C>
6896 where
6897 St: AsRef<str>,
6898 {
6899 self._scopes.insert(String::from(scope.as_ref()));
6900 self
6901 }
6902 /// Identifies the authorization scope(s) for the method you are building.
6903 ///
6904 /// See [`Self::add_scope()`] for details.
6905 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseEnrollmentTokenCreateCall<'a, C>
6906 where
6907 I: IntoIterator<Item = St>,
6908 St: AsRef<str>,
6909 {
6910 self._scopes
6911 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6912 self
6913 }
6914
6915 /// Removes all scopes, and no default scope will be used either.
6916 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6917 /// for details).
6918 pub fn clear_scopes(mut self) -> EnterpriseEnrollmentTokenCreateCall<'a, C> {
6919 self._scopes.clear();
6920 self
6921 }
6922}
6923
6924/// Deletes an enrollment token. This operation invalidates the token, preventing its future use.
6925///
6926/// A builder for the *enrollmentTokens.delete* method supported by a *enterprise* resource.
6927/// It is not used directly, but through a [`EnterpriseMethods`] instance.
6928///
6929/// # Example
6930///
6931/// Instantiate a resource method builder
6932///
6933/// ```test_harness,no_run
6934/// # extern crate hyper;
6935/// # extern crate hyper_rustls;
6936/// # extern crate google_androidmanagement1 as androidmanagement1;
6937/// # async fn dox() {
6938/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6939///
6940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6941/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6942/// # secret,
6943/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6944/// # ).build().await.unwrap();
6945///
6946/// # let client = hyper_util::client::legacy::Client::builder(
6947/// # hyper_util::rt::TokioExecutor::new()
6948/// # )
6949/// # .build(
6950/// # hyper_rustls::HttpsConnectorBuilder::new()
6951/// # .with_native_roots()
6952/// # .unwrap()
6953/// # .https_or_http()
6954/// # .enable_http1()
6955/// # .build()
6956/// # );
6957/// # let mut hub = AndroidManagement::new(client, auth);
6958/// // You can configure optional parameters by calling the respective setters at will, and
6959/// // execute the final call using `doit()`.
6960/// // Values shown here are possibly random and not representative !
6961/// let result = hub.enterprises().enrollment_tokens_delete("name")
6962/// .doit().await;
6963/// # }
6964/// ```
6965pub struct EnterpriseEnrollmentTokenDeleteCall<'a, C>
6966where
6967 C: 'a,
6968{
6969 hub: &'a AndroidManagement<C>,
6970 _name: String,
6971 _delegate: Option<&'a mut dyn common::Delegate>,
6972 _additional_params: HashMap<String, String>,
6973 _scopes: BTreeSet<String>,
6974}
6975
6976impl<'a, C> common::CallBuilder for EnterpriseEnrollmentTokenDeleteCall<'a, C> {}
6977
6978impl<'a, C> EnterpriseEnrollmentTokenDeleteCall<'a, C>
6979where
6980 C: common::Connector,
6981{
6982 /// Perform the operation you have build so far.
6983 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6984 use std::borrow::Cow;
6985 use std::io::{Read, Seek};
6986
6987 use common::{url::Params, ToParts};
6988 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6989
6990 let mut dd = common::DefaultDelegate;
6991 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6992 dlg.begin(common::MethodInfo {
6993 id: "androidmanagement.enterprises.enrollmentTokens.delete",
6994 http_method: hyper::Method::DELETE,
6995 });
6996
6997 for &field in ["alt", "name"].iter() {
6998 if self._additional_params.contains_key(field) {
6999 dlg.finished(false);
7000 return Err(common::Error::FieldClash(field));
7001 }
7002 }
7003
7004 let mut params = Params::with_capacity(3 + self._additional_params.len());
7005 params.push("name", self._name);
7006
7007 params.extend(self._additional_params.iter());
7008
7009 params.push("alt", "json");
7010 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7011 if self._scopes.is_empty() {
7012 self._scopes.insert(Scope::Full.as_ref().to_string());
7013 }
7014
7015 #[allow(clippy::single_element_loop)]
7016 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7017 url = params.uri_replacement(url, param_name, find_this, true);
7018 }
7019 {
7020 let to_remove = ["name"];
7021 params.remove_params(&to_remove);
7022 }
7023
7024 let url = params.parse_with_url(&url);
7025
7026 loop {
7027 let token = match self
7028 .hub
7029 .auth
7030 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7031 .await
7032 {
7033 Ok(token) => token,
7034 Err(e) => match dlg.token(e) {
7035 Ok(token) => token,
7036 Err(e) => {
7037 dlg.finished(false);
7038 return Err(common::Error::MissingToken(e));
7039 }
7040 },
7041 };
7042 let mut req_result = {
7043 let client = &self.hub.client;
7044 dlg.pre_request();
7045 let mut req_builder = hyper::Request::builder()
7046 .method(hyper::Method::DELETE)
7047 .uri(url.as_str())
7048 .header(USER_AGENT, self.hub._user_agent.clone());
7049
7050 if let Some(token) = token.as_ref() {
7051 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7052 }
7053
7054 let request = req_builder
7055 .header(CONTENT_LENGTH, 0_u64)
7056 .body(common::to_body::<String>(None));
7057
7058 client.request(request.unwrap()).await
7059 };
7060
7061 match req_result {
7062 Err(err) => {
7063 if let common::Retry::After(d) = dlg.http_error(&err) {
7064 sleep(d).await;
7065 continue;
7066 }
7067 dlg.finished(false);
7068 return Err(common::Error::HttpError(err));
7069 }
7070 Ok(res) => {
7071 let (mut parts, body) = res.into_parts();
7072 let mut body = common::Body::new(body);
7073 if !parts.status.is_success() {
7074 let bytes = common::to_bytes(body).await.unwrap_or_default();
7075 let error = serde_json::from_str(&common::to_string(&bytes));
7076 let response = common::to_response(parts, bytes.into());
7077
7078 if let common::Retry::After(d) =
7079 dlg.http_failure(&response, error.as_ref().ok())
7080 {
7081 sleep(d).await;
7082 continue;
7083 }
7084
7085 dlg.finished(false);
7086
7087 return Err(match error {
7088 Ok(value) => common::Error::BadRequest(value),
7089 _ => common::Error::Failure(response),
7090 });
7091 }
7092 let response = {
7093 let bytes = common::to_bytes(body).await.unwrap_or_default();
7094 let encoded = common::to_string(&bytes);
7095 match serde_json::from_str(&encoded) {
7096 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7097 Err(error) => {
7098 dlg.response_json_decode_error(&encoded, &error);
7099 return Err(common::Error::JsonDecodeError(
7100 encoded.to_string(),
7101 error,
7102 ));
7103 }
7104 }
7105 };
7106
7107 dlg.finished(true);
7108 return Ok(response);
7109 }
7110 }
7111 }
7112 }
7113
7114 /// The name of the enrollment token in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}.
7115 ///
7116 /// Sets the *name* path property to the given value.
7117 ///
7118 /// Even though the property as already been set when instantiating this call,
7119 /// we provide this method for API completeness.
7120 pub fn name(mut self, new_value: &str) -> EnterpriseEnrollmentTokenDeleteCall<'a, C> {
7121 self._name = new_value.to_string();
7122 self
7123 }
7124 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7125 /// while executing the actual API request.
7126 ///
7127 /// ````text
7128 /// It should be used to handle progress information, and to implement a certain level of resilience.
7129 /// ````
7130 ///
7131 /// Sets the *delegate* property to the given value.
7132 pub fn delegate(
7133 mut self,
7134 new_value: &'a mut dyn common::Delegate,
7135 ) -> EnterpriseEnrollmentTokenDeleteCall<'a, C> {
7136 self._delegate = Some(new_value);
7137 self
7138 }
7139
7140 /// Set any additional parameter of the query string used in the request.
7141 /// It should be used to set parameters which are not yet available through their own
7142 /// setters.
7143 ///
7144 /// Please note that this method must not be used to set any of the known parameters
7145 /// which have their own setter method. If done anyway, the request will fail.
7146 ///
7147 /// # Additional Parameters
7148 ///
7149 /// * *$.xgafv* (query-string) - V1 error format.
7150 /// * *access_token* (query-string) - OAuth access token.
7151 /// * *alt* (query-string) - Data format for response.
7152 /// * *callback* (query-string) - JSONP
7153 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7154 /// * *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.
7155 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7156 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7157 /// * *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.
7158 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7159 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7160 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseEnrollmentTokenDeleteCall<'a, C>
7161 where
7162 T: AsRef<str>,
7163 {
7164 self._additional_params
7165 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7166 self
7167 }
7168
7169 /// Identifies the authorization scope for the method you are building.
7170 ///
7171 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7172 /// [`Scope::Full`].
7173 ///
7174 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7175 /// tokens for more than one scope.
7176 ///
7177 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7178 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7179 /// sufficient, a read-write scope will do as well.
7180 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseEnrollmentTokenDeleteCall<'a, C>
7181 where
7182 St: AsRef<str>,
7183 {
7184 self._scopes.insert(String::from(scope.as_ref()));
7185 self
7186 }
7187 /// Identifies the authorization scope(s) for the method you are building.
7188 ///
7189 /// See [`Self::add_scope()`] for details.
7190 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseEnrollmentTokenDeleteCall<'a, C>
7191 where
7192 I: IntoIterator<Item = St>,
7193 St: AsRef<str>,
7194 {
7195 self._scopes
7196 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7197 self
7198 }
7199
7200 /// Removes all scopes, and no default scope will be used either.
7201 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7202 /// for details).
7203 pub fn clear_scopes(mut self) -> EnterpriseEnrollmentTokenDeleteCall<'a, C> {
7204 self._scopes.clear();
7205 self
7206 }
7207}
7208
7209/// Gets an active, unexpired enrollment token. A partial view of the enrollment token is returned. Only the following fields are populated: name, expirationTimestamp, allowPersonalUsage, value, qrCode. This method is meant to help manage active enrollment tokens lifecycle. For security reasons, it's recommended to delete active enrollment tokens as soon as they're not intended to be used anymore.
7210///
7211/// A builder for the *enrollmentTokens.get* method supported by a *enterprise* resource.
7212/// It is not used directly, but through a [`EnterpriseMethods`] instance.
7213///
7214/// # Example
7215///
7216/// Instantiate a resource method builder
7217///
7218/// ```test_harness,no_run
7219/// # extern crate hyper;
7220/// # extern crate hyper_rustls;
7221/// # extern crate google_androidmanagement1 as androidmanagement1;
7222/// # async fn dox() {
7223/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7224///
7225/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7226/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7227/// # secret,
7228/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7229/// # ).build().await.unwrap();
7230///
7231/// # let client = hyper_util::client::legacy::Client::builder(
7232/// # hyper_util::rt::TokioExecutor::new()
7233/// # )
7234/// # .build(
7235/// # hyper_rustls::HttpsConnectorBuilder::new()
7236/// # .with_native_roots()
7237/// # .unwrap()
7238/// # .https_or_http()
7239/// # .enable_http1()
7240/// # .build()
7241/// # );
7242/// # let mut hub = AndroidManagement::new(client, auth);
7243/// // You can configure optional parameters by calling the respective setters at will, and
7244/// // execute the final call using `doit()`.
7245/// // Values shown here are possibly random and not representative !
7246/// let result = hub.enterprises().enrollment_tokens_get("name")
7247/// .doit().await;
7248/// # }
7249/// ```
7250pub struct EnterpriseEnrollmentTokenGetCall<'a, C>
7251where
7252 C: 'a,
7253{
7254 hub: &'a AndroidManagement<C>,
7255 _name: String,
7256 _delegate: Option<&'a mut dyn common::Delegate>,
7257 _additional_params: HashMap<String, String>,
7258 _scopes: BTreeSet<String>,
7259}
7260
7261impl<'a, C> common::CallBuilder for EnterpriseEnrollmentTokenGetCall<'a, C> {}
7262
7263impl<'a, C> EnterpriseEnrollmentTokenGetCall<'a, C>
7264where
7265 C: common::Connector,
7266{
7267 /// Perform the operation you have build so far.
7268 pub async fn doit(mut self) -> common::Result<(common::Response, EnrollmentToken)> {
7269 use std::borrow::Cow;
7270 use std::io::{Read, Seek};
7271
7272 use common::{url::Params, ToParts};
7273 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7274
7275 let mut dd = common::DefaultDelegate;
7276 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7277 dlg.begin(common::MethodInfo {
7278 id: "androidmanagement.enterprises.enrollmentTokens.get",
7279 http_method: hyper::Method::GET,
7280 });
7281
7282 for &field in ["alt", "name"].iter() {
7283 if self._additional_params.contains_key(field) {
7284 dlg.finished(false);
7285 return Err(common::Error::FieldClash(field));
7286 }
7287 }
7288
7289 let mut params = Params::with_capacity(3 + self._additional_params.len());
7290 params.push("name", self._name);
7291
7292 params.extend(self._additional_params.iter());
7293
7294 params.push("alt", "json");
7295 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7296 if self._scopes.is_empty() {
7297 self._scopes.insert(Scope::Full.as_ref().to_string());
7298 }
7299
7300 #[allow(clippy::single_element_loop)]
7301 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7302 url = params.uri_replacement(url, param_name, find_this, true);
7303 }
7304 {
7305 let to_remove = ["name"];
7306 params.remove_params(&to_remove);
7307 }
7308
7309 let url = params.parse_with_url(&url);
7310
7311 loop {
7312 let token = match self
7313 .hub
7314 .auth
7315 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7316 .await
7317 {
7318 Ok(token) => token,
7319 Err(e) => match dlg.token(e) {
7320 Ok(token) => token,
7321 Err(e) => {
7322 dlg.finished(false);
7323 return Err(common::Error::MissingToken(e));
7324 }
7325 },
7326 };
7327 let mut req_result = {
7328 let client = &self.hub.client;
7329 dlg.pre_request();
7330 let mut req_builder = hyper::Request::builder()
7331 .method(hyper::Method::GET)
7332 .uri(url.as_str())
7333 .header(USER_AGENT, self.hub._user_agent.clone());
7334
7335 if let Some(token) = token.as_ref() {
7336 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7337 }
7338
7339 let request = req_builder
7340 .header(CONTENT_LENGTH, 0_u64)
7341 .body(common::to_body::<String>(None));
7342
7343 client.request(request.unwrap()).await
7344 };
7345
7346 match req_result {
7347 Err(err) => {
7348 if let common::Retry::After(d) = dlg.http_error(&err) {
7349 sleep(d).await;
7350 continue;
7351 }
7352 dlg.finished(false);
7353 return Err(common::Error::HttpError(err));
7354 }
7355 Ok(res) => {
7356 let (mut parts, body) = res.into_parts();
7357 let mut body = common::Body::new(body);
7358 if !parts.status.is_success() {
7359 let bytes = common::to_bytes(body).await.unwrap_or_default();
7360 let error = serde_json::from_str(&common::to_string(&bytes));
7361 let response = common::to_response(parts, bytes.into());
7362
7363 if let common::Retry::After(d) =
7364 dlg.http_failure(&response, error.as_ref().ok())
7365 {
7366 sleep(d).await;
7367 continue;
7368 }
7369
7370 dlg.finished(false);
7371
7372 return Err(match error {
7373 Ok(value) => common::Error::BadRequest(value),
7374 _ => common::Error::Failure(response),
7375 });
7376 }
7377 let response = {
7378 let bytes = common::to_bytes(body).await.unwrap_or_default();
7379 let encoded = common::to_string(&bytes);
7380 match serde_json::from_str(&encoded) {
7381 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7382 Err(error) => {
7383 dlg.response_json_decode_error(&encoded, &error);
7384 return Err(common::Error::JsonDecodeError(
7385 encoded.to_string(),
7386 error,
7387 ));
7388 }
7389 }
7390 };
7391
7392 dlg.finished(true);
7393 return Ok(response);
7394 }
7395 }
7396 }
7397 }
7398
7399 /// Required. The name of the enrollment token in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}.
7400 ///
7401 /// Sets the *name* path property to the given value.
7402 ///
7403 /// Even though the property as already been set when instantiating this call,
7404 /// we provide this method for API completeness.
7405 pub fn name(mut self, new_value: &str) -> EnterpriseEnrollmentTokenGetCall<'a, C> {
7406 self._name = new_value.to_string();
7407 self
7408 }
7409 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7410 /// while executing the actual API request.
7411 ///
7412 /// ````text
7413 /// It should be used to handle progress information, and to implement a certain level of resilience.
7414 /// ````
7415 ///
7416 /// Sets the *delegate* property to the given value.
7417 pub fn delegate(
7418 mut self,
7419 new_value: &'a mut dyn common::Delegate,
7420 ) -> EnterpriseEnrollmentTokenGetCall<'a, C> {
7421 self._delegate = Some(new_value);
7422 self
7423 }
7424
7425 /// Set any additional parameter of the query string used in the request.
7426 /// It should be used to set parameters which are not yet available through their own
7427 /// setters.
7428 ///
7429 /// Please note that this method must not be used to set any of the known parameters
7430 /// which have their own setter method. If done anyway, the request will fail.
7431 ///
7432 /// # Additional Parameters
7433 ///
7434 /// * *$.xgafv* (query-string) - V1 error format.
7435 /// * *access_token* (query-string) - OAuth access token.
7436 /// * *alt* (query-string) - Data format for response.
7437 /// * *callback* (query-string) - JSONP
7438 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7439 /// * *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.
7440 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7441 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7442 /// * *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.
7443 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7444 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7445 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseEnrollmentTokenGetCall<'a, C>
7446 where
7447 T: AsRef<str>,
7448 {
7449 self._additional_params
7450 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7451 self
7452 }
7453
7454 /// Identifies the authorization scope for the method you are building.
7455 ///
7456 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7457 /// [`Scope::Full`].
7458 ///
7459 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7460 /// tokens for more than one scope.
7461 ///
7462 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7463 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7464 /// sufficient, a read-write scope will do as well.
7465 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseEnrollmentTokenGetCall<'a, C>
7466 where
7467 St: AsRef<str>,
7468 {
7469 self._scopes.insert(String::from(scope.as_ref()));
7470 self
7471 }
7472 /// Identifies the authorization scope(s) for the method you are building.
7473 ///
7474 /// See [`Self::add_scope()`] for details.
7475 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseEnrollmentTokenGetCall<'a, C>
7476 where
7477 I: IntoIterator<Item = St>,
7478 St: AsRef<str>,
7479 {
7480 self._scopes
7481 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7482 self
7483 }
7484
7485 /// Removes all scopes, and no default scope will be used either.
7486 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7487 /// for details).
7488 pub fn clear_scopes(mut self) -> EnterpriseEnrollmentTokenGetCall<'a, C> {
7489 self._scopes.clear();
7490 self
7491 }
7492}
7493
7494/// Lists active, unexpired enrollment tokens for a given enterprise. The list items contain only a partial view of EnrollmentToken object. Only the following fields are populated: name, expirationTimestamp, allowPersonalUsage, value, qrCode. This method is meant to help manage active enrollment tokens lifecycle. For security reasons, it's recommended to delete active enrollment tokens as soon as they're not intended to be used anymore.
7495///
7496/// A builder for the *enrollmentTokens.list* method supported by a *enterprise* resource.
7497/// It is not used directly, but through a [`EnterpriseMethods`] instance.
7498///
7499/// # Example
7500///
7501/// Instantiate a resource method builder
7502///
7503/// ```test_harness,no_run
7504/// # extern crate hyper;
7505/// # extern crate hyper_rustls;
7506/// # extern crate google_androidmanagement1 as androidmanagement1;
7507/// # async fn dox() {
7508/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7509///
7510/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7511/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7512/// # secret,
7513/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7514/// # ).build().await.unwrap();
7515///
7516/// # let client = hyper_util::client::legacy::Client::builder(
7517/// # hyper_util::rt::TokioExecutor::new()
7518/// # )
7519/// # .build(
7520/// # hyper_rustls::HttpsConnectorBuilder::new()
7521/// # .with_native_roots()
7522/// # .unwrap()
7523/// # .https_or_http()
7524/// # .enable_http1()
7525/// # .build()
7526/// # );
7527/// # let mut hub = AndroidManagement::new(client, auth);
7528/// // You can configure optional parameters by calling the respective setters at will, and
7529/// // execute the final call using `doit()`.
7530/// // Values shown here are possibly random and not representative !
7531/// let result = hub.enterprises().enrollment_tokens_list("parent")
7532/// .page_token("dolor")
7533/// .page_size(-56)
7534/// .doit().await;
7535/// # }
7536/// ```
7537pub struct EnterpriseEnrollmentTokenListCall<'a, C>
7538where
7539 C: 'a,
7540{
7541 hub: &'a AndroidManagement<C>,
7542 _parent: String,
7543 _page_token: Option<String>,
7544 _page_size: Option<i32>,
7545 _delegate: Option<&'a mut dyn common::Delegate>,
7546 _additional_params: HashMap<String, String>,
7547 _scopes: BTreeSet<String>,
7548}
7549
7550impl<'a, C> common::CallBuilder for EnterpriseEnrollmentTokenListCall<'a, C> {}
7551
7552impl<'a, C> EnterpriseEnrollmentTokenListCall<'a, C>
7553where
7554 C: common::Connector,
7555{
7556 /// Perform the operation you have build so far.
7557 pub async fn doit(
7558 mut self,
7559 ) -> common::Result<(common::Response, ListEnrollmentTokensResponse)> {
7560 use std::borrow::Cow;
7561 use std::io::{Read, Seek};
7562
7563 use common::{url::Params, ToParts};
7564 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7565
7566 let mut dd = common::DefaultDelegate;
7567 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7568 dlg.begin(common::MethodInfo {
7569 id: "androidmanagement.enterprises.enrollmentTokens.list",
7570 http_method: hyper::Method::GET,
7571 });
7572
7573 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
7574 if self._additional_params.contains_key(field) {
7575 dlg.finished(false);
7576 return Err(common::Error::FieldClash(field));
7577 }
7578 }
7579
7580 let mut params = Params::with_capacity(5 + self._additional_params.len());
7581 params.push("parent", self._parent);
7582 if let Some(value) = self._page_token.as_ref() {
7583 params.push("pageToken", value);
7584 }
7585 if let Some(value) = self._page_size.as_ref() {
7586 params.push("pageSize", value.to_string());
7587 }
7588
7589 params.extend(self._additional_params.iter());
7590
7591 params.push("alt", "json");
7592 let mut url = self.hub._base_url.clone() + "v1/{+parent}/enrollmentTokens";
7593 if self._scopes.is_empty() {
7594 self._scopes.insert(Scope::Full.as_ref().to_string());
7595 }
7596
7597 #[allow(clippy::single_element_loop)]
7598 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7599 url = params.uri_replacement(url, param_name, find_this, true);
7600 }
7601 {
7602 let to_remove = ["parent"];
7603 params.remove_params(&to_remove);
7604 }
7605
7606 let url = params.parse_with_url(&url);
7607
7608 loop {
7609 let token = match self
7610 .hub
7611 .auth
7612 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7613 .await
7614 {
7615 Ok(token) => token,
7616 Err(e) => match dlg.token(e) {
7617 Ok(token) => token,
7618 Err(e) => {
7619 dlg.finished(false);
7620 return Err(common::Error::MissingToken(e));
7621 }
7622 },
7623 };
7624 let mut req_result = {
7625 let client = &self.hub.client;
7626 dlg.pre_request();
7627 let mut req_builder = hyper::Request::builder()
7628 .method(hyper::Method::GET)
7629 .uri(url.as_str())
7630 .header(USER_AGENT, self.hub._user_agent.clone());
7631
7632 if let Some(token) = token.as_ref() {
7633 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7634 }
7635
7636 let request = req_builder
7637 .header(CONTENT_LENGTH, 0_u64)
7638 .body(common::to_body::<String>(None));
7639
7640 client.request(request.unwrap()).await
7641 };
7642
7643 match req_result {
7644 Err(err) => {
7645 if let common::Retry::After(d) = dlg.http_error(&err) {
7646 sleep(d).await;
7647 continue;
7648 }
7649 dlg.finished(false);
7650 return Err(common::Error::HttpError(err));
7651 }
7652 Ok(res) => {
7653 let (mut parts, body) = res.into_parts();
7654 let mut body = common::Body::new(body);
7655 if !parts.status.is_success() {
7656 let bytes = common::to_bytes(body).await.unwrap_or_default();
7657 let error = serde_json::from_str(&common::to_string(&bytes));
7658 let response = common::to_response(parts, bytes.into());
7659
7660 if let common::Retry::After(d) =
7661 dlg.http_failure(&response, error.as_ref().ok())
7662 {
7663 sleep(d).await;
7664 continue;
7665 }
7666
7667 dlg.finished(false);
7668
7669 return Err(match error {
7670 Ok(value) => common::Error::BadRequest(value),
7671 _ => common::Error::Failure(response),
7672 });
7673 }
7674 let response = {
7675 let bytes = common::to_bytes(body).await.unwrap_or_default();
7676 let encoded = common::to_string(&bytes);
7677 match serde_json::from_str(&encoded) {
7678 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7679 Err(error) => {
7680 dlg.response_json_decode_error(&encoded, &error);
7681 return Err(common::Error::JsonDecodeError(
7682 encoded.to_string(),
7683 error,
7684 ));
7685 }
7686 }
7687 };
7688
7689 dlg.finished(true);
7690 return Ok(response);
7691 }
7692 }
7693 }
7694 }
7695
7696 /// Required. The name of the enterprise in the form enterprises/{enterpriseId}.
7697 ///
7698 /// Sets the *parent* path property to the given value.
7699 ///
7700 /// Even though the property as already been set when instantiating this call,
7701 /// we provide this method for API completeness.
7702 pub fn parent(mut self, new_value: &str) -> EnterpriseEnrollmentTokenListCall<'a, C> {
7703 self._parent = new_value.to_string();
7704 self
7705 }
7706 /// A token identifying a page of results returned by the server.
7707 ///
7708 /// Sets the *page token* query property to the given value.
7709 pub fn page_token(mut self, new_value: &str) -> EnterpriseEnrollmentTokenListCall<'a, C> {
7710 self._page_token = Some(new_value.to_string());
7711 self
7712 }
7713 /// The requested page size. The service may return fewer than this value. If unspecified, at most 10 items will be returned. The maximum value is 100; values above 100 will be coerced to 100.
7714 ///
7715 /// Sets the *page size* query property to the given value.
7716 pub fn page_size(mut self, new_value: i32) -> EnterpriseEnrollmentTokenListCall<'a, C> {
7717 self._page_size = Some(new_value);
7718 self
7719 }
7720 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7721 /// while executing the actual API request.
7722 ///
7723 /// ````text
7724 /// It should be used to handle progress information, and to implement a certain level of resilience.
7725 /// ````
7726 ///
7727 /// Sets the *delegate* property to the given value.
7728 pub fn delegate(
7729 mut self,
7730 new_value: &'a mut dyn common::Delegate,
7731 ) -> EnterpriseEnrollmentTokenListCall<'a, C> {
7732 self._delegate = Some(new_value);
7733 self
7734 }
7735
7736 /// Set any additional parameter of the query string used in the request.
7737 /// It should be used to set parameters which are not yet available through their own
7738 /// setters.
7739 ///
7740 /// Please note that this method must not be used to set any of the known parameters
7741 /// which have their own setter method. If done anyway, the request will fail.
7742 ///
7743 /// # Additional Parameters
7744 ///
7745 /// * *$.xgafv* (query-string) - V1 error format.
7746 /// * *access_token* (query-string) - OAuth access token.
7747 /// * *alt* (query-string) - Data format for response.
7748 /// * *callback* (query-string) - JSONP
7749 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7750 /// * *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.
7751 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7752 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7753 /// * *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.
7754 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7755 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7756 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseEnrollmentTokenListCall<'a, C>
7757 where
7758 T: AsRef<str>,
7759 {
7760 self._additional_params
7761 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7762 self
7763 }
7764
7765 /// Identifies the authorization scope for the method you are building.
7766 ///
7767 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7768 /// [`Scope::Full`].
7769 ///
7770 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7771 /// tokens for more than one scope.
7772 ///
7773 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7774 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7775 /// sufficient, a read-write scope will do as well.
7776 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseEnrollmentTokenListCall<'a, C>
7777 where
7778 St: AsRef<str>,
7779 {
7780 self._scopes.insert(String::from(scope.as_ref()));
7781 self
7782 }
7783 /// Identifies the authorization scope(s) for the method you are building.
7784 ///
7785 /// See [`Self::add_scope()`] for details.
7786 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseEnrollmentTokenListCall<'a, C>
7787 where
7788 I: IntoIterator<Item = St>,
7789 St: AsRef<str>,
7790 {
7791 self._scopes
7792 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7793 self
7794 }
7795
7796 /// Removes all scopes, and no default scope will be used either.
7797 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7798 /// for details).
7799 pub fn clear_scopes(mut self) -> EnterpriseEnrollmentTokenListCall<'a, C> {
7800 self._scopes.clear();
7801 self
7802 }
7803}
7804
7805/// Creates a migration token, to migrate an existing device from being managed by the EMM's Device Policy Controller (DPC) to being managed by the Android Management API. See the guide (https://developers.google.com/android/management/dpc-migration) for more details.
7806///
7807/// A builder for the *migrationTokens.create* method supported by a *enterprise* resource.
7808/// It is not used directly, but through a [`EnterpriseMethods`] instance.
7809///
7810/// # Example
7811///
7812/// Instantiate a resource method builder
7813///
7814/// ```test_harness,no_run
7815/// # extern crate hyper;
7816/// # extern crate hyper_rustls;
7817/// # extern crate google_androidmanagement1 as androidmanagement1;
7818/// use androidmanagement1::api::MigrationToken;
7819/// # async fn dox() {
7820/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7821///
7822/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7823/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7824/// # secret,
7825/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7826/// # ).build().await.unwrap();
7827///
7828/// # let client = hyper_util::client::legacy::Client::builder(
7829/// # hyper_util::rt::TokioExecutor::new()
7830/// # )
7831/// # .build(
7832/// # hyper_rustls::HttpsConnectorBuilder::new()
7833/// # .with_native_roots()
7834/// # .unwrap()
7835/// # .https_or_http()
7836/// # .enable_http1()
7837/// # .build()
7838/// # );
7839/// # let mut hub = AndroidManagement::new(client, auth);
7840/// // As the method needs a request, you would usually fill it with the desired information
7841/// // into the respective structure. Some of the parts shown here might not be applicable !
7842/// // Values shown here are possibly random and not representative !
7843/// let mut req = MigrationToken::default();
7844///
7845/// // You can configure optional parameters by calling the respective setters at will, and
7846/// // execute the final call using `doit()`.
7847/// // Values shown here are possibly random and not representative !
7848/// let result = hub.enterprises().migration_tokens_create(req, "parent")
7849/// .doit().await;
7850/// # }
7851/// ```
7852pub struct EnterpriseMigrationTokenCreateCall<'a, C>
7853where
7854 C: 'a,
7855{
7856 hub: &'a AndroidManagement<C>,
7857 _request: MigrationToken,
7858 _parent: String,
7859 _delegate: Option<&'a mut dyn common::Delegate>,
7860 _additional_params: HashMap<String, String>,
7861 _scopes: BTreeSet<String>,
7862}
7863
7864impl<'a, C> common::CallBuilder for EnterpriseMigrationTokenCreateCall<'a, C> {}
7865
7866impl<'a, C> EnterpriseMigrationTokenCreateCall<'a, C>
7867where
7868 C: common::Connector,
7869{
7870 /// Perform the operation you have build so far.
7871 pub async fn doit(mut self) -> common::Result<(common::Response, MigrationToken)> {
7872 use std::borrow::Cow;
7873 use std::io::{Read, Seek};
7874
7875 use common::{url::Params, ToParts};
7876 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7877
7878 let mut dd = common::DefaultDelegate;
7879 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7880 dlg.begin(common::MethodInfo {
7881 id: "androidmanagement.enterprises.migrationTokens.create",
7882 http_method: hyper::Method::POST,
7883 });
7884
7885 for &field in ["alt", "parent"].iter() {
7886 if self._additional_params.contains_key(field) {
7887 dlg.finished(false);
7888 return Err(common::Error::FieldClash(field));
7889 }
7890 }
7891
7892 let mut params = Params::with_capacity(4 + self._additional_params.len());
7893 params.push("parent", self._parent);
7894
7895 params.extend(self._additional_params.iter());
7896
7897 params.push("alt", "json");
7898 let mut url = self.hub._base_url.clone() + "v1/{+parent}/migrationTokens";
7899 if self._scopes.is_empty() {
7900 self._scopes.insert(Scope::Full.as_ref().to_string());
7901 }
7902
7903 #[allow(clippy::single_element_loop)]
7904 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7905 url = params.uri_replacement(url, param_name, find_this, true);
7906 }
7907 {
7908 let to_remove = ["parent"];
7909 params.remove_params(&to_remove);
7910 }
7911
7912 let url = params.parse_with_url(&url);
7913
7914 let mut json_mime_type = mime::APPLICATION_JSON;
7915 let mut request_value_reader = {
7916 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7917 common::remove_json_null_values(&mut value);
7918 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7919 serde_json::to_writer(&mut dst, &value).unwrap();
7920 dst
7921 };
7922 let request_size = request_value_reader
7923 .seek(std::io::SeekFrom::End(0))
7924 .unwrap();
7925 request_value_reader
7926 .seek(std::io::SeekFrom::Start(0))
7927 .unwrap();
7928
7929 loop {
7930 let token = match self
7931 .hub
7932 .auth
7933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7934 .await
7935 {
7936 Ok(token) => token,
7937 Err(e) => match dlg.token(e) {
7938 Ok(token) => token,
7939 Err(e) => {
7940 dlg.finished(false);
7941 return Err(common::Error::MissingToken(e));
7942 }
7943 },
7944 };
7945 request_value_reader
7946 .seek(std::io::SeekFrom::Start(0))
7947 .unwrap();
7948 let mut req_result = {
7949 let client = &self.hub.client;
7950 dlg.pre_request();
7951 let mut req_builder = hyper::Request::builder()
7952 .method(hyper::Method::POST)
7953 .uri(url.as_str())
7954 .header(USER_AGENT, self.hub._user_agent.clone());
7955
7956 if let Some(token) = token.as_ref() {
7957 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7958 }
7959
7960 let request = req_builder
7961 .header(CONTENT_TYPE, json_mime_type.to_string())
7962 .header(CONTENT_LENGTH, request_size as u64)
7963 .body(common::to_body(
7964 request_value_reader.get_ref().clone().into(),
7965 ));
7966
7967 client.request(request.unwrap()).await
7968 };
7969
7970 match req_result {
7971 Err(err) => {
7972 if let common::Retry::After(d) = dlg.http_error(&err) {
7973 sleep(d).await;
7974 continue;
7975 }
7976 dlg.finished(false);
7977 return Err(common::Error::HttpError(err));
7978 }
7979 Ok(res) => {
7980 let (mut parts, body) = res.into_parts();
7981 let mut body = common::Body::new(body);
7982 if !parts.status.is_success() {
7983 let bytes = common::to_bytes(body).await.unwrap_or_default();
7984 let error = serde_json::from_str(&common::to_string(&bytes));
7985 let response = common::to_response(parts, bytes.into());
7986
7987 if let common::Retry::After(d) =
7988 dlg.http_failure(&response, error.as_ref().ok())
7989 {
7990 sleep(d).await;
7991 continue;
7992 }
7993
7994 dlg.finished(false);
7995
7996 return Err(match error {
7997 Ok(value) => common::Error::BadRequest(value),
7998 _ => common::Error::Failure(response),
7999 });
8000 }
8001 let response = {
8002 let bytes = common::to_bytes(body).await.unwrap_or_default();
8003 let encoded = common::to_string(&bytes);
8004 match serde_json::from_str(&encoded) {
8005 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8006 Err(error) => {
8007 dlg.response_json_decode_error(&encoded, &error);
8008 return Err(common::Error::JsonDecodeError(
8009 encoded.to_string(),
8010 error,
8011 ));
8012 }
8013 }
8014 };
8015
8016 dlg.finished(true);
8017 return Ok(response);
8018 }
8019 }
8020 }
8021 }
8022
8023 ///
8024 /// Sets the *request* property to the given value.
8025 ///
8026 /// Even though the property as already been set when instantiating this call,
8027 /// we provide this method for API completeness.
8028 pub fn request(
8029 mut self,
8030 new_value: MigrationToken,
8031 ) -> EnterpriseMigrationTokenCreateCall<'a, C> {
8032 self._request = new_value;
8033 self
8034 }
8035 /// Required. The enterprise in which this migration token is created. This must be the same enterprise which already manages the device in the Play EMM API. Format: enterprises/{enterprise}
8036 ///
8037 /// Sets the *parent* path property to the given value.
8038 ///
8039 /// Even though the property as already been set when instantiating this call,
8040 /// we provide this method for API completeness.
8041 pub fn parent(mut self, new_value: &str) -> EnterpriseMigrationTokenCreateCall<'a, C> {
8042 self._parent = new_value.to_string();
8043 self
8044 }
8045 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8046 /// while executing the actual API request.
8047 ///
8048 /// ````text
8049 /// It should be used to handle progress information, and to implement a certain level of resilience.
8050 /// ````
8051 ///
8052 /// Sets the *delegate* property to the given value.
8053 pub fn delegate(
8054 mut self,
8055 new_value: &'a mut dyn common::Delegate,
8056 ) -> EnterpriseMigrationTokenCreateCall<'a, C> {
8057 self._delegate = Some(new_value);
8058 self
8059 }
8060
8061 /// Set any additional parameter of the query string used in the request.
8062 /// It should be used to set parameters which are not yet available through their own
8063 /// setters.
8064 ///
8065 /// Please note that this method must not be used to set any of the known parameters
8066 /// which have their own setter method. If done anyway, the request will fail.
8067 ///
8068 /// # Additional Parameters
8069 ///
8070 /// * *$.xgafv* (query-string) - V1 error format.
8071 /// * *access_token* (query-string) - OAuth access token.
8072 /// * *alt* (query-string) - Data format for response.
8073 /// * *callback* (query-string) - JSONP
8074 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8075 /// * *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.
8076 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8077 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8078 /// * *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.
8079 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8080 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8081 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseMigrationTokenCreateCall<'a, C>
8082 where
8083 T: AsRef<str>,
8084 {
8085 self._additional_params
8086 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8087 self
8088 }
8089
8090 /// Identifies the authorization scope for the method you are building.
8091 ///
8092 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8093 /// [`Scope::Full`].
8094 ///
8095 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8096 /// tokens for more than one scope.
8097 ///
8098 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8099 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8100 /// sufficient, a read-write scope will do as well.
8101 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseMigrationTokenCreateCall<'a, C>
8102 where
8103 St: AsRef<str>,
8104 {
8105 self._scopes.insert(String::from(scope.as_ref()));
8106 self
8107 }
8108 /// Identifies the authorization scope(s) for the method you are building.
8109 ///
8110 /// See [`Self::add_scope()`] for details.
8111 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseMigrationTokenCreateCall<'a, C>
8112 where
8113 I: IntoIterator<Item = St>,
8114 St: AsRef<str>,
8115 {
8116 self._scopes
8117 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8118 self
8119 }
8120
8121 /// Removes all scopes, and no default scope will be used either.
8122 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8123 /// for details).
8124 pub fn clear_scopes(mut self) -> EnterpriseMigrationTokenCreateCall<'a, C> {
8125 self._scopes.clear();
8126 self
8127 }
8128}
8129
8130/// Gets a migration token.
8131///
8132/// A builder for the *migrationTokens.get* method supported by a *enterprise* resource.
8133/// It is not used directly, but through a [`EnterpriseMethods`] instance.
8134///
8135/// # Example
8136///
8137/// Instantiate a resource method builder
8138///
8139/// ```test_harness,no_run
8140/// # extern crate hyper;
8141/// # extern crate hyper_rustls;
8142/// # extern crate google_androidmanagement1 as androidmanagement1;
8143/// # async fn dox() {
8144/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8145///
8146/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8147/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8148/// # secret,
8149/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8150/// # ).build().await.unwrap();
8151///
8152/// # let client = hyper_util::client::legacy::Client::builder(
8153/// # hyper_util::rt::TokioExecutor::new()
8154/// # )
8155/// # .build(
8156/// # hyper_rustls::HttpsConnectorBuilder::new()
8157/// # .with_native_roots()
8158/// # .unwrap()
8159/// # .https_or_http()
8160/// # .enable_http1()
8161/// # .build()
8162/// # );
8163/// # let mut hub = AndroidManagement::new(client, auth);
8164/// // You can configure optional parameters by calling the respective setters at will, and
8165/// // execute the final call using `doit()`.
8166/// // Values shown here are possibly random and not representative !
8167/// let result = hub.enterprises().migration_tokens_get("name")
8168/// .doit().await;
8169/// # }
8170/// ```
8171pub struct EnterpriseMigrationTokenGetCall<'a, C>
8172where
8173 C: 'a,
8174{
8175 hub: &'a AndroidManagement<C>,
8176 _name: String,
8177 _delegate: Option<&'a mut dyn common::Delegate>,
8178 _additional_params: HashMap<String, String>,
8179 _scopes: BTreeSet<String>,
8180}
8181
8182impl<'a, C> common::CallBuilder for EnterpriseMigrationTokenGetCall<'a, C> {}
8183
8184impl<'a, C> EnterpriseMigrationTokenGetCall<'a, C>
8185where
8186 C: common::Connector,
8187{
8188 /// Perform the operation you have build so far.
8189 pub async fn doit(mut self) -> common::Result<(common::Response, MigrationToken)> {
8190 use std::borrow::Cow;
8191 use std::io::{Read, Seek};
8192
8193 use common::{url::Params, ToParts};
8194 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8195
8196 let mut dd = common::DefaultDelegate;
8197 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8198 dlg.begin(common::MethodInfo {
8199 id: "androidmanagement.enterprises.migrationTokens.get",
8200 http_method: hyper::Method::GET,
8201 });
8202
8203 for &field in ["alt", "name"].iter() {
8204 if self._additional_params.contains_key(field) {
8205 dlg.finished(false);
8206 return Err(common::Error::FieldClash(field));
8207 }
8208 }
8209
8210 let mut params = Params::with_capacity(3 + self._additional_params.len());
8211 params.push("name", self._name);
8212
8213 params.extend(self._additional_params.iter());
8214
8215 params.push("alt", "json");
8216 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8217 if self._scopes.is_empty() {
8218 self._scopes.insert(Scope::Full.as_ref().to_string());
8219 }
8220
8221 #[allow(clippy::single_element_loop)]
8222 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8223 url = params.uri_replacement(url, param_name, find_this, true);
8224 }
8225 {
8226 let to_remove = ["name"];
8227 params.remove_params(&to_remove);
8228 }
8229
8230 let url = params.parse_with_url(&url);
8231
8232 loop {
8233 let token = match self
8234 .hub
8235 .auth
8236 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8237 .await
8238 {
8239 Ok(token) => token,
8240 Err(e) => match dlg.token(e) {
8241 Ok(token) => token,
8242 Err(e) => {
8243 dlg.finished(false);
8244 return Err(common::Error::MissingToken(e));
8245 }
8246 },
8247 };
8248 let mut req_result = {
8249 let client = &self.hub.client;
8250 dlg.pre_request();
8251 let mut req_builder = hyper::Request::builder()
8252 .method(hyper::Method::GET)
8253 .uri(url.as_str())
8254 .header(USER_AGENT, self.hub._user_agent.clone());
8255
8256 if let Some(token) = token.as_ref() {
8257 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8258 }
8259
8260 let request = req_builder
8261 .header(CONTENT_LENGTH, 0_u64)
8262 .body(common::to_body::<String>(None));
8263
8264 client.request(request.unwrap()).await
8265 };
8266
8267 match req_result {
8268 Err(err) => {
8269 if let common::Retry::After(d) = dlg.http_error(&err) {
8270 sleep(d).await;
8271 continue;
8272 }
8273 dlg.finished(false);
8274 return Err(common::Error::HttpError(err));
8275 }
8276 Ok(res) => {
8277 let (mut parts, body) = res.into_parts();
8278 let mut body = common::Body::new(body);
8279 if !parts.status.is_success() {
8280 let bytes = common::to_bytes(body).await.unwrap_or_default();
8281 let error = serde_json::from_str(&common::to_string(&bytes));
8282 let response = common::to_response(parts, bytes.into());
8283
8284 if let common::Retry::After(d) =
8285 dlg.http_failure(&response, error.as_ref().ok())
8286 {
8287 sleep(d).await;
8288 continue;
8289 }
8290
8291 dlg.finished(false);
8292
8293 return Err(match error {
8294 Ok(value) => common::Error::BadRequest(value),
8295 _ => common::Error::Failure(response),
8296 });
8297 }
8298 let response = {
8299 let bytes = common::to_bytes(body).await.unwrap_or_default();
8300 let encoded = common::to_string(&bytes);
8301 match serde_json::from_str(&encoded) {
8302 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8303 Err(error) => {
8304 dlg.response_json_decode_error(&encoded, &error);
8305 return Err(common::Error::JsonDecodeError(
8306 encoded.to_string(),
8307 error,
8308 ));
8309 }
8310 }
8311 };
8312
8313 dlg.finished(true);
8314 return Ok(response);
8315 }
8316 }
8317 }
8318 }
8319
8320 /// Required. The name of the migration token to retrieve. Format: enterprises/{enterprise}/migrationTokens/{migration_token}
8321 ///
8322 /// Sets the *name* path property to the given value.
8323 ///
8324 /// Even though the property as already been set when instantiating this call,
8325 /// we provide this method for API completeness.
8326 pub fn name(mut self, new_value: &str) -> EnterpriseMigrationTokenGetCall<'a, C> {
8327 self._name = new_value.to_string();
8328 self
8329 }
8330 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8331 /// while executing the actual API request.
8332 ///
8333 /// ````text
8334 /// It should be used to handle progress information, and to implement a certain level of resilience.
8335 /// ````
8336 ///
8337 /// Sets the *delegate* property to the given value.
8338 pub fn delegate(
8339 mut self,
8340 new_value: &'a mut dyn common::Delegate,
8341 ) -> EnterpriseMigrationTokenGetCall<'a, C> {
8342 self._delegate = Some(new_value);
8343 self
8344 }
8345
8346 /// Set any additional parameter of the query string used in the request.
8347 /// It should be used to set parameters which are not yet available through their own
8348 /// setters.
8349 ///
8350 /// Please note that this method must not be used to set any of the known parameters
8351 /// which have their own setter method. If done anyway, the request will fail.
8352 ///
8353 /// # Additional Parameters
8354 ///
8355 /// * *$.xgafv* (query-string) - V1 error format.
8356 /// * *access_token* (query-string) - OAuth access token.
8357 /// * *alt* (query-string) - Data format for response.
8358 /// * *callback* (query-string) - JSONP
8359 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8360 /// * *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.
8361 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8362 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8363 /// * *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.
8364 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8365 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8366 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseMigrationTokenGetCall<'a, C>
8367 where
8368 T: AsRef<str>,
8369 {
8370 self._additional_params
8371 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8372 self
8373 }
8374
8375 /// Identifies the authorization scope for the method you are building.
8376 ///
8377 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8378 /// [`Scope::Full`].
8379 ///
8380 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8381 /// tokens for more than one scope.
8382 ///
8383 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8384 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8385 /// sufficient, a read-write scope will do as well.
8386 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseMigrationTokenGetCall<'a, C>
8387 where
8388 St: AsRef<str>,
8389 {
8390 self._scopes.insert(String::from(scope.as_ref()));
8391 self
8392 }
8393 /// Identifies the authorization scope(s) for the method you are building.
8394 ///
8395 /// See [`Self::add_scope()`] for details.
8396 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseMigrationTokenGetCall<'a, C>
8397 where
8398 I: IntoIterator<Item = St>,
8399 St: AsRef<str>,
8400 {
8401 self._scopes
8402 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8403 self
8404 }
8405
8406 /// Removes all scopes, and no default scope will be used either.
8407 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8408 /// for details).
8409 pub fn clear_scopes(mut self) -> EnterpriseMigrationTokenGetCall<'a, C> {
8410 self._scopes.clear();
8411 self
8412 }
8413}
8414
8415/// Lists migration tokens.
8416///
8417/// A builder for the *migrationTokens.list* method supported by a *enterprise* resource.
8418/// It is not used directly, but through a [`EnterpriseMethods`] instance.
8419///
8420/// # Example
8421///
8422/// Instantiate a resource method builder
8423///
8424/// ```test_harness,no_run
8425/// # extern crate hyper;
8426/// # extern crate hyper_rustls;
8427/// # extern crate google_androidmanagement1 as androidmanagement1;
8428/// # async fn dox() {
8429/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8430///
8431/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8432/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8433/// # secret,
8434/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8435/// # ).build().await.unwrap();
8436///
8437/// # let client = hyper_util::client::legacy::Client::builder(
8438/// # hyper_util::rt::TokioExecutor::new()
8439/// # )
8440/// # .build(
8441/// # hyper_rustls::HttpsConnectorBuilder::new()
8442/// # .with_native_roots()
8443/// # .unwrap()
8444/// # .https_or_http()
8445/// # .enable_http1()
8446/// # .build()
8447/// # );
8448/// # let mut hub = AndroidManagement::new(client, auth);
8449/// // You can configure optional parameters by calling the respective setters at will, and
8450/// // execute the final call using `doit()`.
8451/// // Values shown here are possibly random and not representative !
8452/// let result = hub.enterprises().migration_tokens_list("parent")
8453/// .page_token("duo")
8454/// .page_size(-80)
8455/// .doit().await;
8456/// # }
8457/// ```
8458pub struct EnterpriseMigrationTokenListCall<'a, C>
8459where
8460 C: 'a,
8461{
8462 hub: &'a AndroidManagement<C>,
8463 _parent: String,
8464 _page_token: Option<String>,
8465 _page_size: Option<i32>,
8466 _delegate: Option<&'a mut dyn common::Delegate>,
8467 _additional_params: HashMap<String, String>,
8468 _scopes: BTreeSet<String>,
8469}
8470
8471impl<'a, C> common::CallBuilder for EnterpriseMigrationTokenListCall<'a, C> {}
8472
8473impl<'a, C> EnterpriseMigrationTokenListCall<'a, C>
8474where
8475 C: common::Connector,
8476{
8477 /// Perform the operation you have build so far.
8478 pub async fn doit(mut self) -> common::Result<(common::Response, ListMigrationTokensResponse)> {
8479 use std::borrow::Cow;
8480 use std::io::{Read, Seek};
8481
8482 use common::{url::Params, ToParts};
8483 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8484
8485 let mut dd = common::DefaultDelegate;
8486 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8487 dlg.begin(common::MethodInfo {
8488 id: "androidmanagement.enterprises.migrationTokens.list",
8489 http_method: hyper::Method::GET,
8490 });
8491
8492 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8493 if self._additional_params.contains_key(field) {
8494 dlg.finished(false);
8495 return Err(common::Error::FieldClash(field));
8496 }
8497 }
8498
8499 let mut params = Params::with_capacity(5 + self._additional_params.len());
8500 params.push("parent", self._parent);
8501 if let Some(value) = self._page_token.as_ref() {
8502 params.push("pageToken", value);
8503 }
8504 if let Some(value) = self._page_size.as_ref() {
8505 params.push("pageSize", value.to_string());
8506 }
8507
8508 params.extend(self._additional_params.iter());
8509
8510 params.push("alt", "json");
8511 let mut url = self.hub._base_url.clone() + "v1/{+parent}/migrationTokens";
8512 if self._scopes.is_empty() {
8513 self._scopes.insert(Scope::Full.as_ref().to_string());
8514 }
8515
8516 #[allow(clippy::single_element_loop)]
8517 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8518 url = params.uri_replacement(url, param_name, find_this, true);
8519 }
8520 {
8521 let to_remove = ["parent"];
8522 params.remove_params(&to_remove);
8523 }
8524
8525 let url = params.parse_with_url(&url);
8526
8527 loop {
8528 let token = match self
8529 .hub
8530 .auth
8531 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8532 .await
8533 {
8534 Ok(token) => token,
8535 Err(e) => match dlg.token(e) {
8536 Ok(token) => token,
8537 Err(e) => {
8538 dlg.finished(false);
8539 return Err(common::Error::MissingToken(e));
8540 }
8541 },
8542 };
8543 let mut req_result = {
8544 let client = &self.hub.client;
8545 dlg.pre_request();
8546 let mut req_builder = hyper::Request::builder()
8547 .method(hyper::Method::GET)
8548 .uri(url.as_str())
8549 .header(USER_AGENT, self.hub._user_agent.clone());
8550
8551 if let Some(token) = token.as_ref() {
8552 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8553 }
8554
8555 let request = req_builder
8556 .header(CONTENT_LENGTH, 0_u64)
8557 .body(common::to_body::<String>(None));
8558
8559 client.request(request.unwrap()).await
8560 };
8561
8562 match req_result {
8563 Err(err) => {
8564 if let common::Retry::After(d) = dlg.http_error(&err) {
8565 sleep(d).await;
8566 continue;
8567 }
8568 dlg.finished(false);
8569 return Err(common::Error::HttpError(err));
8570 }
8571 Ok(res) => {
8572 let (mut parts, body) = res.into_parts();
8573 let mut body = common::Body::new(body);
8574 if !parts.status.is_success() {
8575 let bytes = common::to_bytes(body).await.unwrap_or_default();
8576 let error = serde_json::from_str(&common::to_string(&bytes));
8577 let response = common::to_response(parts, bytes.into());
8578
8579 if let common::Retry::After(d) =
8580 dlg.http_failure(&response, error.as_ref().ok())
8581 {
8582 sleep(d).await;
8583 continue;
8584 }
8585
8586 dlg.finished(false);
8587
8588 return Err(match error {
8589 Ok(value) => common::Error::BadRequest(value),
8590 _ => common::Error::Failure(response),
8591 });
8592 }
8593 let response = {
8594 let bytes = common::to_bytes(body).await.unwrap_or_default();
8595 let encoded = common::to_string(&bytes);
8596 match serde_json::from_str(&encoded) {
8597 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8598 Err(error) => {
8599 dlg.response_json_decode_error(&encoded, &error);
8600 return Err(common::Error::JsonDecodeError(
8601 encoded.to_string(),
8602 error,
8603 ));
8604 }
8605 }
8606 };
8607
8608 dlg.finished(true);
8609 return Ok(response);
8610 }
8611 }
8612 }
8613 }
8614
8615 /// Required. The enterprise which the migration tokens belong to. Format: enterprises/{enterprise}
8616 ///
8617 /// Sets the *parent* path property to the given value.
8618 ///
8619 /// Even though the property as already been set when instantiating this call,
8620 /// we provide this method for API completeness.
8621 pub fn parent(mut self, new_value: &str) -> EnterpriseMigrationTokenListCall<'a, C> {
8622 self._parent = new_value.to_string();
8623 self
8624 }
8625 /// A page token, received from a previous ListMigrationTokens call. Provide this to retrieve the subsequent page.When paginating, all other parameters provided to ListMigrationTokens must match the call that provided the page token.
8626 ///
8627 /// Sets the *page token* query property to the given value.
8628 pub fn page_token(mut self, new_value: &str) -> EnterpriseMigrationTokenListCall<'a, C> {
8629 self._page_token = Some(new_value.to_string());
8630 self
8631 }
8632 /// The maximum number of migration tokens to return. Fewer migration tokens may be returned. If unspecified, at most 100 migration tokens will be returned. The maximum value is 100; values above 100 will be coerced to 100.
8633 ///
8634 /// Sets the *page size* query property to the given value.
8635 pub fn page_size(mut self, new_value: i32) -> EnterpriseMigrationTokenListCall<'a, C> {
8636 self._page_size = Some(new_value);
8637 self
8638 }
8639 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8640 /// while executing the actual API request.
8641 ///
8642 /// ````text
8643 /// It should be used to handle progress information, and to implement a certain level of resilience.
8644 /// ````
8645 ///
8646 /// Sets the *delegate* property to the given value.
8647 pub fn delegate(
8648 mut self,
8649 new_value: &'a mut dyn common::Delegate,
8650 ) -> EnterpriseMigrationTokenListCall<'a, C> {
8651 self._delegate = Some(new_value);
8652 self
8653 }
8654
8655 /// Set any additional parameter of the query string used in the request.
8656 /// It should be used to set parameters which are not yet available through their own
8657 /// setters.
8658 ///
8659 /// Please note that this method must not be used to set any of the known parameters
8660 /// which have their own setter method. If done anyway, the request will fail.
8661 ///
8662 /// # Additional Parameters
8663 ///
8664 /// * *$.xgafv* (query-string) - V1 error format.
8665 /// * *access_token* (query-string) - OAuth access token.
8666 /// * *alt* (query-string) - Data format for response.
8667 /// * *callback* (query-string) - JSONP
8668 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8669 /// * *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.
8670 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8671 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8672 /// * *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.
8673 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8674 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8675 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseMigrationTokenListCall<'a, C>
8676 where
8677 T: AsRef<str>,
8678 {
8679 self._additional_params
8680 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8681 self
8682 }
8683
8684 /// Identifies the authorization scope for the method you are building.
8685 ///
8686 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8687 /// [`Scope::Full`].
8688 ///
8689 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8690 /// tokens for more than one scope.
8691 ///
8692 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8693 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8694 /// sufficient, a read-write scope will do as well.
8695 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseMigrationTokenListCall<'a, C>
8696 where
8697 St: AsRef<str>,
8698 {
8699 self._scopes.insert(String::from(scope.as_ref()));
8700 self
8701 }
8702 /// Identifies the authorization scope(s) for the method you are building.
8703 ///
8704 /// See [`Self::add_scope()`] for details.
8705 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseMigrationTokenListCall<'a, C>
8706 where
8707 I: IntoIterator<Item = St>,
8708 St: AsRef<str>,
8709 {
8710 self._scopes
8711 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8712 self
8713 }
8714
8715 /// Removes all scopes, and no default scope will be used either.
8716 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8717 /// for details).
8718 pub fn clear_scopes(mut self) -> EnterpriseMigrationTokenListCall<'a, C> {
8719 self._scopes.clear();
8720 self
8721 }
8722}
8723
8724/// Deletes a policy. This operation is only permitted if no devices are currently referencing the policy.
8725///
8726/// A builder for the *policies.delete* method supported by a *enterprise* resource.
8727/// It is not used directly, but through a [`EnterpriseMethods`] instance.
8728///
8729/// # Example
8730///
8731/// Instantiate a resource method builder
8732///
8733/// ```test_harness,no_run
8734/// # extern crate hyper;
8735/// # extern crate hyper_rustls;
8736/// # extern crate google_androidmanagement1 as androidmanagement1;
8737/// # async fn dox() {
8738/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8739///
8740/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8741/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8742/// # secret,
8743/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8744/// # ).build().await.unwrap();
8745///
8746/// # let client = hyper_util::client::legacy::Client::builder(
8747/// # hyper_util::rt::TokioExecutor::new()
8748/// # )
8749/// # .build(
8750/// # hyper_rustls::HttpsConnectorBuilder::new()
8751/// # .with_native_roots()
8752/// # .unwrap()
8753/// # .https_or_http()
8754/// # .enable_http1()
8755/// # .build()
8756/// # );
8757/// # let mut hub = AndroidManagement::new(client, auth);
8758/// // You can configure optional parameters by calling the respective setters at will, and
8759/// // execute the final call using `doit()`.
8760/// // Values shown here are possibly random and not representative !
8761/// let result = hub.enterprises().policies_delete("name")
8762/// .doit().await;
8763/// # }
8764/// ```
8765pub struct EnterprisePolicyDeleteCall<'a, C>
8766where
8767 C: 'a,
8768{
8769 hub: &'a AndroidManagement<C>,
8770 _name: String,
8771 _delegate: Option<&'a mut dyn common::Delegate>,
8772 _additional_params: HashMap<String, String>,
8773 _scopes: BTreeSet<String>,
8774}
8775
8776impl<'a, C> common::CallBuilder for EnterprisePolicyDeleteCall<'a, C> {}
8777
8778impl<'a, C> EnterprisePolicyDeleteCall<'a, C>
8779where
8780 C: common::Connector,
8781{
8782 /// Perform the operation you have build so far.
8783 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8784 use std::borrow::Cow;
8785 use std::io::{Read, Seek};
8786
8787 use common::{url::Params, ToParts};
8788 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8789
8790 let mut dd = common::DefaultDelegate;
8791 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8792 dlg.begin(common::MethodInfo {
8793 id: "androidmanagement.enterprises.policies.delete",
8794 http_method: hyper::Method::DELETE,
8795 });
8796
8797 for &field in ["alt", "name"].iter() {
8798 if self._additional_params.contains_key(field) {
8799 dlg.finished(false);
8800 return Err(common::Error::FieldClash(field));
8801 }
8802 }
8803
8804 let mut params = Params::with_capacity(3 + self._additional_params.len());
8805 params.push("name", self._name);
8806
8807 params.extend(self._additional_params.iter());
8808
8809 params.push("alt", "json");
8810 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8811 if self._scopes.is_empty() {
8812 self._scopes.insert(Scope::Full.as_ref().to_string());
8813 }
8814
8815 #[allow(clippy::single_element_loop)]
8816 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8817 url = params.uri_replacement(url, param_name, find_this, true);
8818 }
8819 {
8820 let to_remove = ["name"];
8821 params.remove_params(&to_remove);
8822 }
8823
8824 let url = params.parse_with_url(&url);
8825
8826 loop {
8827 let token = match self
8828 .hub
8829 .auth
8830 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8831 .await
8832 {
8833 Ok(token) => token,
8834 Err(e) => match dlg.token(e) {
8835 Ok(token) => token,
8836 Err(e) => {
8837 dlg.finished(false);
8838 return Err(common::Error::MissingToken(e));
8839 }
8840 },
8841 };
8842 let mut req_result = {
8843 let client = &self.hub.client;
8844 dlg.pre_request();
8845 let mut req_builder = hyper::Request::builder()
8846 .method(hyper::Method::DELETE)
8847 .uri(url.as_str())
8848 .header(USER_AGENT, self.hub._user_agent.clone());
8849
8850 if let Some(token) = token.as_ref() {
8851 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8852 }
8853
8854 let request = req_builder
8855 .header(CONTENT_LENGTH, 0_u64)
8856 .body(common::to_body::<String>(None));
8857
8858 client.request(request.unwrap()).await
8859 };
8860
8861 match req_result {
8862 Err(err) => {
8863 if let common::Retry::After(d) = dlg.http_error(&err) {
8864 sleep(d).await;
8865 continue;
8866 }
8867 dlg.finished(false);
8868 return Err(common::Error::HttpError(err));
8869 }
8870 Ok(res) => {
8871 let (mut parts, body) = res.into_parts();
8872 let mut body = common::Body::new(body);
8873 if !parts.status.is_success() {
8874 let bytes = common::to_bytes(body).await.unwrap_or_default();
8875 let error = serde_json::from_str(&common::to_string(&bytes));
8876 let response = common::to_response(parts, bytes.into());
8877
8878 if let common::Retry::After(d) =
8879 dlg.http_failure(&response, error.as_ref().ok())
8880 {
8881 sleep(d).await;
8882 continue;
8883 }
8884
8885 dlg.finished(false);
8886
8887 return Err(match error {
8888 Ok(value) => common::Error::BadRequest(value),
8889 _ => common::Error::Failure(response),
8890 });
8891 }
8892 let response = {
8893 let bytes = common::to_bytes(body).await.unwrap_or_default();
8894 let encoded = common::to_string(&bytes);
8895 match serde_json::from_str(&encoded) {
8896 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8897 Err(error) => {
8898 dlg.response_json_decode_error(&encoded, &error);
8899 return Err(common::Error::JsonDecodeError(
8900 encoded.to_string(),
8901 error,
8902 ));
8903 }
8904 }
8905 };
8906
8907 dlg.finished(true);
8908 return Ok(response);
8909 }
8910 }
8911 }
8912 }
8913
8914 /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}.
8915 ///
8916 /// Sets the *name* path property to the given value.
8917 ///
8918 /// Even though the property as already been set when instantiating this call,
8919 /// we provide this method for API completeness.
8920 pub fn name(mut self, new_value: &str) -> EnterprisePolicyDeleteCall<'a, C> {
8921 self._name = new_value.to_string();
8922 self
8923 }
8924 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8925 /// while executing the actual API request.
8926 ///
8927 /// ````text
8928 /// It should be used to handle progress information, and to implement a certain level of resilience.
8929 /// ````
8930 ///
8931 /// Sets the *delegate* property to the given value.
8932 pub fn delegate(
8933 mut self,
8934 new_value: &'a mut dyn common::Delegate,
8935 ) -> EnterprisePolicyDeleteCall<'a, C> {
8936 self._delegate = Some(new_value);
8937 self
8938 }
8939
8940 /// Set any additional parameter of the query string used in the request.
8941 /// It should be used to set parameters which are not yet available through their own
8942 /// setters.
8943 ///
8944 /// Please note that this method must not be used to set any of the known parameters
8945 /// which have their own setter method. If done anyway, the request will fail.
8946 ///
8947 /// # Additional Parameters
8948 ///
8949 /// * *$.xgafv* (query-string) - V1 error format.
8950 /// * *access_token* (query-string) - OAuth access token.
8951 /// * *alt* (query-string) - Data format for response.
8952 /// * *callback* (query-string) - JSONP
8953 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8954 /// * *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.
8955 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8956 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8957 /// * *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.
8958 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8959 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8960 pub fn param<T>(mut self, name: T, value: T) -> EnterprisePolicyDeleteCall<'a, C>
8961 where
8962 T: AsRef<str>,
8963 {
8964 self._additional_params
8965 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8966 self
8967 }
8968
8969 /// Identifies the authorization scope for the method you are building.
8970 ///
8971 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8972 /// [`Scope::Full`].
8973 ///
8974 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8975 /// tokens for more than one scope.
8976 ///
8977 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8978 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8979 /// sufficient, a read-write scope will do as well.
8980 pub fn add_scope<St>(mut self, scope: St) -> EnterprisePolicyDeleteCall<'a, C>
8981 where
8982 St: AsRef<str>,
8983 {
8984 self._scopes.insert(String::from(scope.as_ref()));
8985 self
8986 }
8987 /// Identifies the authorization scope(s) for the method you are building.
8988 ///
8989 /// See [`Self::add_scope()`] for details.
8990 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterprisePolicyDeleteCall<'a, C>
8991 where
8992 I: IntoIterator<Item = St>,
8993 St: AsRef<str>,
8994 {
8995 self._scopes
8996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8997 self
8998 }
8999
9000 /// Removes all scopes, and no default scope will be used either.
9001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9002 /// for details).
9003 pub fn clear_scopes(mut self) -> EnterprisePolicyDeleteCall<'a, C> {
9004 self._scopes.clear();
9005 self
9006 }
9007}
9008
9009/// Gets a policy.
9010///
9011/// A builder for the *policies.get* method supported by a *enterprise* resource.
9012/// It is not used directly, but through a [`EnterpriseMethods`] instance.
9013///
9014/// # Example
9015///
9016/// Instantiate a resource method builder
9017///
9018/// ```test_harness,no_run
9019/// # extern crate hyper;
9020/// # extern crate hyper_rustls;
9021/// # extern crate google_androidmanagement1 as androidmanagement1;
9022/// # async fn dox() {
9023/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9024///
9025/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9026/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9027/// # secret,
9028/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9029/// # ).build().await.unwrap();
9030///
9031/// # let client = hyper_util::client::legacy::Client::builder(
9032/// # hyper_util::rt::TokioExecutor::new()
9033/// # )
9034/// # .build(
9035/// # hyper_rustls::HttpsConnectorBuilder::new()
9036/// # .with_native_roots()
9037/// # .unwrap()
9038/// # .https_or_http()
9039/// # .enable_http1()
9040/// # .build()
9041/// # );
9042/// # let mut hub = AndroidManagement::new(client, auth);
9043/// // You can configure optional parameters by calling the respective setters at will, and
9044/// // execute the final call using `doit()`.
9045/// // Values shown here are possibly random and not representative !
9046/// let result = hub.enterprises().policies_get("name")
9047/// .doit().await;
9048/// # }
9049/// ```
9050pub struct EnterprisePolicyGetCall<'a, C>
9051where
9052 C: 'a,
9053{
9054 hub: &'a AndroidManagement<C>,
9055 _name: String,
9056 _delegate: Option<&'a mut dyn common::Delegate>,
9057 _additional_params: HashMap<String, String>,
9058 _scopes: BTreeSet<String>,
9059}
9060
9061impl<'a, C> common::CallBuilder for EnterprisePolicyGetCall<'a, C> {}
9062
9063impl<'a, C> EnterprisePolicyGetCall<'a, C>
9064where
9065 C: common::Connector,
9066{
9067 /// Perform the operation you have build so far.
9068 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9069 use std::borrow::Cow;
9070 use std::io::{Read, Seek};
9071
9072 use common::{url::Params, ToParts};
9073 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9074
9075 let mut dd = common::DefaultDelegate;
9076 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9077 dlg.begin(common::MethodInfo {
9078 id: "androidmanagement.enterprises.policies.get",
9079 http_method: hyper::Method::GET,
9080 });
9081
9082 for &field in ["alt", "name"].iter() {
9083 if self._additional_params.contains_key(field) {
9084 dlg.finished(false);
9085 return Err(common::Error::FieldClash(field));
9086 }
9087 }
9088
9089 let mut params = Params::with_capacity(3 + self._additional_params.len());
9090 params.push("name", self._name);
9091
9092 params.extend(self._additional_params.iter());
9093
9094 params.push("alt", "json");
9095 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9096 if self._scopes.is_empty() {
9097 self._scopes.insert(Scope::Full.as_ref().to_string());
9098 }
9099
9100 #[allow(clippy::single_element_loop)]
9101 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9102 url = params.uri_replacement(url, param_name, find_this, true);
9103 }
9104 {
9105 let to_remove = ["name"];
9106 params.remove_params(&to_remove);
9107 }
9108
9109 let url = params.parse_with_url(&url);
9110
9111 loop {
9112 let token = match self
9113 .hub
9114 .auth
9115 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9116 .await
9117 {
9118 Ok(token) => token,
9119 Err(e) => match dlg.token(e) {
9120 Ok(token) => token,
9121 Err(e) => {
9122 dlg.finished(false);
9123 return Err(common::Error::MissingToken(e));
9124 }
9125 },
9126 };
9127 let mut req_result = {
9128 let client = &self.hub.client;
9129 dlg.pre_request();
9130 let mut req_builder = hyper::Request::builder()
9131 .method(hyper::Method::GET)
9132 .uri(url.as_str())
9133 .header(USER_AGENT, self.hub._user_agent.clone());
9134
9135 if let Some(token) = token.as_ref() {
9136 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9137 }
9138
9139 let request = req_builder
9140 .header(CONTENT_LENGTH, 0_u64)
9141 .body(common::to_body::<String>(None));
9142
9143 client.request(request.unwrap()).await
9144 };
9145
9146 match req_result {
9147 Err(err) => {
9148 if let common::Retry::After(d) = dlg.http_error(&err) {
9149 sleep(d).await;
9150 continue;
9151 }
9152 dlg.finished(false);
9153 return Err(common::Error::HttpError(err));
9154 }
9155 Ok(res) => {
9156 let (mut parts, body) = res.into_parts();
9157 let mut body = common::Body::new(body);
9158 if !parts.status.is_success() {
9159 let bytes = common::to_bytes(body).await.unwrap_or_default();
9160 let error = serde_json::from_str(&common::to_string(&bytes));
9161 let response = common::to_response(parts, bytes.into());
9162
9163 if let common::Retry::After(d) =
9164 dlg.http_failure(&response, error.as_ref().ok())
9165 {
9166 sleep(d).await;
9167 continue;
9168 }
9169
9170 dlg.finished(false);
9171
9172 return Err(match error {
9173 Ok(value) => common::Error::BadRequest(value),
9174 _ => common::Error::Failure(response),
9175 });
9176 }
9177 let response = {
9178 let bytes = common::to_bytes(body).await.unwrap_or_default();
9179 let encoded = common::to_string(&bytes);
9180 match serde_json::from_str(&encoded) {
9181 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9182 Err(error) => {
9183 dlg.response_json_decode_error(&encoded, &error);
9184 return Err(common::Error::JsonDecodeError(
9185 encoded.to_string(),
9186 error,
9187 ));
9188 }
9189 }
9190 };
9191
9192 dlg.finished(true);
9193 return Ok(response);
9194 }
9195 }
9196 }
9197 }
9198
9199 /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}.
9200 ///
9201 /// Sets the *name* path property to the given value.
9202 ///
9203 /// Even though the property as already been set when instantiating this call,
9204 /// we provide this method for API completeness.
9205 pub fn name(mut self, new_value: &str) -> EnterprisePolicyGetCall<'a, C> {
9206 self._name = new_value.to_string();
9207 self
9208 }
9209 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9210 /// while executing the actual API request.
9211 ///
9212 /// ````text
9213 /// It should be used to handle progress information, and to implement a certain level of resilience.
9214 /// ````
9215 ///
9216 /// Sets the *delegate* property to the given value.
9217 pub fn delegate(
9218 mut self,
9219 new_value: &'a mut dyn common::Delegate,
9220 ) -> EnterprisePolicyGetCall<'a, C> {
9221 self._delegate = Some(new_value);
9222 self
9223 }
9224
9225 /// Set any additional parameter of the query string used in the request.
9226 /// It should be used to set parameters which are not yet available through their own
9227 /// setters.
9228 ///
9229 /// Please note that this method must not be used to set any of the known parameters
9230 /// which have their own setter method. If done anyway, the request will fail.
9231 ///
9232 /// # Additional Parameters
9233 ///
9234 /// * *$.xgafv* (query-string) - V1 error format.
9235 /// * *access_token* (query-string) - OAuth access token.
9236 /// * *alt* (query-string) - Data format for response.
9237 /// * *callback* (query-string) - JSONP
9238 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9239 /// * *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.
9240 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9241 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9242 /// * *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.
9243 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9244 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9245 pub fn param<T>(mut self, name: T, value: T) -> EnterprisePolicyGetCall<'a, C>
9246 where
9247 T: AsRef<str>,
9248 {
9249 self._additional_params
9250 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9251 self
9252 }
9253
9254 /// Identifies the authorization scope for the method you are building.
9255 ///
9256 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9257 /// [`Scope::Full`].
9258 ///
9259 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9260 /// tokens for more than one scope.
9261 ///
9262 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9263 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9264 /// sufficient, a read-write scope will do as well.
9265 pub fn add_scope<St>(mut self, scope: St) -> EnterprisePolicyGetCall<'a, C>
9266 where
9267 St: AsRef<str>,
9268 {
9269 self._scopes.insert(String::from(scope.as_ref()));
9270 self
9271 }
9272 /// Identifies the authorization scope(s) for the method you are building.
9273 ///
9274 /// See [`Self::add_scope()`] for details.
9275 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterprisePolicyGetCall<'a, C>
9276 where
9277 I: IntoIterator<Item = St>,
9278 St: AsRef<str>,
9279 {
9280 self._scopes
9281 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9282 self
9283 }
9284
9285 /// Removes all scopes, and no default scope will be used either.
9286 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9287 /// for details).
9288 pub fn clear_scopes(mut self) -> EnterprisePolicyGetCall<'a, C> {
9289 self._scopes.clear();
9290 self
9291 }
9292}
9293
9294/// Lists policies for a given enterprise.
9295///
9296/// A builder for the *policies.list* method supported by a *enterprise* resource.
9297/// It is not used directly, but through a [`EnterpriseMethods`] instance.
9298///
9299/// # Example
9300///
9301/// Instantiate a resource method builder
9302///
9303/// ```test_harness,no_run
9304/// # extern crate hyper;
9305/// # extern crate hyper_rustls;
9306/// # extern crate google_androidmanagement1 as androidmanagement1;
9307/// # async fn dox() {
9308/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9309///
9310/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9311/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9312/// # secret,
9313/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9314/// # ).build().await.unwrap();
9315///
9316/// # let client = hyper_util::client::legacy::Client::builder(
9317/// # hyper_util::rt::TokioExecutor::new()
9318/// # )
9319/// # .build(
9320/// # hyper_rustls::HttpsConnectorBuilder::new()
9321/// # .with_native_roots()
9322/// # .unwrap()
9323/// # .https_or_http()
9324/// # .enable_http1()
9325/// # .build()
9326/// # );
9327/// # let mut hub = AndroidManagement::new(client, auth);
9328/// // You can configure optional parameters by calling the respective setters at will, and
9329/// // execute the final call using `doit()`.
9330/// // Values shown here are possibly random and not representative !
9331/// let result = hub.enterprises().policies_list("parent")
9332/// .page_token("et")
9333/// .page_size(-43)
9334/// .doit().await;
9335/// # }
9336/// ```
9337pub struct EnterprisePolicyListCall<'a, C>
9338where
9339 C: 'a,
9340{
9341 hub: &'a AndroidManagement<C>,
9342 _parent: String,
9343 _page_token: Option<String>,
9344 _page_size: Option<i32>,
9345 _delegate: Option<&'a mut dyn common::Delegate>,
9346 _additional_params: HashMap<String, String>,
9347 _scopes: BTreeSet<String>,
9348}
9349
9350impl<'a, C> common::CallBuilder for EnterprisePolicyListCall<'a, C> {}
9351
9352impl<'a, C> EnterprisePolicyListCall<'a, C>
9353where
9354 C: common::Connector,
9355{
9356 /// Perform the operation you have build so far.
9357 pub async fn doit(mut self) -> common::Result<(common::Response, ListPoliciesResponse)> {
9358 use std::borrow::Cow;
9359 use std::io::{Read, Seek};
9360
9361 use common::{url::Params, ToParts};
9362 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9363
9364 let mut dd = common::DefaultDelegate;
9365 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9366 dlg.begin(common::MethodInfo {
9367 id: "androidmanagement.enterprises.policies.list",
9368 http_method: hyper::Method::GET,
9369 });
9370
9371 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9372 if self._additional_params.contains_key(field) {
9373 dlg.finished(false);
9374 return Err(common::Error::FieldClash(field));
9375 }
9376 }
9377
9378 let mut params = Params::with_capacity(5 + self._additional_params.len());
9379 params.push("parent", self._parent);
9380 if let Some(value) = self._page_token.as_ref() {
9381 params.push("pageToken", value);
9382 }
9383 if let Some(value) = self._page_size.as_ref() {
9384 params.push("pageSize", value.to_string());
9385 }
9386
9387 params.extend(self._additional_params.iter());
9388
9389 params.push("alt", "json");
9390 let mut url = self.hub._base_url.clone() + "v1/{+parent}/policies";
9391 if self._scopes.is_empty() {
9392 self._scopes.insert(Scope::Full.as_ref().to_string());
9393 }
9394
9395 #[allow(clippy::single_element_loop)]
9396 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9397 url = params.uri_replacement(url, param_name, find_this, true);
9398 }
9399 {
9400 let to_remove = ["parent"];
9401 params.remove_params(&to_remove);
9402 }
9403
9404 let url = params.parse_with_url(&url);
9405
9406 loop {
9407 let token = match self
9408 .hub
9409 .auth
9410 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9411 .await
9412 {
9413 Ok(token) => token,
9414 Err(e) => match dlg.token(e) {
9415 Ok(token) => token,
9416 Err(e) => {
9417 dlg.finished(false);
9418 return Err(common::Error::MissingToken(e));
9419 }
9420 },
9421 };
9422 let mut req_result = {
9423 let client = &self.hub.client;
9424 dlg.pre_request();
9425 let mut req_builder = hyper::Request::builder()
9426 .method(hyper::Method::GET)
9427 .uri(url.as_str())
9428 .header(USER_AGENT, self.hub._user_agent.clone());
9429
9430 if let Some(token) = token.as_ref() {
9431 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9432 }
9433
9434 let request = req_builder
9435 .header(CONTENT_LENGTH, 0_u64)
9436 .body(common::to_body::<String>(None));
9437
9438 client.request(request.unwrap()).await
9439 };
9440
9441 match req_result {
9442 Err(err) => {
9443 if let common::Retry::After(d) = dlg.http_error(&err) {
9444 sleep(d).await;
9445 continue;
9446 }
9447 dlg.finished(false);
9448 return Err(common::Error::HttpError(err));
9449 }
9450 Ok(res) => {
9451 let (mut parts, body) = res.into_parts();
9452 let mut body = common::Body::new(body);
9453 if !parts.status.is_success() {
9454 let bytes = common::to_bytes(body).await.unwrap_or_default();
9455 let error = serde_json::from_str(&common::to_string(&bytes));
9456 let response = common::to_response(parts, bytes.into());
9457
9458 if let common::Retry::After(d) =
9459 dlg.http_failure(&response, error.as_ref().ok())
9460 {
9461 sleep(d).await;
9462 continue;
9463 }
9464
9465 dlg.finished(false);
9466
9467 return Err(match error {
9468 Ok(value) => common::Error::BadRequest(value),
9469 _ => common::Error::Failure(response),
9470 });
9471 }
9472 let response = {
9473 let bytes = common::to_bytes(body).await.unwrap_or_default();
9474 let encoded = common::to_string(&bytes);
9475 match serde_json::from_str(&encoded) {
9476 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9477 Err(error) => {
9478 dlg.response_json_decode_error(&encoded, &error);
9479 return Err(common::Error::JsonDecodeError(
9480 encoded.to_string(),
9481 error,
9482 ));
9483 }
9484 }
9485 };
9486
9487 dlg.finished(true);
9488 return Ok(response);
9489 }
9490 }
9491 }
9492 }
9493
9494 /// The name of the enterprise in the form enterprises/{enterpriseId}.
9495 ///
9496 /// Sets the *parent* path property to the given value.
9497 ///
9498 /// Even though the property as already been set when instantiating this call,
9499 /// we provide this method for API completeness.
9500 pub fn parent(mut self, new_value: &str) -> EnterprisePolicyListCall<'a, C> {
9501 self._parent = new_value.to_string();
9502 self
9503 }
9504 /// A token identifying a page of results returned by the server.
9505 ///
9506 /// Sets the *page token* query property to the given value.
9507 pub fn page_token(mut self, new_value: &str) -> EnterprisePolicyListCall<'a, C> {
9508 self._page_token = Some(new_value.to_string());
9509 self
9510 }
9511 /// The requested page size. The actual page size may be fixed to a min or max value.
9512 ///
9513 /// Sets the *page size* query property to the given value.
9514 pub fn page_size(mut self, new_value: i32) -> EnterprisePolicyListCall<'a, C> {
9515 self._page_size = Some(new_value);
9516 self
9517 }
9518 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9519 /// while executing the actual API request.
9520 ///
9521 /// ````text
9522 /// It should be used to handle progress information, and to implement a certain level of resilience.
9523 /// ````
9524 ///
9525 /// Sets the *delegate* property to the given value.
9526 pub fn delegate(
9527 mut self,
9528 new_value: &'a mut dyn common::Delegate,
9529 ) -> EnterprisePolicyListCall<'a, C> {
9530 self._delegate = Some(new_value);
9531 self
9532 }
9533
9534 /// Set any additional parameter of the query string used in the request.
9535 /// It should be used to set parameters which are not yet available through their own
9536 /// setters.
9537 ///
9538 /// Please note that this method must not be used to set any of the known parameters
9539 /// which have their own setter method. If done anyway, the request will fail.
9540 ///
9541 /// # Additional Parameters
9542 ///
9543 /// * *$.xgafv* (query-string) - V1 error format.
9544 /// * *access_token* (query-string) - OAuth access token.
9545 /// * *alt* (query-string) - Data format for response.
9546 /// * *callback* (query-string) - JSONP
9547 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9548 /// * *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.
9549 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9550 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9551 /// * *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.
9552 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9553 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9554 pub fn param<T>(mut self, name: T, value: T) -> EnterprisePolicyListCall<'a, C>
9555 where
9556 T: AsRef<str>,
9557 {
9558 self._additional_params
9559 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9560 self
9561 }
9562
9563 /// Identifies the authorization scope for the method you are building.
9564 ///
9565 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9566 /// [`Scope::Full`].
9567 ///
9568 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9569 /// tokens for more than one scope.
9570 ///
9571 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9572 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9573 /// sufficient, a read-write scope will do as well.
9574 pub fn add_scope<St>(mut self, scope: St) -> EnterprisePolicyListCall<'a, C>
9575 where
9576 St: AsRef<str>,
9577 {
9578 self._scopes.insert(String::from(scope.as_ref()));
9579 self
9580 }
9581 /// Identifies the authorization scope(s) for the method you are building.
9582 ///
9583 /// See [`Self::add_scope()`] for details.
9584 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterprisePolicyListCall<'a, C>
9585 where
9586 I: IntoIterator<Item = St>,
9587 St: AsRef<str>,
9588 {
9589 self._scopes
9590 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9591 self
9592 }
9593
9594 /// Removes all scopes, and no default scope will be used either.
9595 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9596 /// for details).
9597 pub fn clear_scopes(mut self) -> EnterprisePolicyListCall<'a, C> {
9598 self._scopes.clear();
9599 self
9600 }
9601}
9602
9603/// Updates or creates a policy.
9604///
9605/// A builder for the *policies.patch* method supported by a *enterprise* resource.
9606/// It is not used directly, but through a [`EnterpriseMethods`] instance.
9607///
9608/// # Example
9609///
9610/// Instantiate a resource method builder
9611///
9612/// ```test_harness,no_run
9613/// # extern crate hyper;
9614/// # extern crate hyper_rustls;
9615/// # extern crate google_androidmanagement1 as androidmanagement1;
9616/// use androidmanagement1::api::Policy;
9617/// # async fn dox() {
9618/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9619///
9620/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9622/// # secret,
9623/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9624/// # ).build().await.unwrap();
9625///
9626/// # let client = hyper_util::client::legacy::Client::builder(
9627/// # hyper_util::rt::TokioExecutor::new()
9628/// # )
9629/// # .build(
9630/// # hyper_rustls::HttpsConnectorBuilder::new()
9631/// # .with_native_roots()
9632/// # .unwrap()
9633/// # .https_or_http()
9634/// # .enable_http1()
9635/// # .build()
9636/// # );
9637/// # let mut hub = AndroidManagement::new(client, auth);
9638/// // As the method needs a request, you would usually fill it with the desired information
9639/// // into the respective structure. Some of the parts shown here might not be applicable !
9640/// // Values shown here are possibly random and not representative !
9641/// let mut req = Policy::default();
9642///
9643/// // You can configure optional parameters by calling the respective setters at will, and
9644/// // execute the final call using `doit()`.
9645/// // Values shown here are possibly random and not representative !
9646/// let result = hub.enterprises().policies_patch(req, "name")
9647/// .update_mask(FieldMask::new::<&str>(&[]))
9648/// .doit().await;
9649/// # }
9650/// ```
9651pub struct EnterprisePolicyPatchCall<'a, C>
9652where
9653 C: 'a,
9654{
9655 hub: &'a AndroidManagement<C>,
9656 _request: Policy,
9657 _name: String,
9658 _update_mask: Option<common::FieldMask>,
9659 _delegate: Option<&'a mut dyn common::Delegate>,
9660 _additional_params: HashMap<String, String>,
9661 _scopes: BTreeSet<String>,
9662}
9663
9664impl<'a, C> common::CallBuilder for EnterprisePolicyPatchCall<'a, C> {}
9665
9666impl<'a, C> EnterprisePolicyPatchCall<'a, C>
9667where
9668 C: common::Connector,
9669{
9670 /// Perform the operation you have build so far.
9671 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9672 use std::borrow::Cow;
9673 use std::io::{Read, Seek};
9674
9675 use common::{url::Params, ToParts};
9676 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9677
9678 let mut dd = common::DefaultDelegate;
9679 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9680 dlg.begin(common::MethodInfo {
9681 id: "androidmanagement.enterprises.policies.patch",
9682 http_method: hyper::Method::PATCH,
9683 });
9684
9685 for &field in ["alt", "name", "updateMask"].iter() {
9686 if self._additional_params.contains_key(field) {
9687 dlg.finished(false);
9688 return Err(common::Error::FieldClash(field));
9689 }
9690 }
9691
9692 let mut params = Params::with_capacity(5 + self._additional_params.len());
9693 params.push("name", self._name);
9694 if let Some(value) = self._update_mask.as_ref() {
9695 params.push("updateMask", value.to_string());
9696 }
9697
9698 params.extend(self._additional_params.iter());
9699
9700 params.push("alt", "json");
9701 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9702 if self._scopes.is_empty() {
9703 self._scopes.insert(Scope::Full.as_ref().to_string());
9704 }
9705
9706 #[allow(clippy::single_element_loop)]
9707 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9708 url = params.uri_replacement(url, param_name, find_this, true);
9709 }
9710 {
9711 let to_remove = ["name"];
9712 params.remove_params(&to_remove);
9713 }
9714
9715 let url = params.parse_with_url(&url);
9716
9717 let mut json_mime_type = mime::APPLICATION_JSON;
9718 let mut request_value_reader = {
9719 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9720 common::remove_json_null_values(&mut value);
9721 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9722 serde_json::to_writer(&mut dst, &value).unwrap();
9723 dst
9724 };
9725 let request_size = request_value_reader
9726 .seek(std::io::SeekFrom::End(0))
9727 .unwrap();
9728 request_value_reader
9729 .seek(std::io::SeekFrom::Start(0))
9730 .unwrap();
9731
9732 loop {
9733 let token = match self
9734 .hub
9735 .auth
9736 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9737 .await
9738 {
9739 Ok(token) => token,
9740 Err(e) => match dlg.token(e) {
9741 Ok(token) => token,
9742 Err(e) => {
9743 dlg.finished(false);
9744 return Err(common::Error::MissingToken(e));
9745 }
9746 },
9747 };
9748 request_value_reader
9749 .seek(std::io::SeekFrom::Start(0))
9750 .unwrap();
9751 let mut req_result = {
9752 let client = &self.hub.client;
9753 dlg.pre_request();
9754 let mut req_builder = hyper::Request::builder()
9755 .method(hyper::Method::PATCH)
9756 .uri(url.as_str())
9757 .header(USER_AGENT, self.hub._user_agent.clone());
9758
9759 if let Some(token) = token.as_ref() {
9760 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9761 }
9762
9763 let request = req_builder
9764 .header(CONTENT_TYPE, json_mime_type.to_string())
9765 .header(CONTENT_LENGTH, request_size as u64)
9766 .body(common::to_body(
9767 request_value_reader.get_ref().clone().into(),
9768 ));
9769
9770 client.request(request.unwrap()).await
9771 };
9772
9773 match req_result {
9774 Err(err) => {
9775 if let common::Retry::After(d) = dlg.http_error(&err) {
9776 sleep(d).await;
9777 continue;
9778 }
9779 dlg.finished(false);
9780 return Err(common::Error::HttpError(err));
9781 }
9782 Ok(res) => {
9783 let (mut parts, body) = res.into_parts();
9784 let mut body = common::Body::new(body);
9785 if !parts.status.is_success() {
9786 let bytes = common::to_bytes(body).await.unwrap_or_default();
9787 let error = serde_json::from_str(&common::to_string(&bytes));
9788 let response = common::to_response(parts, bytes.into());
9789
9790 if let common::Retry::After(d) =
9791 dlg.http_failure(&response, error.as_ref().ok())
9792 {
9793 sleep(d).await;
9794 continue;
9795 }
9796
9797 dlg.finished(false);
9798
9799 return Err(match error {
9800 Ok(value) => common::Error::BadRequest(value),
9801 _ => common::Error::Failure(response),
9802 });
9803 }
9804 let response = {
9805 let bytes = common::to_bytes(body).await.unwrap_or_default();
9806 let encoded = common::to_string(&bytes);
9807 match serde_json::from_str(&encoded) {
9808 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9809 Err(error) => {
9810 dlg.response_json_decode_error(&encoded, &error);
9811 return Err(common::Error::JsonDecodeError(
9812 encoded.to_string(),
9813 error,
9814 ));
9815 }
9816 }
9817 };
9818
9819 dlg.finished(true);
9820 return Ok(response);
9821 }
9822 }
9823 }
9824 }
9825
9826 ///
9827 /// Sets the *request* property to the given value.
9828 ///
9829 /// Even though the property as already been set when instantiating this call,
9830 /// we provide this method for API completeness.
9831 pub fn request(mut self, new_value: Policy) -> EnterprisePolicyPatchCall<'a, C> {
9832 self._request = new_value;
9833 self
9834 }
9835 /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}.
9836 ///
9837 /// Sets the *name* path property to the given value.
9838 ///
9839 /// Even though the property as already been set when instantiating this call,
9840 /// we provide this method for API completeness.
9841 pub fn name(mut self, new_value: &str) -> EnterprisePolicyPatchCall<'a, C> {
9842 self._name = new_value.to_string();
9843 self
9844 }
9845 /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified.
9846 ///
9847 /// Sets the *update mask* query property to the given value.
9848 pub fn update_mask(mut self, new_value: common::FieldMask) -> EnterprisePolicyPatchCall<'a, C> {
9849 self._update_mask = Some(new_value);
9850 self
9851 }
9852 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9853 /// while executing the actual API request.
9854 ///
9855 /// ````text
9856 /// It should be used to handle progress information, and to implement a certain level of resilience.
9857 /// ````
9858 ///
9859 /// Sets the *delegate* property to the given value.
9860 pub fn delegate(
9861 mut self,
9862 new_value: &'a mut dyn common::Delegate,
9863 ) -> EnterprisePolicyPatchCall<'a, C> {
9864 self._delegate = Some(new_value);
9865 self
9866 }
9867
9868 /// Set any additional parameter of the query string used in the request.
9869 /// It should be used to set parameters which are not yet available through their own
9870 /// setters.
9871 ///
9872 /// Please note that this method must not be used to set any of the known parameters
9873 /// which have their own setter method. If done anyway, the request will fail.
9874 ///
9875 /// # Additional Parameters
9876 ///
9877 /// * *$.xgafv* (query-string) - V1 error format.
9878 /// * *access_token* (query-string) - OAuth access token.
9879 /// * *alt* (query-string) - Data format for response.
9880 /// * *callback* (query-string) - JSONP
9881 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9882 /// * *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.
9883 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9884 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9885 /// * *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.
9886 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9887 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9888 pub fn param<T>(mut self, name: T, value: T) -> EnterprisePolicyPatchCall<'a, C>
9889 where
9890 T: AsRef<str>,
9891 {
9892 self._additional_params
9893 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9894 self
9895 }
9896
9897 /// Identifies the authorization scope for the method you are building.
9898 ///
9899 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9900 /// [`Scope::Full`].
9901 ///
9902 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9903 /// tokens for more than one scope.
9904 ///
9905 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9906 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9907 /// sufficient, a read-write scope will do as well.
9908 pub fn add_scope<St>(mut self, scope: St) -> EnterprisePolicyPatchCall<'a, C>
9909 where
9910 St: AsRef<str>,
9911 {
9912 self._scopes.insert(String::from(scope.as_ref()));
9913 self
9914 }
9915 /// Identifies the authorization scope(s) for the method you are building.
9916 ///
9917 /// See [`Self::add_scope()`] for details.
9918 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterprisePolicyPatchCall<'a, C>
9919 where
9920 I: IntoIterator<Item = St>,
9921 St: AsRef<str>,
9922 {
9923 self._scopes
9924 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9925 self
9926 }
9927
9928 /// Removes all scopes, and no default scope will be used either.
9929 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9930 /// for details).
9931 pub fn clear_scopes(mut self) -> EnterprisePolicyPatchCall<'a, C> {
9932 self._scopes.clear();
9933 self
9934 }
9935}
9936
9937/// Creates a web app.
9938///
9939/// A builder for the *webApps.create* method supported by a *enterprise* resource.
9940/// It is not used directly, but through a [`EnterpriseMethods`] instance.
9941///
9942/// # Example
9943///
9944/// Instantiate a resource method builder
9945///
9946/// ```test_harness,no_run
9947/// # extern crate hyper;
9948/// # extern crate hyper_rustls;
9949/// # extern crate google_androidmanagement1 as androidmanagement1;
9950/// use androidmanagement1::api::WebApp;
9951/// # async fn dox() {
9952/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9953///
9954/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9956/// # secret,
9957/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9958/// # ).build().await.unwrap();
9959///
9960/// # let client = hyper_util::client::legacy::Client::builder(
9961/// # hyper_util::rt::TokioExecutor::new()
9962/// # )
9963/// # .build(
9964/// # hyper_rustls::HttpsConnectorBuilder::new()
9965/// # .with_native_roots()
9966/// # .unwrap()
9967/// # .https_or_http()
9968/// # .enable_http1()
9969/// # .build()
9970/// # );
9971/// # let mut hub = AndroidManagement::new(client, auth);
9972/// // As the method needs a request, you would usually fill it with the desired information
9973/// // into the respective structure. Some of the parts shown here might not be applicable !
9974/// // Values shown here are possibly random and not representative !
9975/// let mut req = WebApp::default();
9976///
9977/// // You can configure optional parameters by calling the respective setters at will, and
9978/// // execute the final call using `doit()`.
9979/// // Values shown here are possibly random and not representative !
9980/// let result = hub.enterprises().web_apps_create(req, "parent")
9981/// .doit().await;
9982/// # }
9983/// ```
9984pub struct EnterpriseWebAppCreateCall<'a, C>
9985where
9986 C: 'a,
9987{
9988 hub: &'a AndroidManagement<C>,
9989 _request: WebApp,
9990 _parent: String,
9991 _delegate: Option<&'a mut dyn common::Delegate>,
9992 _additional_params: HashMap<String, String>,
9993 _scopes: BTreeSet<String>,
9994}
9995
9996impl<'a, C> common::CallBuilder for EnterpriseWebAppCreateCall<'a, C> {}
9997
9998impl<'a, C> EnterpriseWebAppCreateCall<'a, C>
9999where
10000 C: common::Connector,
10001{
10002 /// Perform the operation you have build so far.
10003 pub async fn doit(mut self) -> common::Result<(common::Response, WebApp)> {
10004 use std::borrow::Cow;
10005 use std::io::{Read, Seek};
10006
10007 use common::{url::Params, ToParts};
10008 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10009
10010 let mut dd = common::DefaultDelegate;
10011 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10012 dlg.begin(common::MethodInfo {
10013 id: "androidmanagement.enterprises.webApps.create",
10014 http_method: hyper::Method::POST,
10015 });
10016
10017 for &field in ["alt", "parent"].iter() {
10018 if self._additional_params.contains_key(field) {
10019 dlg.finished(false);
10020 return Err(common::Error::FieldClash(field));
10021 }
10022 }
10023
10024 let mut params = Params::with_capacity(4 + self._additional_params.len());
10025 params.push("parent", self._parent);
10026
10027 params.extend(self._additional_params.iter());
10028
10029 params.push("alt", "json");
10030 let mut url = self.hub._base_url.clone() + "v1/{+parent}/webApps";
10031 if self._scopes.is_empty() {
10032 self._scopes.insert(Scope::Full.as_ref().to_string());
10033 }
10034
10035 #[allow(clippy::single_element_loop)]
10036 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10037 url = params.uri_replacement(url, param_name, find_this, true);
10038 }
10039 {
10040 let to_remove = ["parent"];
10041 params.remove_params(&to_remove);
10042 }
10043
10044 let url = params.parse_with_url(&url);
10045
10046 let mut json_mime_type = mime::APPLICATION_JSON;
10047 let mut request_value_reader = {
10048 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10049 common::remove_json_null_values(&mut value);
10050 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10051 serde_json::to_writer(&mut dst, &value).unwrap();
10052 dst
10053 };
10054 let request_size = request_value_reader
10055 .seek(std::io::SeekFrom::End(0))
10056 .unwrap();
10057 request_value_reader
10058 .seek(std::io::SeekFrom::Start(0))
10059 .unwrap();
10060
10061 loop {
10062 let token = match self
10063 .hub
10064 .auth
10065 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10066 .await
10067 {
10068 Ok(token) => token,
10069 Err(e) => match dlg.token(e) {
10070 Ok(token) => token,
10071 Err(e) => {
10072 dlg.finished(false);
10073 return Err(common::Error::MissingToken(e));
10074 }
10075 },
10076 };
10077 request_value_reader
10078 .seek(std::io::SeekFrom::Start(0))
10079 .unwrap();
10080 let mut req_result = {
10081 let client = &self.hub.client;
10082 dlg.pre_request();
10083 let mut req_builder = hyper::Request::builder()
10084 .method(hyper::Method::POST)
10085 .uri(url.as_str())
10086 .header(USER_AGENT, self.hub._user_agent.clone());
10087
10088 if let Some(token) = token.as_ref() {
10089 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10090 }
10091
10092 let request = req_builder
10093 .header(CONTENT_TYPE, json_mime_type.to_string())
10094 .header(CONTENT_LENGTH, request_size as u64)
10095 .body(common::to_body(
10096 request_value_reader.get_ref().clone().into(),
10097 ));
10098
10099 client.request(request.unwrap()).await
10100 };
10101
10102 match req_result {
10103 Err(err) => {
10104 if let common::Retry::After(d) = dlg.http_error(&err) {
10105 sleep(d).await;
10106 continue;
10107 }
10108 dlg.finished(false);
10109 return Err(common::Error::HttpError(err));
10110 }
10111 Ok(res) => {
10112 let (mut parts, body) = res.into_parts();
10113 let mut body = common::Body::new(body);
10114 if !parts.status.is_success() {
10115 let bytes = common::to_bytes(body).await.unwrap_or_default();
10116 let error = serde_json::from_str(&common::to_string(&bytes));
10117 let response = common::to_response(parts, bytes.into());
10118
10119 if let common::Retry::After(d) =
10120 dlg.http_failure(&response, error.as_ref().ok())
10121 {
10122 sleep(d).await;
10123 continue;
10124 }
10125
10126 dlg.finished(false);
10127
10128 return Err(match error {
10129 Ok(value) => common::Error::BadRequest(value),
10130 _ => common::Error::Failure(response),
10131 });
10132 }
10133 let response = {
10134 let bytes = common::to_bytes(body).await.unwrap_or_default();
10135 let encoded = common::to_string(&bytes);
10136 match serde_json::from_str(&encoded) {
10137 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10138 Err(error) => {
10139 dlg.response_json_decode_error(&encoded, &error);
10140 return Err(common::Error::JsonDecodeError(
10141 encoded.to_string(),
10142 error,
10143 ));
10144 }
10145 }
10146 };
10147
10148 dlg.finished(true);
10149 return Ok(response);
10150 }
10151 }
10152 }
10153 }
10154
10155 ///
10156 /// Sets the *request* property to the given value.
10157 ///
10158 /// Even though the property as already been set when instantiating this call,
10159 /// we provide this method for API completeness.
10160 pub fn request(mut self, new_value: WebApp) -> EnterpriseWebAppCreateCall<'a, C> {
10161 self._request = new_value;
10162 self
10163 }
10164 /// The name of the enterprise in the form enterprises/{enterpriseId}.
10165 ///
10166 /// Sets the *parent* path property to the given value.
10167 ///
10168 /// Even though the property as already been set when instantiating this call,
10169 /// we provide this method for API completeness.
10170 pub fn parent(mut self, new_value: &str) -> EnterpriseWebAppCreateCall<'a, C> {
10171 self._parent = new_value.to_string();
10172 self
10173 }
10174 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10175 /// while executing the actual API request.
10176 ///
10177 /// ````text
10178 /// It should be used to handle progress information, and to implement a certain level of resilience.
10179 /// ````
10180 ///
10181 /// Sets the *delegate* property to the given value.
10182 pub fn delegate(
10183 mut self,
10184 new_value: &'a mut dyn common::Delegate,
10185 ) -> EnterpriseWebAppCreateCall<'a, C> {
10186 self._delegate = Some(new_value);
10187 self
10188 }
10189
10190 /// Set any additional parameter of the query string used in the request.
10191 /// It should be used to set parameters which are not yet available through their own
10192 /// setters.
10193 ///
10194 /// Please note that this method must not be used to set any of the known parameters
10195 /// which have their own setter method. If done anyway, the request will fail.
10196 ///
10197 /// # Additional Parameters
10198 ///
10199 /// * *$.xgafv* (query-string) - V1 error format.
10200 /// * *access_token* (query-string) - OAuth access token.
10201 /// * *alt* (query-string) - Data format for response.
10202 /// * *callback* (query-string) - JSONP
10203 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10204 /// * *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.
10205 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10206 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10207 /// * *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.
10208 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10209 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10210 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseWebAppCreateCall<'a, C>
10211 where
10212 T: AsRef<str>,
10213 {
10214 self._additional_params
10215 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10216 self
10217 }
10218
10219 /// Identifies the authorization scope for the method you are building.
10220 ///
10221 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10222 /// [`Scope::Full`].
10223 ///
10224 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10225 /// tokens for more than one scope.
10226 ///
10227 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10228 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10229 /// sufficient, a read-write scope will do as well.
10230 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseWebAppCreateCall<'a, C>
10231 where
10232 St: AsRef<str>,
10233 {
10234 self._scopes.insert(String::from(scope.as_ref()));
10235 self
10236 }
10237 /// Identifies the authorization scope(s) for the method you are building.
10238 ///
10239 /// See [`Self::add_scope()`] for details.
10240 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseWebAppCreateCall<'a, C>
10241 where
10242 I: IntoIterator<Item = St>,
10243 St: AsRef<str>,
10244 {
10245 self._scopes
10246 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10247 self
10248 }
10249
10250 /// Removes all scopes, and no default scope will be used either.
10251 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10252 /// for details).
10253 pub fn clear_scopes(mut self) -> EnterpriseWebAppCreateCall<'a, C> {
10254 self._scopes.clear();
10255 self
10256 }
10257}
10258
10259/// Deletes a web app.
10260///
10261/// A builder for the *webApps.delete* method supported by a *enterprise* resource.
10262/// It is not used directly, but through a [`EnterpriseMethods`] instance.
10263///
10264/// # Example
10265///
10266/// Instantiate a resource method builder
10267///
10268/// ```test_harness,no_run
10269/// # extern crate hyper;
10270/// # extern crate hyper_rustls;
10271/// # extern crate google_androidmanagement1 as androidmanagement1;
10272/// # async fn dox() {
10273/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10274///
10275/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10276/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10277/// # secret,
10278/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10279/// # ).build().await.unwrap();
10280///
10281/// # let client = hyper_util::client::legacy::Client::builder(
10282/// # hyper_util::rt::TokioExecutor::new()
10283/// # )
10284/// # .build(
10285/// # hyper_rustls::HttpsConnectorBuilder::new()
10286/// # .with_native_roots()
10287/// # .unwrap()
10288/// # .https_or_http()
10289/// # .enable_http1()
10290/// # .build()
10291/// # );
10292/// # let mut hub = AndroidManagement::new(client, auth);
10293/// // You can configure optional parameters by calling the respective setters at will, and
10294/// // execute the final call using `doit()`.
10295/// // Values shown here are possibly random and not representative !
10296/// let result = hub.enterprises().web_apps_delete("name")
10297/// .doit().await;
10298/// # }
10299/// ```
10300pub struct EnterpriseWebAppDeleteCall<'a, C>
10301where
10302 C: 'a,
10303{
10304 hub: &'a AndroidManagement<C>,
10305 _name: String,
10306 _delegate: Option<&'a mut dyn common::Delegate>,
10307 _additional_params: HashMap<String, String>,
10308 _scopes: BTreeSet<String>,
10309}
10310
10311impl<'a, C> common::CallBuilder for EnterpriseWebAppDeleteCall<'a, C> {}
10312
10313impl<'a, C> EnterpriseWebAppDeleteCall<'a, C>
10314where
10315 C: common::Connector,
10316{
10317 /// Perform the operation you have build so far.
10318 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
10319 use std::borrow::Cow;
10320 use std::io::{Read, Seek};
10321
10322 use common::{url::Params, ToParts};
10323 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10324
10325 let mut dd = common::DefaultDelegate;
10326 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10327 dlg.begin(common::MethodInfo {
10328 id: "androidmanagement.enterprises.webApps.delete",
10329 http_method: hyper::Method::DELETE,
10330 });
10331
10332 for &field in ["alt", "name"].iter() {
10333 if self._additional_params.contains_key(field) {
10334 dlg.finished(false);
10335 return Err(common::Error::FieldClash(field));
10336 }
10337 }
10338
10339 let mut params = Params::with_capacity(3 + self._additional_params.len());
10340 params.push("name", self._name);
10341
10342 params.extend(self._additional_params.iter());
10343
10344 params.push("alt", "json");
10345 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10346 if self._scopes.is_empty() {
10347 self._scopes.insert(Scope::Full.as_ref().to_string());
10348 }
10349
10350 #[allow(clippy::single_element_loop)]
10351 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10352 url = params.uri_replacement(url, param_name, find_this, true);
10353 }
10354 {
10355 let to_remove = ["name"];
10356 params.remove_params(&to_remove);
10357 }
10358
10359 let url = params.parse_with_url(&url);
10360
10361 loop {
10362 let token = match self
10363 .hub
10364 .auth
10365 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10366 .await
10367 {
10368 Ok(token) => token,
10369 Err(e) => match dlg.token(e) {
10370 Ok(token) => token,
10371 Err(e) => {
10372 dlg.finished(false);
10373 return Err(common::Error::MissingToken(e));
10374 }
10375 },
10376 };
10377 let mut req_result = {
10378 let client = &self.hub.client;
10379 dlg.pre_request();
10380 let mut req_builder = hyper::Request::builder()
10381 .method(hyper::Method::DELETE)
10382 .uri(url.as_str())
10383 .header(USER_AGENT, self.hub._user_agent.clone());
10384
10385 if let Some(token) = token.as_ref() {
10386 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10387 }
10388
10389 let request = req_builder
10390 .header(CONTENT_LENGTH, 0_u64)
10391 .body(common::to_body::<String>(None));
10392
10393 client.request(request.unwrap()).await
10394 };
10395
10396 match req_result {
10397 Err(err) => {
10398 if let common::Retry::After(d) = dlg.http_error(&err) {
10399 sleep(d).await;
10400 continue;
10401 }
10402 dlg.finished(false);
10403 return Err(common::Error::HttpError(err));
10404 }
10405 Ok(res) => {
10406 let (mut parts, body) = res.into_parts();
10407 let mut body = common::Body::new(body);
10408 if !parts.status.is_success() {
10409 let bytes = common::to_bytes(body).await.unwrap_or_default();
10410 let error = serde_json::from_str(&common::to_string(&bytes));
10411 let response = common::to_response(parts, bytes.into());
10412
10413 if let common::Retry::After(d) =
10414 dlg.http_failure(&response, error.as_ref().ok())
10415 {
10416 sleep(d).await;
10417 continue;
10418 }
10419
10420 dlg.finished(false);
10421
10422 return Err(match error {
10423 Ok(value) => common::Error::BadRequest(value),
10424 _ => common::Error::Failure(response),
10425 });
10426 }
10427 let response = {
10428 let bytes = common::to_bytes(body).await.unwrap_or_default();
10429 let encoded = common::to_string(&bytes);
10430 match serde_json::from_str(&encoded) {
10431 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10432 Err(error) => {
10433 dlg.response_json_decode_error(&encoded, &error);
10434 return Err(common::Error::JsonDecodeError(
10435 encoded.to_string(),
10436 error,
10437 ));
10438 }
10439 }
10440 };
10441
10442 dlg.finished(true);
10443 return Ok(response);
10444 }
10445 }
10446 }
10447 }
10448
10449 /// The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}.
10450 ///
10451 /// Sets the *name* path property to the given value.
10452 ///
10453 /// Even though the property as already been set when instantiating this call,
10454 /// we provide this method for API completeness.
10455 pub fn name(mut self, new_value: &str) -> EnterpriseWebAppDeleteCall<'a, C> {
10456 self._name = new_value.to_string();
10457 self
10458 }
10459 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10460 /// while executing the actual API request.
10461 ///
10462 /// ````text
10463 /// It should be used to handle progress information, and to implement a certain level of resilience.
10464 /// ````
10465 ///
10466 /// Sets the *delegate* property to the given value.
10467 pub fn delegate(
10468 mut self,
10469 new_value: &'a mut dyn common::Delegate,
10470 ) -> EnterpriseWebAppDeleteCall<'a, C> {
10471 self._delegate = Some(new_value);
10472 self
10473 }
10474
10475 /// Set any additional parameter of the query string used in the request.
10476 /// It should be used to set parameters which are not yet available through their own
10477 /// setters.
10478 ///
10479 /// Please note that this method must not be used to set any of the known parameters
10480 /// which have their own setter method. If done anyway, the request will fail.
10481 ///
10482 /// # Additional Parameters
10483 ///
10484 /// * *$.xgafv* (query-string) - V1 error format.
10485 /// * *access_token* (query-string) - OAuth access token.
10486 /// * *alt* (query-string) - Data format for response.
10487 /// * *callback* (query-string) - JSONP
10488 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10489 /// * *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.
10490 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10491 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10492 /// * *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.
10493 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10494 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10495 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseWebAppDeleteCall<'a, C>
10496 where
10497 T: AsRef<str>,
10498 {
10499 self._additional_params
10500 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10501 self
10502 }
10503
10504 /// Identifies the authorization scope for the method you are building.
10505 ///
10506 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10507 /// [`Scope::Full`].
10508 ///
10509 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10510 /// tokens for more than one scope.
10511 ///
10512 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10513 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10514 /// sufficient, a read-write scope will do as well.
10515 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseWebAppDeleteCall<'a, C>
10516 where
10517 St: AsRef<str>,
10518 {
10519 self._scopes.insert(String::from(scope.as_ref()));
10520 self
10521 }
10522 /// Identifies the authorization scope(s) for the method you are building.
10523 ///
10524 /// See [`Self::add_scope()`] for details.
10525 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseWebAppDeleteCall<'a, C>
10526 where
10527 I: IntoIterator<Item = St>,
10528 St: AsRef<str>,
10529 {
10530 self._scopes
10531 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10532 self
10533 }
10534
10535 /// Removes all scopes, and no default scope will be used either.
10536 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10537 /// for details).
10538 pub fn clear_scopes(mut self) -> EnterpriseWebAppDeleteCall<'a, C> {
10539 self._scopes.clear();
10540 self
10541 }
10542}
10543
10544/// Gets a web app.
10545///
10546/// A builder for the *webApps.get* method supported by a *enterprise* resource.
10547/// It is not used directly, but through a [`EnterpriseMethods`] instance.
10548///
10549/// # Example
10550///
10551/// Instantiate a resource method builder
10552///
10553/// ```test_harness,no_run
10554/// # extern crate hyper;
10555/// # extern crate hyper_rustls;
10556/// # extern crate google_androidmanagement1 as androidmanagement1;
10557/// # async fn dox() {
10558/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10559///
10560/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10561/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10562/// # secret,
10563/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10564/// # ).build().await.unwrap();
10565///
10566/// # let client = hyper_util::client::legacy::Client::builder(
10567/// # hyper_util::rt::TokioExecutor::new()
10568/// # )
10569/// # .build(
10570/// # hyper_rustls::HttpsConnectorBuilder::new()
10571/// # .with_native_roots()
10572/// # .unwrap()
10573/// # .https_or_http()
10574/// # .enable_http1()
10575/// # .build()
10576/// # );
10577/// # let mut hub = AndroidManagement::new(client, auth);
10578/// // You can configure optional parameters by calling the respective setters at will, and
10579/// // execute the final call using `doit()`.
10580/// // Values shown here are possibly random and not representative !
10581/// let result = hub.enterprises().web_apps_get("name")
10582/// .doit().await;
10583/// # }
10584/// ```
10585pub struct EnterpriseWebAppGetCall<'a, C>
10586where
10587 C: 'a,
10588{
10589 hub: &'a AndroidManagement<C>,
10590 _name: String,
10591 _delegate: Option<&'a mut dyn common::Delegate>,
10592 _additional_params: HashMap<String, String>,
10593 _scopes: BTreeSet<String>,
10594}
10595
10596impl<'a, C> common::CallBuilder for EnterpriseWebAppGetCall<'a, C> {}
10597
10598impl<'a, C> EnterpriseWebAppGetCall<'a, C>
10599where
10600 C: common::Connector,
10601{
10602 /// Perform the operation you have build so far.
10603 pub async fn doit(mut self) -> common::Result<(common::Response, WebApp)> {
10604 use std::borrow::Cow;
10605 use std::io::{Read, Seek};
10606
10607 use common::{url::Params, ToParts};
10608 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10609
10610 let mut dd = common::DefaultDelegate;
10611 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10612 dlg.begin(common::MethodInfo {
10613 id: "androidmanagement.enterprises.webApps.get",
10614 http_method: hyper::Method::GET,
10615 });
10616
10617 for &field in ["alt", "name"].iter() {
10618 if self._additional_params.contains_key(field) {
10619 dlg.finished(false);
10620 return Err(common::Error::FieldClash(field));
10621 }
10622 }
10623
10624 let mut params = Params::with_capacity(3 + self._additional_params.len());
10625 params.push("name", self._name);
10626
10627 params.extend(self._additional_params.iter());
10628
10629 params.push("alt", "json");
10630 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10631 if self._scopes.is_empty() {
10632 self._scopes.insert(Scope::Full.as_ref().to_string());
10633 }
10634
10635 #[allow(clippy::single_element_loop)]
10636 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10637 url = params.uri_replacement(url, param_name, find_this, true);
10638 }
10639 {
10640 let to_remove = ["name"];
10641 params.remove_params(&to_remove);
10642 }
10643
10644 let url = params.parse_with_url(&url);
10645
10646 loop {
10647 let token = match self
10648 .hub
10649 .auth
10650 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10651 .await
10652 {
10653 Ok(token) => token,
10654 Err(e) => match dlg.token(e) {
10655 Ok(token) => token,
10656 Err(e) => {
10657 dlg.finished(false);
10658 return Err(common::Error::MissingToken(e));
10659 }
10660 },
10661 };
10662 let mut req_result = {
10663 let client = &self.hub.client;
10664 dlg.pre_request();
10665 let mut req_builder = hyper::Request::builder()
10666 .method(hyper::Method::GET)
10667 .uri(url.as_str())
10668 .header(USER_AGENT, self.hub._user_agent.clone());
10669
10670 if let Some(token) = token.as_ref() {
10671 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10672 }
10673
10674 let request = req_builder
10675 .header(CONTENT_LENGTH, 0_u64)
10676 .body(common::to_body::<String>(None));
10677
10678 client.request(request.unwrap()).await
10679 };
10680
10681 match req_result {
10682 Err(err) => {
10683 if let common::Retry::After(d) = dlg.http_error(&err) {
10684 sleep(d).await;
10685 continue;
10686 }
10687 dlg.finished(false);
10688 return Err(common::Error::HttpError(err));
10689 }
10690 Ok(res) => {
10691 let (mut parts, body) = res.into_parts();
10692 let mut body = common::Body::new(body);
10693 if !parts.status.is_success() {
10694 let bytes = common::to_bytes(body).await.unwrap_or_default();
10695 let error = serde_json::from_str(&common::to_string(&bytes));
10696 let response = common::to_response(parts, bytes.into());
10697
10698 if let common::Retry::After(d) =
10699 dlg.http_failure(&response, error.as_ref().ok())
10700 {
10701 sleep(d).await;
10702 continue;
10703 }
10704
10705 dlg.finished(false);
10706
10707 return Err(match error {
10708 Ok(value) => common::Error::BadRequest(value),
10709 _ => common::Error::Failure(response),
10710 });
10711 }
10712 let response = {
10713 let bytes = common::to_bytes(body).await.unwrap_or_default();
10714 let encoded = common::to_string(&bytes);
10715 match serde_json::from_str(&encoded) {
10716 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10717 Err(error) => {
10718 dlg.response_json_decode_error(&encoded, &error);
10719 return Err(common::Error::JsonDecodeError(
10720 encoded.to_string(),
10721 error,
10722 ));
10723 }
10724 }
10725 };
10726
10727 dlg.finished(true);
10728 return Ok(response);
10729 }
10730 }
10731 }
10732 }
10733
10734 /// The name of the web app in the form enterprises/{enterpriseId}/webApp/{packageName}.
10735 ///
10736 /// Sets the *name* path property to the given value.
10737 ///
10738 /// Even though the property as already been set when instantiating this call,
10739 /// we provide this method for API completeness.
10740 pub fn name(mut self, new_value: &str) -> EnterpriseWebAppGetCall<'a, C> {
10741 self._name = new_value.to_string();
10742 self
10743 }
10744 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10745 /// while executing the actual API request.
10746 ///
10747 /// ````text
10748 /// It should be used to handle progress information, and to implement a certain level of resilience.
10749 /// ````
10750 ///
10751 /// Sets the *delegate* property to the given value.
10752 pub fn delegate(
10753 mut self,
10754 new_value: &'a mut dyn common::Delegate,
10755 ) -> EnterpriseWebAppGetCall<'a, C> {
10756 self._delegate = Some(new_value);
10757 self
10758 }
10759
10760 /// Set any additional parameter of the query string used in the request.
10761 /// It should be used to set parameters which are not yet available through their own
10762 /// setters.
10763 ///
10764 /// Please note that this method must not be used to set any of the known parameters
10765 /// which have their own setter method. If done anyway, the request will fail.
10766 ///
10767 /// # Additional Parameters
10768 ///
10769 /// * *$.xgafv* (query-string) - V1 error format.
10770 /// * *access_token* (query-string) - OAuth access token.
10771 /// * *alt* (query-string) - Data format for response.
10772 /// * *callback* (query-string) - JSONP
10773 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10774 /// * *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.
10775 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10776 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10777 /// * *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.
10778 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10779 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10780 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseWebAppGetCall<'a, C>
10781 where
10782 T: AsRef<str>,
10783 {
10784 self._additional_params
10785 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10786 self
10787 }
10788
10789 /// Identifies the authorization scope for the method you are building.
10790 ///
10791 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10792 /// [`Scope::Full`].
10793 ///
10794 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10795 /// tokens for more than one scope.
10796 ///
10797 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10798 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10799 /// sufficient, a read-write scope will do as well.
10800 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseWebAppGetCall<'a, C>
10801 where
10802 St: AsRef<str>,
10803 {
10804 self._scopes.insert(String::from(scope.as_ref()));
10805 self
10806 }
10807 /// Identifies the authorization scope(s) for the method you are building.
10808 ///
10809 /// See [`Self::add_scope()`] for details.
10810 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseWebAppGetCall<'a, C>
10811 where
10812 I: IntoIterator<Item = St>,
10813 St: AsRef<str>,
10814 {
10815 self._scopes
10816 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10817 self
10818 }
10819
10820 /// Removes all scopes, and no default scope will be used either.
10821 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10822 /// for details).
10823 pub fn clear_scopes(mut self) -> EnterpriseWebAppGetCall<'a, C> {
10824 self._scopes.clear();
10825 self
10826 }
10827}
10828
10829/// Lists web apps for a given enterprise.
10830///
10831/// A builder for the *webApps.list* method supported by a *enterprise* resource.
10832/// It is not used directly, but through a [`EnterpriseMethods`] instance.
10833///
10834/// # Example
10835///
10836/// Instantiate a resource method builder
10837///
10838/// ```test_harness,no_run
10839/// # extern crate hyper;
10840/// # extern crate hyper_rustls;
10841/// # extern crate google_androidmanagement1 as androidmanagement1;
10842/// # async fn dox() {
10843/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10844///
10845/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10846/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10847/// # secret,
10848/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10849/// # ).build().await.unwrap();
10850///
10851/// # let client = hyper_util::client::legacy::Client::builder(
10852/// # hyper_util::rt::TokioExecutor::new()
10853/// # )
10854/// # .build(
10855/// # hyper_rustls::HttpsConnectorBuilder::new()
10856/// # .with_native_roots()
10857/// # .unwrap()
10858/// # .https_or_http()
10859/// # .enable_http1()
10860/// # .build()
10861/// # );
10862/// # let mut hub = AndroidManagement::new(client, auth);
10863/// // You can configure optional parameters by calling the respective setters at will, and
10864/// // execute the final call using `doit()`.
10865/// // Values shown here are possibly random and not representative !
10866/// let result = hub.enterprises().web_apps_list("parent")
10867/// .page_token("duo")
10868/// .page_size(-34)
10869/// .doit().await;
10870/// # }
10871/// ```
10872pub struct EnterpriseWebAppListCall<'a, C>
10873where
10874 C: 'a,
10875{
10876 hub: &'a AndroidManagement<C>,
10877 _parent: String,
10878 _page_token: Option<String>,
10879 _page_size: Option<i32>,
10880 _delegate: Option<&'a mut dyn common::Delegate>,
10881 _additional_params: HashMap<String, String>,
10882 _scopes: BTreeSet<String>,
10883}
10884
10885impl<'a, C> common::CallBuilder for EnterpriseWebAppListCall<'a, C> {}
10886
10887impl<'a, C> EnterpriseWebAppListCall<'a, C>
10888where
10889 C: common::Connector,
10890{
10891 /// Perform the operation you have build so far.
10892 pub async fn doit(mut self) -> common::Result<(common::Response, ListWebAppsResponse)> {
10893 use std::borrow::Cow;
10894 use std::io::{Read, Seek};
10895
10896 use common::{url::Params, ToParts};
10897 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10898
10899 let mut dd = common::DefaultDelegate;
10900 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10901 dlg.begin(common::MethodInfo {
10902 id: "androidmanagement.enterprises.webApps.list",
10903 http_method: hyper::Method::GET,
10904 });
10905
10906 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
10907 if self._additional_params.contains_key(field) {
10908 dlg.finished(false);
10909 return Err(common::Error::FieldClash(field));
10910 }
10911 }
10912
10913 let mut params = Params::with_capacity(5 + self._additional_params.len());
10914 params.push("parent", self._parent);
10915 if let Some(value) = self._page_token.as_ref() {
10916 params.push("pageToken", value);
10917 }
10918 if let Some(value) = self._page_size.as_ref() {
10919 params.push("pageSize", value.to_string());
10920 }
10921
10922 params.extend(self._additional_params.iter());
10923
10924 params.push("alt", "json");
10925 let mut url = self.hub._base_url.clone() + "v1/{+parent}/webApps";
10926 if self._scopes.is_empty() {
10927 self._scopes.insert(Scope::Full.as_ref().to_string());
10928 }
10929
10930 #[allow(clippy::single_element_loop)]
10931 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10932 url = params.uri_replacement(url, param_name, find_this, true);
10933 }
10934 {
10935 let to_remove = ["parent"];
10936 params.remove_params(&to_remove);
10937 }
10938
10939 let url = params.parse_with_url(&url);
10940
10941 loop {
10942 let token = match self
10943 .hub
10944 .auth
10945 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10946 .await
10947 {
10948 Ok(token) => token,
10949 Err(e) => match dlg.token(e) {
10950 Ok(token) => token,
10951 Err(e) => {
10952 dlg.finished(false);
10953 return Err(common::Error::MissingToken(e));
10954 }
10955 },
10956 };
10957 let mut req_result = {
10958 let client = &self.hub.client;
10959 dlg.pre_request();
10960 let mut req_builder = hyper::Request::builder()
10961 .method(hyper::Method::GET)
10962 .uri(url.as_str())
10963 .header(USER_AGENT, self.hub._user_agent.clone());
10964
10965 if let Some(token) = token.as_ref() {
10966 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10967 }
10968
10969 let request = req_builder
10970 .header(CONTENT_LENGTH, 0_u64)
10971 .body(common::to_body::<String>(None));
10972
10973 client.request(request.unwrap()).await
10974 };
10975
10976 match req_result {
10977 Err(err) => {
10978 if let common::Retry::After(d) = dlg.http_error(&err) {
10979 sleep(d).await;
10980 continue;
10981 }
10982 dlg.finished(false);
10983 return Err(common::Error::HttpError(err));
10984 }
10985 Ok(res) => {
10986 let (mut parts, body) = res.into_parts();
10987 let mut body = common::Body::new(body);
10988 if !parts.status.is_success() {
10989 let bytes = common::to_bytes(body).await.unwrap_or_default();
10990 let error = serde_json::from_str(&common::to_string(&bytes));
10991 let response = common::to_response(parts, bytes.into());
10992
10993 if let common::Retry::After(d) =
10994 dlg.http_failure(&response, error.as_ref().ok())
10995 {
10996 sleep(d).await;
10997 continue;
10998 }
10999
11000 dlg.finished(false);
11001
11002 return Err(match error {
11003 Ok(value) => common::Error::BadRequest(value),
11004 _ => common::Error::Failure(response),
11005 });
11006 }
11007 let response = {
11008 let bytes = common::to_bytes(body).await.unwrap_or_default();
11009 let encoded = common::to_string(&bytes);
11010 match serde_json::from_str(&encoded) {
11011 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11012 Err(error) => {
11013 dlg.response_json_decode_error(&encoded, &error);
11014 return Err(common::Error::JsonDecodeError(
11015 encoded.to_string(),
11016 error,
11017 ));
11018 }
11019 }
11020 };
11021
11022 dlg.finished(true);
11023 return Ok(response);
11024 }
11025 }
11026 }
11027 }
11028
11029 /// The name of the enterprise in the form enterprises/{enterpriseId}.
11030 ///
11031 /// Sets the *parent* path property to the given value.
11032 ///
11033 /// Even though the property as already been set when instantiating this call,
11034 /// we provide this method for API completeness.
11035 pub fn parent(mut self, new_value: &str) -> EnterpriseWebAppListCall<'a, C> {
11036 self._parent = new_value.to_string();
11037 self
11038 }
11039 /// A token identifying a page of results returned by the server.
11040 ///
11041 /// Sets the *page token* query property to the given value.
11042 pub fn page_token(mut self, new_value: &str) -> EnterpriseWebAppListCall<'a, C> {
11043 self._page_token = Some(new_value.to_string());
11044 self
11045 }
11046 /// The requested page size. This is a hint and the actual page size in the response may be different.
11047 ///
11048 /// Sets the *page size* query property to the given value.
11049 pub fn page_size(mut self, new_value: i32) -> EnterpriseWebAppListCall<'a, C> {
11050 self._page_size = Some(new_value);
11051 self
11052 }
11053 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11054 /// while executing the actual API request.
11055 ///
11056 /// ````text
11057 /// It should be used to handle progress information, and to implement a certain level of resilience.
11058 /// ````
11059 ///
11060 /// Sets the *delegate* property to the given value.
11061 pub fn delegate(
11062 mut self,
11063 new_value: &'a mut dyn common::Delegate,
11064 ) -> EnterpriseWebAppListCall<'a, C> {
11065 self._delegate = Some(new_value);
11066 self
11067 }
11068
11069 /// Set any additional parameter of the query string used in the request.
11070 /// It should be used to set parameters which are not yet available through their own
11071 /// setters.
11072 ///
11073 /// Please note that this method must not be used to set any of the known parameters
11074 /// which have their own setter method. If done anyway, the request will fail.
11075 ///
11076 /// # Additional Parameters
11077 ///
11078 /// * *$.xgafv* (query-string) - V1 error format.
11079 /// * *access_token* (query-string) - OAuth access token.
11080 /// * *alt* (query-string) - Data format for response.
11081 /// * *callback* (query-string) - JSONP
11082 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11083 /// * *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.
11084 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11085 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11086 /// * *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.
11087 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11088 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11089 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseWebAppListCall<'a, C>
11090 where
11091 T: AsRef<str>,
11092 {
11093 self._additional_params
11094 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11095 self
11096 }
11097
11098 /// Identifies the authorization scope for the method you are building.
11099 ///
11100 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11101 /// [`Scope::Full`].
11102 ///
11103 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11104 /// tokens for more than one scope.
11105 ///
11106 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11107 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11108 /// sufficient, a read-write scope will do as well.
11109 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseWebAppListCall<'a, C>
11110 where
11111 St: AsRef<str>,
11112 {
11113 self._scopes.insert(String::from(scope.as_ref()));
11114 self
11115 }
11116 /// Identifies the authorization scope(s) for the method you are building.
11117 ///
11118 /// See [`Self::add_scope()`] for details.
11119 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseWebAppListCall<'a, C>
11120 where
11121 I: IntoIterator<Item = St>,
11122 St: AsRef<str>,
11123 {
11124 self._scopes
11125 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11126 self
11127 }
11128
11129 /// Removes all scopes, and no default scope will be used either.
11130 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11131 /// for details).
11132 pub fn clear_scopes(mut self) -> EnterpriseWebAppListCall<'a, C> {
11133 self._scopes.clear();
11134 self
11135 }
11136}
11137
11138/// Updates a web app.
11139///
11140/// A builder for the *webApps.patch* method supported by a *enterprise* resource.
11141/// It is not used directly, but through a [`EnterpriseMethods`] instance.
11142///
11143/// # Example
11144///
11145/// Instantiate a resource method builder
11146///
11147/// ```test_harness,no_run
11148/// # extern crate hyper;
11149/// # extern crate hyper_rustls;
11150/// # extern crate google_androidmanagement1 as androidmanagement1;
11151/// use androidmanagement1::api::WebApp;
11152/// # async fn dox() {
11153/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11154///
11155/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11156/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11157/// # secret,
11158/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11159/// # ).build().await.unwrap();
11160///
11161/// # let client = hyper_util::client::legacy::Client::builder(
11162/// # hyper_util::rt::TokioExecutor::new()
11163/// # )
11164/// # .build(
11165/// # hyper_rustls::HttpsConnectorBuilder::new()
11166/// # .with_native_roots()
11167/// # .unwrap()
11168/// # .https_or_http()
11169/// # .enable_http1()
11170/// # .build()
11171/// # );
11172/// # let mut hub = AndroidManagement::new(client, auth);
11173/// // As the method needs a request, you would usually fill it with the desired information
11174/// // into the respective structure. Some of the parts shown here might not be applicable !
11175/// // Values shown here are possibly random and not representative !
11176/// let mut req = WebApp::default();
11177///
11178/// // You can configure optional parameters by calling the respective setters at will, and
11179/// // execute the final call using `doit()`.
11180/// // Values shown here are possibly random and not representative !
11181/// let result = hub.enterprises().web_apps_patch(req, "name")
11182/// .update_mask(FieldMask::new::<&str>(&[]))
11183/// .doit().await;
11184/// # }
11185/// ```
11186pub struct EnterpriseWebAppPatchCall<'a, C>
11187where
11188 C: 'a,
11189{
11190 hub: &'a AndroidManagement<C>,
11191 _request: WebApp,
11192 _name: String,
11193 _update_mask: Option<common::FieldMask>,
11194 _delegate: Option<&'a mut dyn common::Delegate>,
11195 _additional_params: HashMap<String, String>,
11196 _scopes: BTreeSet<String>,
11197}
11198
11199impl<'a, C> common::CallBuilder for EnterpriseWebAppPatchCall<'a, C> {}
11200
11201impl<'a, C> EnterpriseWebAppPatchCall<'a, C>
11202where
11203 C: common::Connector,
11204{
11205 /// Perform the operation you have build so far.
11206 pub async fn doit(mut self) -> common::Result<(common::Response, WebApp)> {
11207 use std::borrow::Cow;
11208 use std::io::{Read, Seek};
11209
11210 use common::{url::Params, ToParts};
11211 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11212
11213 let mut dd = common::DefaultDelegate;
11214 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11215 dlg.begin(common::MethodInfo {
11216 id: "androidmanagement.enterprises.webApps.patch",
11217 http_method: hyper::Method::PATCH,
11218 });
11219
11220 for &field in ["alt", "name", "updateMask"].iter() {
11221 if self._additional_params.contains_key(field) {
11222 dlg.finished(false);
11223 return Err(common::Error::FieldClash(field));
11224 }
11225 }
11226
11227 let mut params = Params::with_capacity(5 + self._additional_params.len());
11228 params.push("name", self._name);
11229 if let Some(value) = self._update_mask.as_ref() {
11230 params.push("updateMask", value.to_string());
11231 }
11232
11233 params.extend(self._additional_params.iter());
11234
11235 params.push("alt", "json");
11236 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11237 if self._scopes.is_empty() {
11238 self._scopes.insert(Scope::Full.as_ref().to_string());
11239 }
11240
11241 #[allow(clippy::single_element_loop)]
11242 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11243 url = params.uri_replacement(url, param_name, find_this, true);
11244 }
11245 {
11246 let to_remove = ["name"];
11247 params.remove_params(&to_remove);
11248 }
11249
11250 let url = params.parse_with_url(&url);
11251
11252 let mut json_mime_type = mime::APPLICATION_JSON;
11253 let mut request_value_reader = {
11254 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11255 common::remove_json_null_values(&mut value);
11256 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11257 serde_json::to_writer(&mut dst, &value).unwrap();
11258 dst
11259 };
11260 let request_size = request_value_reader
11261 .seek(std::io::SeekFrom::End(0))
11262 .unwrap();
11263 request_value_reader
11264 .seek(std::io::SeekFrom::Start(0))
11265 .unwrap();
11266
11267 loop {
11268 let token = match self
11269 .hub
11270 .auth
11271 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11272 .await
11273 {
11274 Ok(token) => token,
11275 Err(e) => match dlg.token(e) {
11276 Ok(token) => token,
11277 Err(e) => {
11278 dlg.finished(false);
11279 return Err(common::Error::MissingToken(e));
11280 }
11281 },
11282 };
11283 request_value_reader
11284 .seek(std::io::SeekFrom::Start(0))
11285 .unwrap();
11286 let mut req_result = {
11287 let client = &self.hub.client;
11288 dlg.pre_request();
11289 let mut req_builder = hyper::Request::builder()
11290 .method(hyper::Method::PATCH)
11291 .uri(url.as_str())
11292 .header(USER_AGENT, self.hub._user_agent.clone());
11293
11294 if let Some(token) = token.as_ref() {
11295 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11296 }
11297
11298 let request = req_builder
11299 .header(CONTENT_TYPE, json_mime_type.to_string())
11300 .header(CONTENT_LENGTH, request_size as u64)
11301 .body(common::to_body(
11302 request_value_reader.get_ref().clone().into(),
11303 ));
11304
11305 client.request(request.unwrap()).await
11306 };
11307
11308 match req_result {
11309 Err(err) => {
11310 if let common::Retry::After(d) = dlg.http_error(&err) {
11311 sleep(d).await;
11312 continue;
11313 }
11314 dlg.finished(false);
11315 return Err(common::Error::HttpError(err));
11316 }
11317 Ok(res) => {
11318 let (mut parts, body) = res.into_parts();
11319 let mut body = common::Body::new(body);
11320 if !parts.status.is_success() {
11321 let bytes = common::to_bytes(body).await.unwrap_or_default();
11322 let error = serde_json::from_str(&common::to_string(&bytes));
11323 let response = common::to_response(parts, bytes.into());
11324
11325 if let common::Retry::After(d) =
11326 dlg.http_failure(&response, error.as_ref().ok())
11327 {
11328 sleep(d).await;
11329 continue;
11330 }
11331
11332 dlg.finished(false);
11333
11334 return Err(match error {
11335 Ok(value) => common::Error::BadRequest(value),
11336 _ => common::Error::Failure(response),
11337 });
11338 }
11339 let response = {
11340 let bytes = common::to_bytes(body).await.unwrap_or_default();
11341 let encoded = common::to_string(&bytes);
11342 match serde_json::from_str(&encoded) {
11343 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11344 Err(error) => {
11345 dlg.response_json_decode_error(&encoded, &error);
11346 return Err(common::Error::JsonDecodeError(
11347 encoded.to_string(),
11348 error,
11349 ));
11350 }
11351 }
11352 };
11353
11354 dlg.finished(true);
11355 return Ok(response);
11356 }
11357 }
11358 }
11359 }
11360
11361 ///
11362 /// Sets the *request* property to the given value.
11363 ///
11364 /// Even though the property as already been set when instantiating this call,
11365 /// we provide this method for API completeness.
11366 pub fn request(mut self, new_value: WebApp) -> EnterpriseWebAppPatchCall<'a, C> {
11367 self._request = new_value;
11368 self
11369 }
11370 /// The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}.
11371 ///
11372 /// Sets the *name* path property to the given value.
11373 ///
11374 /// Even though the property as already been set when instantiating this call,
11375 /// we provide this method for API completeness.
11376 pub fn name(mut self, new_value: &str) -> EnterpriseWebAppPatchCall<'a, C> {
11377 self._name = new_value.to_string();
11378 self
11379 }
11380 /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified.
11381 ///
11382 /// Sets the *update mask* query property to the given value.
11383 pub fn update_mask(mut self, new_value: common::FieldMask) -> EnterpriseWebAppPatchCall<'a, C> {
11384 self._update_mask = Some(new_value);
11385 self
11386 }
11387 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11388 /// while executing the actual API request.
11389 ///
11390 /// ````text
11391 /// It should be used to handle progress information, and to implement a certain level of resilience.
11392 /// ````
11393 ///
11394 /// Sets the *delegate* property to the given value.
11395 pub fn delegate(
11396 mut self,
11397 new_value: &'a mut dyn common::Delegate,
11398 ) -> EnterpriseWebAppPatchCall<'a, C> {
11399 self._delegate = Some(new_value);
11400 self
11401 }
11402
11403 /// Set any additional parameter of the query string used in the request.
11404 /// It should be used to set parameters which are not yet available through their own
11405 /// setters.
11406 ///
11407 /// Please note that this method must not be used to set any of the known parameters
11408 /// which have their own setter method. If done anyway, the request will fail.
11409 ///
11410 /// # Additional Parameters
11411 ///
11412 /// * *$.xgafv* (query-string) - V1 error format.
11413 /// * *access_token* (query-string) - OAuth access token.
11414 /// * *alt* (query-string) - Data format for response.
11415 /// * *callback* (query-string) - JSONP
11416 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11417 /// * *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.
11418 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11419 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11420 /// * *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.
11421 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11422 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11423 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseWebAppPatchCall<'a, C>
11424 where
11425 T: AsRef<str>,
11426 {
11427 self._additional_params
11428 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11429 self
11430 }
11431
11432 /// Identifies the authorization scope for the method you are building.
11433 ///
11434 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11435 /// [`Scope::Full`].
11436 ///
11437 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11438 /// tokens for more than one scope.
11439 ///
11440 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11441 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11442 /// sufficient, a read-write scope will do as well.
11443 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseWebAppPatchCall<'a, C>
11444 where
11445 St: AsRef<str>,
11446 {
11447 self._scopes.insert(String::from(scope.as_ref()));
11448 self
11449 }
11450 /// Identifies the authorization scope(s) for the method you are building.
11451 ///
11452 /// See [`Self::add_scope()`] for details.
11453 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseWebAppPatchCall<'a, C>
11454 where
11455 I: IntoIterator<Item = St>,
11456 St: AsRef<str>,
11457 {
11458 self._scopes
11459 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11460 self
11461 }
11462
11463 /// Removes all scopes, and no default scope will be used either.
11464 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11465 /// for details).
11466 pub fn clear_scopes(mut self) -> EnterpriseWebAppPatchCall<'a, C> {
11467 self._scopes.clear();
11468 self
11469 }
11470}
11471
11472/// Creates a web token to access an embeddable managed Google Play web UI for a given enterprise.
11473///
11474/// A builder for the *webTokens.create* method supported by a *enterprise* resource.
11475/// It is not used directly, but through a [`EnterpriseMethods`] instance.
11476///
11477/// # Example
11478///
11479/// Instantiate a resource method builder
11480///
11481/// ```test_harness,no_run
11482/// # extern crate hyper;
11483/// # extern crate hyper_rustls;
11484/// # extern crate google_androidmanagement1 as androidmanagement1;
11485/// use androidmanagement1::api::WebToken;
11486/// # async fn dox() {
11487/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11488///
11489/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11490/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11491/// # secret,
11492/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11493/// # ).build().await.unwrap();
11494///
11495/// # let client = hyper_util::client::legacy::Client::builder(
11496/// # hyper_util::rt::TokioExecutor::new()
11497/// # )
11498/// # .build(
11499/// # hyper_rustls::HttpsConnectorBuilder::new()
11500/// # .with_native_roots()
11501/// # .unwrap()
11502/// # .https_or_http()
11503/// # .enable_http1()
11504/// # .build()
11505/// # );
11506/// # let mut hub = AndroidManagement::new(client, auth);
11507/// // As the method needs a request, you would usually fill it with the desired information
11508/// // into the respective structure. Some of the parts shown here might not be applicable !
11509/// // Values shown here are possibly random and not representative !
11510/// let mut req = WebToken::default();
11511///
11512/// // You can configure optional parameters by calling the respective setters at will, and
11513/// // execute the final call using `doit()`.
11514/// // Values shown here are possibly random and not representative !
11515/// let result = hub.enterprises().web_tokens_create(req, "parent")
11516/// .doit().await;
11517/// # }
11518/// ```
11519pub struct EnterpriseWebTokenCreateCall<'a, C>
11520where
11521 C: 'a,
11522{
11523 hub: &'a AndroidManagement<C>,
11524 _request: WebToken,
11525 _parent: String,
11526 _delegate: Option<&'a mut dyn common::Delegate>,
11527 _additional_params: HashMap<String, String>,
11528 _scopes: BTreeSet<String>,
11529}
11530
11531impl<'a, C> common::CallBuilder for EnterpriseWebTokenCreateCall<'a, C> {}
11532
11533impl<'a, C> EnterpriseWebTokenCreateCall<'a, C>
11534where
11535 C: common::Connector,
11536{
11537 /// Perform the operation you have build so far.
11538 pub async fn doit(mut self) -> common::Result<(common::Response, WebToken)> {
11539 use std::borrow::Cow;
11540 use std::io::{Read, Seek};
11541
11542 use common::{url::Params, ToParts};
11543 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11544
11545 let mut dd = common::DefaultDelegate;
11546 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11547 dlg.begin(common::MethodInfo {
11548 id: "androidmanagement.enterprises.webTokens.create",
11549 http_method: hyper::Method::POST,
11550 });
11551
11552 for &field in ["alt", "parent"].iter() {
11553 if self._additional_params.contains_key(field) {
11554 dlg.finished(false);
11555 return Err(common::Error::FieldClash(field));
11556 }
11557 }
11558
11559 let mut params = Params::with_capacity(4 + self._additional_params.len());
11560 params.push("parent", self._parent);
11561
11562 params.extend(self._additional_params.iter());
11563
11564 params.push("alt", "json");
11565 let mut url = self.hub._base_url.clone() + "v1/{+parent}/webTokens";
11566 if self._scopes.is_empty() {
11567 self._scopes.insert(Scope::Full.as_ref().to_string());
11568 }
11569
11570 #[allow(clippy::single_element_loop)]
11571 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11572 url = params.uri_replacement(url, param_name, find_this, true);
11573 }
11574 {
11575 let to_remove = ["parent"];
11576 params.remove_params(&to_remove);
11577 }
11578
11579 let url = params.parse_with_url(&url);
11580
11581 let mut json_mime_type = mime::APPLICATION_JSON;
11582 let mut request_value_reader = {
11583 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11584 common::remove_json_null_values(&mut value);
11585 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11586 serde_json::to_writer(&mut dst, &value).unwrap();
11587 dst
11588 };
11589 let request_size = request_value_reader
11590 .seek(std::io::SeekFrom::End(0))
11591 .unwrap();
11592 request_value_reader
11593 .seek(std::io::SeekFrom::Start(0))
11594 .unwrap();
11595
11596 loop {
11597 let token = match self
11598 .hub
11599 .auth
11600 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11601 .await
11602 {
11603 Ok(token) => token,
11604 Err(e) => match dlg.token(e) {
11605 Ok(token) => token,
11606 Err(e) => {
11607 dlg.finished(false);
11608 return Err(common::Error::MissingToken(e));
11609 }
11610 },
11611 };
11612 request_value_reader
11613 .seek(std::io::SeekFrom::Start(0))
11614 .unwrap();
11615 let mut req_result = {
11616 let client = &self.hub.client;
11617 dlg.pre_request();
11618 let mut req_builder = hyper::Request::builder()
11619 .method(hyper::Method::POST)
11620 .uri(url.as_str())
11621 .header(USER_AGENT, self.hub._user_agent.clone());
11622
11623 if let Some(token) = token.as_ref() {
11624 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11625 }
11626
11627 let request = req_builder
11628 .header(CONTENT_TYPE, json_mime_type.to_string())
11629 .header(CONTENT_LENGTH, request_size as u64)
11630 .body(common::to_body(
11631 request_value_reader.get_ref().clone().into(),
11632 ));
11633
11634 client.request(request.unwrap()).await
11635 };
11636
11637 match req_result {
11638 Err(err) => {
11639 if let common::Retry::After(d) = dlg.http_error(&err) {
11640 sleep(d).await;
11641 continue;
11642 }
11643 dlg.finished(false);
11644 return Err(common::Error::HttpError(err));
11645 }
11646 Ok(res) => {
11647 let (mut parts, body) = res.into_parts();
11648 let mut body = common::Body::new(body);
11649 if !parts.status.is_success() {
11650 let bytes = common::to_bytes(body).await.unwrap_or_default();
11651 let error = serde_json::from_str(&common::to_string(&bytes));
11652 let response = common::to_response(parts, bytes.into());
11653
11654 if let common::Retry::After(d) =
11655 dlg.http_failure(&response, error.as_ref().ok())
11656 {
11657 sleep(d).await;
11658 continue;
11659 }
11660
11661 dlg.finished(false);
11662
11663 return Err(match error {
11664 Ok(value) => common::Error::BadRequest(value),
11665 _ => common::Error::Failure(response),
11666 });
11667 }
11668 let response = {
11669 let bytes = common::to_bytes(body).await.unwrap_or_default();
11670 let encoded = common::to_string(&bytes);
11671 match serde_json::from_str(&encoded) {
11672 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11673 Err(error) => {
11674 dlg.response_json_decode_error(&encoded, &error);
11675 return Err(common::Error::JsonDecodeError(
11676 encoded.to_string(),
11677 error,
11678 ));
11679 }
11680 }
11681 };
11682
11683 dlg.finished(true);
11684 return Ok(response);
11685 }
11686 }
11687 }
11688 }
11689
11690 ///
11691 /// Sets the *request* property to the given value.
11692 ///
11693 /// Even though the property as already been set when instantiating this call,
11694 /// we provide this method for API completeness.
11695 pub fn request(mut self, new_value: WebToken) -> EnterpriseWebTokenCreateCall<'a, C> {
11696 self._request = new_value;
11697 self
11698 }
11699 /// The name of the enterprise in the form enterprises/{enterpriseId}.
11700 ///
11701 /// Sets the *parent* path property to the given value.
11702 ///
11703 /// Even though the property as already been set when instantiating this call,
11704 /// we provide this method for API completeness.
11705 pub fn parent(mut self, new_value: &str) -> EnterpriseWebTokenCreateCall<'a, C> {
11706 self._parent = new_value.to_string();
11707 self
11708 }
11709 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11710 /// while executing the actual API request.
11711 ///
11712 /// ````text
11713 /// It should be used to handle progress information, and to implement a certain level of resilience.
11714 /// ````
11715 ///
11716 /// Sets the *delegate* property to the given value.
11717 pub fn delegate(
11718 mut self,
11719 new_value: &'a mut dyn common::Delegate,
11720 ) -> EnterpriseWebTokenCreateCall<'a, C> {
11721 self._delegate = Some(new_value);
11722 self
11723 }
11724
11725 /// Set any additional parameter of the query string used in the request.
11726 /// It should be used to set parameters which are not yet available through their own
11727 /// setters.
11728 ///
11729 /// Please note that this method must not be used to set any of the known parameters
11730 /// which have their own setter method. If done anyway, the request will fail.
11731 ///
11732 /// # Additional Parameters
11733 ///
11734 /// * *$.xgafv* (query-string) - V1 error format.
11735 /// * *access_token* (query-string) - OAuth access token.
11736 /// * *alt* (query-string) - Data format for response.
11737 /// * *callback* (query-string) - JSONP
11738 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11739 /// * *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.
11740 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11741 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11742 /// * *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.
11743 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11744 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11745 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseWebTokenCreateCall<'a, C>
11746 where
11747 T: AsRef<str>,
11748 {
11749 self._additional_params
11750 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11751 self
11752 }
11753
11754 /// Identifies the authorization scope for the method you are building.
11755 ///
11756 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11757 /// [`Scope::Full`].
11758 ///
11759 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11760 /// tokens for more than one scope.
11761 ///
11762 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11763 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11764 /// sufficient, a read-write scope will do as well.
11765 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseWebTokenCreateCall<'a, C>
11766 where
11767 St: AsRef<str>,
11768 {
11769 self._scopes.insert(String::from(scope.as_ref()));
11770 self
11771 }
11772 /// Identifies the authorization scope(s) for the method you are building.
11773 ///
11774 /// See [`Self::add_scope()`] for details.
11775 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseWebTokenCreateCall<'a, C>
11776 where
11777 I: IntoIterator<Item = St>,
11778 St: AsRef<str>,
11779 {
11780 self._scopes
11781 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11782 self
11783 }
11784
11785 /// Removes all scopes, and no default scope will be used either.
11786 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11787 /// for details).
11788 pub fn clear_scopes(mut self) -> EnterpriseWebTokenCreateCall<'a, C> {
11789 self._scopes.clear();
11790 self
11791 }
11792}
11793
11794/// Creates an enterprise. This is the last step in the enterprise signup flow. See also: SigninDetail
11795///
11796/// A builder for the *create* method supported by a *enterprise* resource.
11797/// It is not used directly, but through a [`EnterpriseMethods`] instance.
11798///
11799/// # Example
11800///
11801/// Instantiate a resource method builder
11802///
11803/// ```test_harness,no_run
11804/// # extern crate hyper;
11805/// # extern crate hyper_rustls;
11806/// # extern crate google_androidmanagement1 as androidmanagement1;
11807/// use androidmanagement1::api::Enterprise;
11808/// # async fn dox() {
11809/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11810///
11811/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11812/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11813/// # secret,
11814/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11815/// # ).build().await.unwrap();
11816///
11817/// # let client = hyper_util::client::legacy::Client::builder(
11818/// # hyper_util::rt::TokioExecutor::new()
11819/// # )
11820/// # .build(
11821/// # hyper_rustls::HttpsConnectorBuilder::new()
11822/// # .with_native_roots()
11823/// # .unwrap()
11824/// # .https_or_http()
11825/// # .enable_http1()
11826/// # .build()
11827/// # );
11828/// # let mut hub = AndroidManagement::new(client, auth);
11829/// // As the method needs a request, you would usually fill it with the desired information
11830/// // into the respective structure. Some of the parts shown here might not be applicable !
11831/// // Values shown here are possibly random and not representative !
11832/// let mut req = Enterprise::default();
11833///
11834/// // You can configure optional parameters by calling the respective setters at will, and
11835/// // execute the final call using `doit()`.
11836/// // Values shown here are possibly random and not representative !
11837/// let result = hub.enterprises().create(req)
11838/// .signup_url_name("amet.")
11839/// .project_id("consetetur")
11840/// .enterprise_token("diam")
11841/// .agreement_accepted(true)
11842/// .doit().await;
11843/// # }
11844/// ```
11845pub struct EnterpriseCreateCall<'a, C>
11846where
11847 C: 'a,
11848{
11849 hub: &'a AndroidManagement<C>,
11850 _request: Enterprise,
11851 _signup_url_name: Option<String>,
11852 _project_id: Option<String>,
11853 _enterprise_token: Option<String>,
11854 _agreement_accepted: Option<bool>,
11855 _delegate: Option<&'a mut dyn common::Delegate>,
11856 _additional_params: HashMap<String, String>,
11857 _scopes: BTreeSet<String>,
11858}
11859
11860impl<'a, C> common::CallBuilder for EnterpriseCreateCall<'a, C> {}
11861
11862impl<'a, C> EnterpriseCreateCall<'a, C>
11863where
11864 C: common::Connector,
11865{
11866 /// Perform the operation you have build so far.
11867 pub async fn doit(mut self) -> common::Result<(common::Response, Enterprise)> {
11868 use std::borrow::Cow;
11869 use std::io::{Read, Seek};
11870
11871 use common::{url::Params, ToParts};
11872 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11873
11874 let mut dd = common::DefaultDelegate;
11875 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11876 dlg.begin(common::MethodInfo {
11877 id: "androidmanagement.enterprises.create",
11878 http_method: hyper::Method::POST,
11879 });
11880
11881 for &field in [
11882 "alt",
11883 "signupUrlName",
11884 "projectId",
11885 "enterpriseToken",
11886 "agreementAccepted",
11887 ]
11888 .iter()
11889 {
11890 if self._additional_params.contains_key(field) {
11891 dlg.finished(false);
11892 return Err(common::Error::FieldClash(field));
11893 }
11894 }
11895
11896 let mut params = Params::with_capacity(7 + self._additional_params.len());
11897 if let Some(value) = self._signup_url_name.as_ref() {
11898 params.push("signupUrlName", value);
11899 }
11900 if let Some(value) = self._project_id.as_ref() {
11901 params.push("projectId", value);
11902 }
11903 if let Some(value) = self._enterprise_token.as_ref() {
11904 params.push("enterpriseToken", value);
11905 }
11906 if let Some(value) = self._agreement_accepted.as_ref() {
11907 params.push("agreementAccepted", value.to_string());
11908 }
11909
11910 params.extend(self._additional_params.iter());
11911
11912 params.push("alt", "json");
11913 let mut url = self.hub._base_url.clone() + "v1/enterprises";
11914 if self._scopes.is_empty() {
11915 self._scopes.insert(Scope::Full.as_ref().to_string());
11916 }
11917
11918 let url = params.parse_with_url(&url);
11919
11920 let mut json_mime_type = mime::APPLICATION_JSON;
11921 let mut request_value_reader = {
11922 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11923 common::remove_json_null_values(&mut value);
11924 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11925 serde_json::to_writer(&mut dst, &value).unwrap();
11926 dst
11927 };
11928 let request_size = request_value_reader
11929 .seek(std::io::SeekFrom::End(0))
11930 .unwrap();
11931 request_value_reader
11932 .seek(std::io::SeekFrom::Start(0))
11933 .unwrap();
11934
11935 loop {
11936 let token = match self
11937 .hub
11938 .auth
11939 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11940 .await
11941 {
11942 Ok(token) => token,
11943 Err(e) => match dlg.token(e) {
11944 Ok(token) => token,
11945 Err(e) => {
11946 dlg.finished(false);
11947 return Err(common::Error::MissingToken(e));
11948 }
11949 },
11950 };
11951 request_value_reader
11952 .seek(std::io::SeekFrom::Start(0))
11953 .unwrap();
11954 let mut req_result = {
11955 let client = &self.hub.client;
11956 dlg.pre_request();
11957 let mut req_builder = hyper::Request::builder()
11958 .method(hyper::Method::POST)
11959 .uri(url.as_str())
11960 .header(USER_AGENT, self.hub._user_agent.clone());
11961
11962 if let Some(token) = token.as_ref() {
11963 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11964 }
11965
11966 let request = req_builder
11967 .header(CONTENT_TYPE, json_mime_type.to_string())
11968 .header(CONTENT_LENGTH, request_size as u64)
11969 .body(common::to_body(
11970 request_value_reader.get_ref().clone().into(),
11971 ));
11972
11973 client.request(request.unwrap()).await
11974 };
11975
11976 match req_result {
11977 Err(err) => {
11978 if let common::Retry::After(d) = dlg.http_error(&err) {
11979 sleep(d).await;
11980 continue;
11981 }
11982 dlg.finished(false);
11983 return Err(common::Error::HttpError(err));
11984 }
11985 Ok(res) => {
11986 let (mut parts, body) = res.into_parts();
11987 let mut body = common::Body::new(body);
11988 if !parts.status.is_success() {
11989 let bytes = common::to_bytes(body).await.unwrap_or_default();
11990 let error = serde_json::from_str(&common::to_string(&bytes));
11991 let response = common::to_response(parts, bytes.into());
11992
11993 if let common::Retry::After(d) =
11994 dlg.http_failure(&response, error.as_ref().ok())
11995 {
11996 sleep(d).await;
11997 continue;
11998 }
11999
12000 dlg.finished(false);
12001
12002 return Err(match error {
12003 Ok(value) => common::Error::BadRequest(value),
12004 _ => common::Error::Failure(response),
12005 });
12006 }
12007 let response = {
12008 let bytes = common::to_bytes(body).await.unwrap_or_default();
12009 let encoded = common::to_string(&bytes);
12010 match serde_json::from_str(&encoded) {
12011 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12012 Err(error) => {
12013 dlg.response_json_decode_error(&encoded, &error);
12014 return Err(common::Error::JsonDecodeError(
12015 encoded.to_string(),
12016 error,
12017 ));
12018 }
12019 }
12020 };
12021
12022 dlg.finished(true);
12023 return Ok(response);
12024 }
12025 }
12026 }
12027 }
12028
12029 ///
12030 /// Sets the *request* property to the given value.
12031 ///
12032 /// Even though the property as already been set when instantiating this call,
12033 /// we provide this method for API completeness.
12034 pub fn request(mut self, new_value: Enterprise) -> EnterpriseCreateCall<'a, C> {
12035 self._request = new_value;
12036 self
12037 }
12038 /// The name of the SignupUrl used to sign up for the enterprise. Set this when creating a customer-managed enterprise (https://developers.google.com/android/management/create-enterprise#customer-managed_enterprises) and not when creating a deprecated EMM-managed enterprise (https://developers.google.com/android/management/create-enterprise#emm-managed_enterprises).
12039 ///
12040 /// Sets the *signup url name* query property to the given value.
12041 pub fn signup_url_name(mut self, new_value: &str) -> EnterpriseCreateCall<'a, C> {
12042 self._signup_url_name = Some(new_value.to_string());
12043 self
12044 }
12045 /// The ID of the Google Cloud Platform project which will own the enterprise.
12046 ///
12047 /// Sets the *project id* query property to the given value.
12048 pub fn project_id(mut self, new_value: &str) -> EnterpriseCreateCall<'a, C> {
12049 self._project_id = Some(new_value.to_string());
12050 self
12051 }
12052 /// The enterprise token appended to the callback URL. Set this when creating a customer-managed enterprise (https://developers.google.com/android/management/create-enterprise#customer-managed_enterprises) and not when creating a deprecated EMM-managed enterprise (https://developers.google.com/android/management/create-enterprise#emm-managed_enterprises).
12053 ///
12054 /// Sets the *enterprise token* query property to the given value.
12055 pub fn enterprise_token(mut self, new_value: &str) -> EnterpriseCreateCall<'a, C> {
12056 self._enterprise_token = Some(new_value.to_string());
12057 self
12058 }
12059 /// Whether the enterprise admin has seen and agreed to the managed Google Play Agreement (https://www.android.com/enterprise/terms/). Do not set this field for any customer-managed enterprise (https://developers.google.com/android/management/create-enterprise#customer-managed_enterprises). Set this to field to true for all EMM-managed enterprises (https://developers.google.com/android/management/create-enterprise#emm-managed_enterprises).
12060 ///
12061 /// Sets the *agreement accepted* query property to the given value.
12062 pub fn agreement_accepted(mut self, new_value: bool) -> EnterpriseCreateCall<'a, C> {
12063 self._agreement_accepted = Some(new_value);
12064 self
12065 }
12066 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12067 /// while executing the actual API request.
12068 ///
12069 /// ````text
12070 /// It should be used to handle progress information, and to implement a certain level of resilience.
12071 /// ````
12072 ///
12073 /// Sets the *delegate* property to the given value.
12074 pub fn delegate(
12075 mut self,
12076 new_value: &'a mut dyn common::Delegate,
12077 ) -> EnterpriseCreateCall<'a, C> {
12078 self._delegate = Some(new_value);
12079 self
12080 }
12081
12082 /// Set any additional parameter of the query string used in the request.
12083 /// It should be used to set parameters which are not yet available through their own
12084 /// setters.
12085 ///
12086 /// Please note that this method must not be used to set any of the known parameters
12087 /// which have their own setter method. If done anyway, the request will fail.
12088 ///
12089 /// # Additional Parameters
12090 ///
12091 /// * *$.xgafv* (query-string) - V1 error format.
12092 /// * *access_token* (query-string) - OAuth access token.
12093 /// * *alt* (query-string) - Data format for response.
12094 /// * *callback* (query-string) - JSONP
12095 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12096 /// * *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.
12097 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12098 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12099 /// * *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.
12100 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12101 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12102 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseCreateCall<'a, C>
12103 where
12104 T: AsRef<str>,
12105 {
12106 self._additional_params
12107 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12108 self
12109 }
12110
12111 /// Identifies the authorization scope for the method you are building.
12112 ///
12113 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12114 /// [`Scope::Full`].
12115 ///
12116 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12117 /// tokens for more than one scope.
12118 ///
12119 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12120 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12121 /// sufficient, a read-write scope will do as well.
12122 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseCreateCall<'a, C>
12123 where
12124 St: AsRef<str>,
12125 {
12126 self._scopes.insert(String::from(scope.as_ref()));
12127 self
12128 }
12129 /// Identifies the authorization scope(s) for the method you are building.
12130 ///
12131 /// See [`Self::add_scope()`] for details.
12132 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseCreateCall<'a, C>
12133 where
12134 I: IntoIterator<Item = St>,
12135 St: AsRef<str>,
12136 {
12137 self._scopes
12138 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12139 self
12140 }
12141
12142 /// Removes all scopes, and no default scope will be used either.
12143 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12144 /// for details).
12145 pub fn clear_scopes(mut self) -> EnterpriseCreateCall<'a, C> {
12146 self._scopes.clear();
12147 self
12148 }
12149}
12150
12151/// Permanently deletes an enterprise and all accounts and data associated with it. Warning: this will result in a cascaded deletion of all AM API devices associated with the deleted enterprise. Only available for EMM-managed enterprises.
12152///
12153/// A builder for the *delete* method supported by a *enterprise* resource.
12154/// It is not used directly, but through a [`EnterpriseMethods`] instance.
12155///
12156/// # Example
12157///
12158/// Instantiate a resource method builder
12159///
12160/// ```test_harness,no_run
12161/// # extern crate hyper;
12162/// # extern crate hyper_rustls;
12163/// # extern crate google_androidmanagement1 as androidmanagement1;
12164/// # async fn dox() {
12165/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12166///
12167/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12168/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12169/// # secret,
12170/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12171/// # ).build().await.unwrap();
12172///
12173/// # let client = hyper_util::client::legacy::Client::builder(
12174/// # hyper_util::rt::TokioExecutor::new()
12175/// # )
12176/// # .build(
12177/// # hyper_rustls::HttpsConnectorBuilder::new()
12178/// # .with_native_roots()
12179/// # .unwrap()
12180/// # .https_or_http()
12181/// # .enable_http1()
12182/// # .build()
12183/// # );
12184/// # let mut hub = AndroidManagement::new(client, auth);
12185/// // You can configure optional parameters by calling the respective setters at will, and
12186/// // execute the final call using `doit()`.
12187/// // Values shown here are possibly random and not representative !
12188/// let result = hub.enterprises().delete("name")
12189/// .doit().await;
12190/// # }
12191/// ```
12192pub struct EnterpriseDeleteCall<'a, C>
12193where
12194 C: 'a,
12195{
12196 hub: &'a AndroidManagement<C>,
12197 _name: String,
12198 _delegate: Option<&'a mut dyn common::Delegate>,
12199 _additional_params: HashMap<String, String>,
12200 _scopes: BTreeSet<String>,
12201}
12202
12203impl<'a, C> common::CallBuilder for EnterpriseDeleteCall<'a, C> {}
12204
12205impl<'a, C> EnterpriseDeleteCall<'a, C>
12206where
12207 C: common::Connector,
12208{
12209 /// Perform the operation you have build so far.
12210 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
12211 use std::borrow::Cow;
12212 use std::io::{Read, Seek};
12213
12214 use common::{url::Params, ToParts};
12215 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12216
12217 let mut dd = common::DefaultDelegate;
12218 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12219 dlg.begin(common::MethodInfo {
12220 id: "androidmanagement.enterprises.delete",
12221 http_method: hyper::Method::DELETE,
12222 });
12223
12224 for &field in ["alt", "name"].iter() {
12225 if self._additional_params.contains_key(field) {
12226 dlg.finished(false);
12227 return Err(common::Error::FieldClash(field));
12228 }
12229 }
12230
12231 let mut params = Params::with_capacity(3 + self._additional_params.len());
12232 params.push("name", self._name);
12233
12234 params.extend(self._additional_params.iter());
12235
12236 params.push("alt", "json");
12237 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12238 if self._scopes.is_empty() {
12239 self._scopes.insert(Scope::Full.as_ref().to_string());
12240 }
12241
12242 #[allow(clippy::single_element_loop)]
12243 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12244 url = params.uri_replacement(url, param_name, find_this, true);
12245 }
12246 {
12247 let to_remove = ["name"];
12248 params.remove_params(&to_remove);
12249 }
12250
12251 let url = params.parse_with_url(&url);
12252
12253 loop {
12254 let token = match self
12255 .hub
12256 .auth
12257 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12258 .await
12259 {
12260 Ok(token) => token,
12261 Err(e) => match dlg.token(e) {
12262 Ok(token) => token,
12263 Err(e) => {
12264 dlg.finished(false);
12265 return Err(common::Error::MissingToken(e));
12266 }
12267 },
12268 };
12269 let mut req_result = {
12270 let client = &self.hub.client;
12271 dlg.pre_request();
12272 let mut req_builder = hyper::Request::builder()
12273 .method(hyper::Method::DELETE)
12274 .uri(url.as_str())
12275 .header(USER_AGENT, self.hub._user_agent.clone());
12276
12277 if let Some(token) = token.as_ref() {
12278 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12279 }
12280
12281 let request = req_builder
12282 .header(CONTENT_LENGTH, 0_u64)
12283 .body(common::to_body::<String>(None));
12284
12285 client.request(request.unwrap()).await
12286 };
12287
12288 match req_result {
12289 Err(err) => {
12290 if let common::Retry::After(d) = dlg.http_error(&err) {
12291 sleep(d).await;
12292 continue;
12293 }
12294 dlg.finished(false);
12295 return Err(common::Error::HttpError(err));
12296 }
12297 Ok(res) => {
12298 let (mut parts, body) = res.into_parts();
12299 let mut body = common::Body::new(body);
12300 if !parts.status.is_success() {
12301 let bytes = common::to_bytes(body).await.unwrap_or_default();
12302 let error = serde_json::from_str(&common::to_string(&bytes));
12303 let response = common::to_response(parts, bytes.into());
12304
12305 if let common::Retry::After(d) =
12306 dlg.http_failure(&response, error.as_ref().ok())
12307 {
12308 sleep(d).await;
12309 continue;
12310 }
12311
12312 dlg.finished(false);
12313
12314 return Err(match error {
12315 Ok(value) => common::Error::BadRequest(value),
12316 _ => common::Error::Failure(response),
12317 });
12318 }
12319 let response = {
12320 let bytes = common::to_bytes(body).await.unwrap_or_default();
12321 let encoded = common::to_string(&bytes);
12322 match serde_json::from_str(&encoded) {
12323 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12324 Err(error) => {
12325 dlg.response_json_decode_error(&encoded, &error);
12326 return Err(common::Error::JsonDecodeError(
12327 encoded.to_string(),
12328 error,
12329 ));
12330 }
12331 }
12332 };
12333
12334 dlg.finished(true);
12335 return Ok(response);
12336 }
12337 }
12338 }
12339 }
12340
12341 /// The name of the enterprise in the form enterprises/{enterpriseId}.
12342 ///
12343 /// Sets the *name* path property to the given value.
12344 ///
12345 /// Even though the property as already been set when instantiating this call,
12346 /// we provide this method for API completeness.
12347 pub fn name(mut self, new_value: &str) -> EnterpriseDeleteCall<'a, C> {
12348 self._name = new_value.to_string();
12349 self
12350 }
12351 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12352 /// while executing the actual API request.
12353 ///
12354 /// ````text
12355 /// It should be used to handle progress information, and to implement a certain level of resilience.
12356 /// ````
12357 ///
12358 /// Sets the *delegate* property to the given value.
12359 pub fn delegate(
12360 mut self,
12361 new_value: &'a mut dyn common::Delegate,
12362 ) -> EnterpriseDeleteCall<'a, C> {
12363 self._delegate = Some(new_value);
12364 self
12365 }
12366
12367 /// Set any additional parameter of the query string used in the request.
12368 /// It should be used to set parameters which are not yet available through their own
12369 /// setters.
12370 ///
12371 /// Please note that this method must not be used to set any of the known parameters
12372 /// which have their own setter method. If done anyway, the request will fail.
12373 ///
12374 /// # Additional Parameters
12375 ///
12376 /// * *$.xgafv* (query-string) - V1 error format.
12377 /// * *access_token* (query-string) - OAuth access token.
12378 /// * *alt* (query-string) - Data format for response.
12379 /// * *callback* (query-string) - JSONP
12380 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12381 /// * *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.
12382 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12383 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12384 /// * *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.
12385 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12386 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12387 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseDeleteCall<'a, C>
12388 where
12389 T: AsRef<str>,
12390 {
12391 self._additional_params
12392 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12393 self
12394 }
12395
12396 /// Identifies the authorization scope for the method you are building.
12397 ///
12398 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12399 /// [`Scope::Full`].
12400 ///
12401 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12402 /// tokens for more than one scope.
12403 ///
12404 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12405 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12406 /// sufficient, a read-write scope will do as well.
12407 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseDeleteCall<'a, C>
12408 where
12409 St: AsRef<str>,
12410 {
12411 self._scopes.insert(String::from(scope.as_ref()));
12412 self
12413 }
12414 /// Identifies the authorization scope(s) for the method you are building.
12415 ///
12416 /// See [`Self::add_scope()`] for details.
12417 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseDeleteCall<'a, C>
12418 where
12419 I: IntoIterator<Item = St>,
12420 St: AsRef<str>,
12421 {
12422 self._scopes
12423 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12424 self
12425 }
12426
12427 /// Removes all scopes, and no default scope will be used either.
12428 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12429 /// for details).
12430 pub fn clear_scopes(mut self) -> EnterpriseDeleteCall<'a, C> {
12431 self._scopes.clear();
12432 self
12433 }
12434}
12435
12436/// Gets an enterprise.
12437///
12438/// A builder for the *get* method supported by a *enterprise* resource.
12439/// It is not used directly, but through a [`EnterpriseMethods`] instance.
12440///
12441/// # Example
12442///
12443/// Instantiate a resource method builder
12444///
12445/// ```test_harness,no_run
12446/// # extern crate hyper;
12447/// # extern crate hyper_rustls;
12448/// # extern crate google_androidmanagement1 as androidmanagement1;
12449/// # async fn dox() {
12450/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12451///
12452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12453/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12454/// # secret,
12455/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12456/// # ).build().await.unwrap();
12457///
12458/// # let client = hyper_util::client::legacy::Client::builder(
12459/// # hyper_util::rt::TokioExecutor::new()
12460/// # )
12461/// # .build(
12462/// # hyper_rustls::HttpsConnectorBuilder::new()
12463/// # .with_native_roots()
12464/// # .unwrap()
12465/// # .https_or_http()
12466/// # .enable_http1()
12467/// # .build()
12468/// # );
12469/// # let mut hub = AndroidManagement::new(client, auth);
12470/// // You can configure optional parameters by calling the respective setters at will, and
12471/// // execute the final call using `doit()`.
12472/// // Values shown here are possibly random and not representative !
12473/// let result = hub.enterprises().get("name")
12474/// .doit().await;
12475/// # }
12476/// ```
12477pub struct EnterpriseGetCall<'a, C>
12478where
12479 C: 'a,
12480{
12481 hub: &'a AndroidManagement<C>,
12482 _name: String,
12483 _delegate: Option<&'a mut dyn common::Delegate>,
12484 _additional_params: HashMap<String, String>,
12485 _scopes: BTreeSet<String>,
12486}
12487
12488impl<'a, C> common::CallBuilder for EnterpriseGetCall<'a, C> {}
12489
12490impl<'a, C> EnterpriseGetCall<'a, C>
12491where
12492 C: common::Connector,
12493{
12494 /// Perform the operation you have build so far.
12495 pub async fn doit(mut self) -> common::Result<(common::Response, Enterprise)> {
12496 use std::borrow::Cow;
12497 use std::io::{Read, Seek};
12498
12499 use common::{url::Params, ToParts};
12500 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12501
12502 let mut dd = common::DefaultDelegate;
12503 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12504 dlg.begin(common::MethodInfo {
12505 id: "androidmanagement.enterprises.get",
12506 http_method: hyper::Method::GET,
12507 });
12508
12509 for &field in ["alt", "name"].iter() {
12510 if self._additional_params.contains_key(field) {
12511 dlg.finished(false);
12512 return Err(common::Error::FieldClash(field));
12513 }
12514 }
12515
12516 let mut params = Params::with_capacity(3 + self._additional_params.len());
12517 params.push("name", self._name);
12518
12519 params.extend(self._additional_params.iter());
12520
12521 params.push("alt", "json");
12522 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12523 if self._scopes.is_empty() {
12524 self._scopes.insert(Scope::Full.as_ref().to_string());
12525 }
12526
12527 #[allow(clippy::single_element_loop)]
12528 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12529 url = params.uri_replacement(url, param_name, find_this, true);
12530 }
12531 {
12532 let to_remove = ["name"];
12533 params.remove_params(&to_remove);
12534 }
12535
12536 let url = params.parse_with_url(&url);
12537
12538 loop {
12539 let token = match self
12540 .hub
12541 .auth
12542 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12543 .await
12544 {
12545 Ok(token) => token,
12546 Err(e) => match dlg.token(e) {
12547 Ok(token) => token,
12548 Err(e) => {
12549 dlg.finished(false);
12550 return Err(common::Error::MissingToken(e));
12551 }
12552 },
12553 };
12554 let mut req_result = {
12555 let client = &self.hub.client;
12556 dlg.pre_request();
12557 let mut req_builder = hyper::Request::builder()
12558 .method(hyper::Method::GET)
12559 .uri(url.as_str())
12560 .header(USER_AGENT, self.hub._user_agent.clone());
12561
12562 if let Some(token) = token.as_ref() {
12563 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12564 }
12565
12566 let request = req_builder
12567 .header(CONTENT_LENGTH, 0_u64)
12568 .body(common::to_body::<String>(None));
12569
12570 client.request(request.unwrap()).await
12571 };
12572
12573 match req_result {
12574 Err(err) => {
12575 if let common::Retry::After(d) = dlg.http_error(&err) {
12576 sleep(d).await;
12577 continue;
12578 }
12579 dlg.finished(false);
12580 return Err(common::Error::HttpError(err));
12581 }
12582 Ok(res) => {
12583 let (mut parts, body) = res.into_parts();
12584 let mut body = common::Body::new(body);
12585 if !parts.status.is_success() {
12586 let bytes = common::to_bytes(body).await.unwrap_or_default();
12587 let error = serde_json::from_str(&common::to_string(&bytes));
12588 let response = common::to_response(parts, bytes.into());
12589
12590 if let common::Retry::After(d) =
12591 dlg.http_failure(&response, error.as_ref().ok())
12592 {
12593 sleep(d).await;
12594 continue;
12595 }
12596
12597 dlg.finished(false);
12598
12599 return Err(match error {
12600 Ok(value) => common::Error::BadRequest(value),
12601 _ => common::Error::Failure(response),
12602 });
12603 }
12604 let response = {
12605 let bytes = common::to_bytes(body).await.unwrap_or_default();
12606 let encoded = common::to_string(&bytes);
12607 match serde_json::from_str(&encoded) {
12608 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12609 Err(error) => {
12610 dlg.response_json_decode_error(&encoded, &error);
12611 return Err(common::Error::JsonDecodeError(
12612 encoded.to_string(),
12613 error,
12614 ));
12615 }
12616 }
12617 };
12618
12619 dlg.finished(true);
12620 return Ok(response);
12621 }
12622 }
12623 }
12624 }
12625
12626 /// The name of the enterprise in the form enterprises/{enterpriseId}.
12627 ///
12628 /// Sets the *name* path property to the given value.
12629 ///
12630 /// Even though the property as already been set when instantiating this call,
12631 /// we provide this method for API completeness.
12632 pub fn name(mut self, new_value: &str) -> EnterpriseGetCall<'a, C> {
12633 self._name = new_value.to_string();
12634 self
12635 }
12636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12637 /// while executing the actual API request.
12638 ///
12639 /// ````text
12640 /// It should be used to handle progress information, and to implement a certain level of resilience.
12641 /// ````
12642 ///
12643 /// Sets the *delegate* property to the given value.
12644 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EnterpriseGetCall<'a, C> {
12645 self._delegate = Some(new_value);
12646 self
12647 }
12648
12649 /// Set any additional parameter of the query string used in the request.
12650 /// It should be used to set parameters which are not yet available through their own
12651 /// setters.
12652 ///
12653 /// Please note that this method must not be used to set any of the known parameters
12654 /// which have their own setter method. If done anyway, the request will fail.
12655 ///
12656 /// # Additional Parameters
12657 ///
12658 /// * *$.xgafv* (query-string) - V1 error format.
12659 /// * *access_token* (query-string) - OAuth access token.
12660 /// * *alt* (query-string) - Data format for response.
12661 /// * *callback* (query-string) - JSONP
12662 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12663 /// * *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.
12664 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12665 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12666 /// * *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.
12667 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12668 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12669 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseGetCall<'a, C>
12670 where
12671 T: AsRef<str>,
12672 {
12673 self._additional_params
12674 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12675 self
12676 }
12677
12678 /// Identifies the authorization scope for the method you are building.
12679 ///
12680 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12681 /// [`Scope::Full`].
12682 ///
12683 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12684 /// tokens for more than one scope.
12685 ///
12686 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12687 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12688 /// sufficient, a read-write scope will do as well.
12689 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseGetCall<'a, C>
12690 where
12691 St: AsRef<str>,
12692 {
12693 self._scopes.insert(String::from(scope.as_ref()));
12694 self
12695 }
12696 /// Identifies the authorization scope(s) for the method you are building.
12697 ///
12698 /// See [`Self::add_scope()`] for details.
12699 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseGetCall<'a, C>
12700 where
12701 I: IntoIterator<Item = St>,
12702 St: AsRef<str>,
12703 {
12704 self._scopes
12705 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12706 self
12707 }
12708
12709 /// Removes all scopes, and no default scope will be used either.
12710 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12711 /// for details).
12712 pub fn clear_scopes(mut self) -> EnterpriseGetCall<'a, C> {
12713 self._scopes.clear();
12714 self
12715 }
12716}
12717
12718/// Lists EMM-managed enterprises. Only BASIC fields are returned.
12719///
12720/// A builder for the *list* method supported by a *enterprise* resource.
12721/// It is not used directly, but through a [`EnterpriseMethods`] instance.
12722///
12723/// # Example
12724///
12725/// Instantiate a resource method builder
12726///
12727/// ```test_harness,no_run
12728/// # extern crate hyper;
12729/// # extern crate hyper_rustls;
12730/// # extern crate google_androidmanagement1 as androidmanagement1;
12731/// # async fn dox() {
12732/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12733///
12734/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12735/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12736/// # secret,
12737/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12738/// # ).build().await.unwrap();
12739///
12740/// # let client = hyper_util::client::legacy::Client::builder(
12741/// # hyper_util::rt::TokioExecutor::new()
12742/// # )
12743/// # .build(
12744/// # hyper_rustls::HttpsConnectorBuilder::new()
12745/// # .with_native_roots()
12746/// # .unwrap()
12747/// # .https_or_http()
12748/// # .enable_http1()
12749/// # .build()
12750/// # );
12751/// # let mut hub = AndroidManagement::new(client, auth);
12752/// // You can configure optional parameters by calling the respective setters at will, and
12753/// // execute the final call using `doit()`.
12754/// // Values shown here are possibly random and not representative !
12755/// let result = hub.enterprises().list()
12756/// .view("sadipscing")
12757/// .project_id("Stet")
12758/// .page_token("dolor")
12759/// .page_size(-20)
12760/// .doit().await;
12761/// # }
12762/// ```
12763pub struct EnterpriseListCall<'a, C>
12764where
12765 C: 'a,
12766{
12767 hub: &'a AndroidManagement<C>,
12768 _view: Option<String>,
12769 _project_id: Option<String>,
12770 _page_token: Option<String>,
12771 _page_size: Option<i32>,
12772 _delegate: Option<&'a mut dyn common::Delegate>,
12773 _additional_params: HashMap<String, String>,
12774 _scopes: BTreeSet<String>,
12775}
12776
12777impl<'a, C> common::CallBuilder for EnterpriseListCall<'a, C> {}
12778
12779impl<'a, C> EnterpriseListCall<'a, C>
12780where
12781 C: common::Connector,
12782{
12783 /// Perform the operation you have build so far.
12784 pub async fn doit(mut self) -> common::Result<(common::Response, ListEnterprisesResponse)> {
12785 use std::borrow::Cow;
12786 use std::io::{Read, Seek};
12787
12788 use common::{url::Params, ToParts};
12789 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12790
12791 let mut dd = common::DefaultDelegate;
12792 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12793 dlg.begin(common::MethodInfo {
12794 id: "androidmanagement.enterprises.list",
12795 http_method: hyper::Method::GET,
12796 });
12797
12798 for &field in ["alt", "view", "projectId", "pageToken", "pageSize"].iter() {
12799 if self._additional_params.contains_key(field) {
12800 dlg.finished(false);
12801 return Err(common::Error::FieldClash(field));
12802 }
12803 }
12804
12805 let mut params = Params::with_capacity(6 + self._additional_params.len());
12806 if let Some(value) = self._view.as_ref() {
12807 params.push("view", value);
12808 }
12809 if let Some(value) = self._project_id.as_ref() {
12810 params.push("projectId", value);
12811 }
12812 if let Some(value) = self._page_token.as_ref() {
12813 params.push("pageToken", value);
12814 }
12815 if let Some(value) = self._page_size.as_ref() {
12816 params.push("pageSize", value.to_string());
12817 }
12818
12819 params.extend(self._additional_params.iter());
12820
12821 params.push("alt", "json");
12822 let mut url = self.hub._base_url.clone() + "v1/enterprises";
12823 if self._scopes.is_empty() {
12824 self._scopes.insert(Scope::Full.as_ref().to_string());
12825 }
12826
12827 let url = params.parse_with_url(&url);
12828
12829 loop {
12830 let token = match self
12831 .hub
12832 .auth
12833 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12834 .await
12835 {
12836 Ok(token) => token,
12837 Err(e) => match dlg.token(e) {
12838 Ok(token) => token,
12839 Err(e) => {
12840 dlg.finished(false);
12841 return Err(common::Error::MissingToken(e));
12842 }
12843 },
12844 };
12845 let mut req_result = {
12846 let client = &self.hub.client;
12847 dlg.pre_request();
12848 let mut req_builder = hyper::Request::builder()
12849 .method(hyper::Method::GET)
12850 .uri(url.as_str())
12851 .header(USER_AGENT, self.hub._user_agent.clone());
12852
12853 if let Some(token) = token.as_ref() {
12854 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12855 }
12856
12857 let request = req_builder
12858 .header(CONTENT_LENGTH, 0_u64)
12859 .body(common::to_body::<String>(None));
12860
12861 client.request(request.unwrap()).await
12862 };
12863
12864 match req_result {
12865 Err(err) => {
12866 if let common::Retry::After(d) = dlg.http_error(&err) {
12867 sleep(d).await;
12868 continue;
12869 }
12870 dlg.finished(false);
12871 return Err(common::Error::HttpError(err));
12872 }
12873 Ok(res) => {
12874 let (mut parts, body) = res.into_parts();
12875 let mut body = common::Body::new(body);
12876 if !parts.status.is_success() {
12877 let bytes = common::to_bytes(body).await.unwrap_or_default();
12878 let error = serde_json::from_str(&common::to_string(&bytes));
12879 let response = common::to_response(parts, bytes.into());
12880
12881 if let common::Retry::After(d) =
12882 dlg.http_failure(&response, error.as_ref().ok())
12883 {
12884 sleep(d).await;
12885 continue;
12886 }
12887
12888 dlg.finished(false);
12889
12890 return Err(match error {
12891 Ok(value) => common::Error::BadRequest(value),
12892 _ => common::Error::Failure(response),
12893 });
12894 }
12895 let response = {
12896 let bytes = common::to_bytes(body).await.unwrap_or_default();
12897 let encoded = common::to_string(&bytes);
12898 match serde_json::from_str(&encoded) {
12899 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12900 Err(error) => {
12901 dlg.response_json_decode_error(&encoded, &error);
12902 return Err(common::Error::JsonDecodeError(
12903 encoded.to_string(),
12904 error,
12905 ));
12906 }
12907 }
12908 };
12909
12910 dlg.finished(true);
12911 return Ok(response);
12912 }
12913 }
12914 }
12915 }
12916
12917 /// Specifies which Enterprise fields to return. This method only supports BASIC.
12918 ///
12919 /// Sets the *view* query property to the given value.
12920 pub fn view(mut self, new_value: &str) -> EnterpriseListCall<'a, C> {
12921 self._view = Some(new_value.to_string());
12922 self
12923 }
12924 /// Required. The Cloud project ID of the EMM managing the enterprises.
12925 ///
12926 /// Sets the *project id* query property to the given value.
12927 pub fn project_id(mut self, new_value: &str) -> EnterpriseListCall<'a, C> {
12928 self._project_id = Some(new_value.to_string());
12929 self
12930 }
12931 /// A token identifying a page of results returned by the server.
12932 ///
12933 /// Sets the *page token* query property to the given value.
12934 pub fn page_token(mut self, new_value: &str) -> EnterpriseListCall<'a, C> {
12935 self._page_token = Some(new_value.to_string());
12936 self
12937 }
12938 /// The requested page size. The actual page size may be fixed to a min or max value.
12939 ///
12940 /// Sets the *page size* query property to the given value.
12941 pub fn page_size(mut self, new_value: i32) -> EnterpriseListCall<'a, C> {
12942 self._page_size = Some(new_value);
12943 self
12944 }
12945 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12946 /// while executing the actual API request.
12947 ///
12948 /// ````text
12949 /// It should be used to handle progress information, and to implement a certain level of resilience.
12950 /// ````
12951 ///
12952 /// Sets the *delegate* property to the given value.
12953 pub fn delegate(
12954 mut self,
12955 new_value: &'a mut dyn common::Delegate,
12956 ) -> EnterpriseListCall<'a, C> {
12957 self._delegate = Some(new_value);
12958 self
12959 }
12960
12961 /// Set any additional parameter of the query string used in the request.
12962 /// It should be used to set parameters which are not yet available through their own
12963 /// setters.
12964 ///
12965 /// Please note that this method must not be used to set any of the known parameters
12966 /// which have their own setter method. If done anyway, the request will fail.
12967 ///
12968 /// # Additional Parameters
12969 ///
12970 /// * *$.xgafv* (query-string) - V1 error format.
12971 /// * *access_token* (query-string) - OAuth access token.
12972 /// * *alt* (query-string) - Data format for response.
12973 /// * *callback* (query-string) - JSONP
12974 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12975 /// * *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.
12976 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12977 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12978 /// * *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.
12979 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12980 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12981 pub fn param<T>(mut self, name: T, value: T) -> EnterpriseListCall<'a, C>
12982 where
12983 T: AsRef<str>,
12984 {
12985 self._additional_params
12986 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12987 self
12988 }
12989
12990 /// Identifies the authorization scope for the method you are building.
12991 ///
12992 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12993 /// [`Scope::Full`].
12994 ///
12995 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12996 /// tokens for more than one scope.
12997 ///
12998 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12999 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13000 /// sufficient, a read-write scope will do as well.
13001 pub fn add_scope<St>(mut self, scope: St) -> EnterpriseListCall<'a, C>
13002 where
13003 St: AsRef<str>,
13004 {
13005 self._scopes.insert(String::from(scope.as_ref()));
13006 self
13007 }
13008 /// Identifies the authorization scope(s) for the method you are building.
13009 ///
13010 /// See [`Self::add_scope()`] for details.
13011 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterpriseListCall<'a, C>
13012 where
13013 I: IntoIterator<Item = St>,
13014 St: AsRef<str>,
13015 {
13016 self._scopes
13017 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13018 self
13019 }
13020
13021 /// Removes all scopes, and no default scope will be used either.
13022 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13023 /// for details).
13024 pub fn clear_scopes(mut self) -> EnterpriseListCall<'a, C> {
13025 self._scopes.clear();
13026 self
13027 }
13028}
13029
13030/// Updates an enterprise. See also: SigninDetail
13031///
13032/// A builder for the *patch* method supported by a *enterprise* resource.
13033/// It is not used directly, but through a [`EnterpriseMethods`] instance.
13034///
13035/// # Example
13036///
13037/// Instantiate a resource method builder
13038///
13039/// ```test_harness,no_run
13040/// # extern crate hyper;
13041/// # extern crate hyper_rustls;
13042/// # extern crate google_androidmanagement1 as androidmanagement1;
13043/// use androidmanagement1::api::Enterprise;
13044/// # async fn dox() {
13045/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13046///
13047/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13048/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13049/// # secret,
13050/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13051/// # ).build().await.unwrap();
13052///
13053/// # let client = hyper_util::client::legacy::Client::builder(
13054/// # hyper_util::rt::TokioExecutor::new()
13055/// # )
13056/// # .build(
13057/// # hyper_rustls::HttpsConnectorBuilder::new()
13058/// # .with_native_roots()
13059/// # .unwrap()
13060/// # .https_or_http()
13061/// # .enable_http1()
13062/// # .build()
13063/// # );
13064/// # let mut hub = AndroidManagement::new(client, auth);
13065/// // As the method needs a request, you would usually fill it with the desired information
13066/// // into the respective structure. Some of the parts shown here might not be applicable !
13067/// // Values shown here are possibly random and not representative !
13068/// let mut req = Enterprise::default();
13069///
13070/// // You can configure optional parameters by calling the respective setters at will, and
13071/// // execute the final call using `doit()`.
13072/// // Values shown here are possibly random and not representative !
13073/// let result = hub.enterprises().patch(req, "name")
13074/// .update_mask(FieldMask::new::<&str>(&[]))
13075/// .doit().await;
13076/// # }
13077/// ```
13078pub struct EnterprisePatchCall<'a, C>
13079where
13080 C: 'a,
13081{
13082 hub: &'a AndroidManagement<C>,
13083 _request: Enterprise,
13084 _name: String,
13085 _update_mask: Option<common::FieldMask>,
13086 _delegate: Option<&'a mut dyn common::Delegate>,
13087 _additional_params: HashMap<String, String>,
13088 _scopes: BTreeSet<String>,
13089}
13090
13091impl<'a, C> common::CallBuilder for EnterprisePatchCall<'a, C> {}
13092
13093impl<'a, C> EnterprisePatchCall<'a, C>
13094where
13095 C: common::Connector,
13096{
13097 /// Perform the operation you have build so far.
13098 pub async fn doit(mut self) -> common::Result<(common::Response, Enterprise)> {
13099 use std::borrow::Cow;
13100 use std::io::{Read, Seek};
13101
13102 use common::{url::Params, ToParts};
13103 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13104
13105 let mut dd = common::DefaultDelegate;
13106 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13107 dlg.begin(common::MethodInfo {
13108 id: "androidmanagement.enterprises.patch",
13109 http_method: hyper::Method::PATCH,
13110 });
13111
13112 for &field in ["alt", "name", "updateMask"].iter() {
13113 if self._additional_params.contains_key(field) {
13114 dlg.finished(false);
13115 return Err(common::Error::FieldClash(field));
13116 }
13117 }
13118
13119 let mut params = Params::with_capacity(5 + self._additional_params.len());
13120 params.push("name", self._name);
13121 if let Some(value) = self._update_mask.as_ref() {
13122 params.push("updateMask", value.to_string());
13123 }
13124
13125 params.extend(self._additional_params.iter());
13126
13127 params.push("alt", "json");
13128 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13129 if self._scopes.is_empty() {
13130 self._scopes.insert(Scope::Full.as_ref().to_string());
13131 }
13132
13133 #[allow(clippy::single_element_loop)]
13134 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13135 url = params.uri_replacement(url, param_name, find_this, true);
13136 }
13137 {
13138 let to_remove = ["name"];
13139 params.remove_params(&to_remove);
13140 }
13141
13142 let url = params.parse_with_url(&url);
13143
13144 let mut json_mime_type = mime::APPLICATION_JSON;
13145 let mut request_value_reader = {
13146 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13147 common::remove_json_null_values(&mut value);
13148 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13149 serde_json::to_writer(&mut dst, &value).unwrap();
13150 dst
13151 };
13152 let request_size = request_value_reader
13153 .seek(std::io::SeekFrom::End(0))
13154 .unwrap();
13155 request_value_reader
13156 .seek(std::io::SeekFrom::Start(0))
13157 .unwrap();
13158
13159 loop {
13160 let token = match self
13161 .hub
13162 .auth
13163 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13164 .await
13165 {
13166 Ok(token) => token,
13167 Err(e) => match dlg.token(e) {
13168 Ok(token) => token,
13169 Err(e) => {
13170 dlg.finished(false);
13171 return Err(common::Error::MissingToken(e));
13172 }
13173 },
13174 };
13175 request_value_reader
13176 .seek(std::io::SeekFrom::Start(0))
13177 .unwrap();
13178 let mut req_result = {
13179 let client = &self.hub.client;
13180 dlg.pre_request();
13181 let mut req_builder = hyper::Request::builder()
13182 .method(hyper::Method::PATCH)
13183 .uri(url.as_str())
13184 .header(USER_AGENT, self.hub._user_agent.clone());
13185
13186 if let Some(token) = token.as_ref() {
13187 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13188 }
13189
13190 let request = req_builder
13191 .header(CONTENT_TYPE, json_mime_type.to_string())
13192 .header(CONTENT_LENGTH, request_size as u64)
13193 .body(common::to_body(
13194 request_value_reader.get_ref().clone().into(),
13195 ));
13196
13197 client.request(request.unwrap()).await
13198 };
13199
13200 match req_result {
13201 Err(err) => {
13202 if let common::Retry::After(d) = dlg.http_error(&err) {
13203 sleep(d).await;
13204 continue;
13205 }
13206 dlg.finished(false);
13207 return Err(common::Error::HttpError(err));
13208 }
13209 Ok(res) => {
13210 let (mut parts, body) = res.into_parts();
13211 let mut body = common::Body::new(body);
13212 if !parts.status.is_success() {
13213 let bytes = common::to_bytes(body).await.unwrap_or_default();
13214 let error = serde_json::from_str(&common::to_string(&bytes));
13215 let response = common::to_response(parts, bytes.into());
13216
13217 if let common::Retry::After(d) =
13218 dlg.http_failure(&response, error.as_ref().ok())
13219 {
13220 sleep(d).await;
13221 continue;
13222 }
13223
13224 dlg.finished(false);
13225
13226 return Err(match error {
13227 Ok(value) => common::Error::BadRequest(value),
13228 _ => common::Error::Failure(response),
13229 });
13230 }
13231 let response = {
13232 let bytes = common::to_bytes(body).await.unwrap_or_default();
13233 let encoded = common::to_string(&bytes);
13234 match serde_json::from_str(&encoded) {
13235 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13236 Err(error) => {
13237 dlg.response_json_decode_error(&encoded, &error);
13238 return Err(common::Error::JsonDecodeError(
13239 encoded.to_string(),
13240 error,
13241 ));
13242 }
13243 }
13244 };
13245
13246 dlg.finished(true);
13247 return Ok(response);
13248 }
13249 }
13250 }
13251 }
13252
13253 ///
13254 /// Sets the *request* property to the given value.
13255 ///
13256 /// Even though the property as already been set when instantiating this call,
13257 /// we provide this method for API completeness.
13258 pub fn request(mut self, new_value: Enterprise) -> EnterprisePatchCall<'a, C> {
13259 self._request = new_value;
13260 self
13261 }
13262 /// The name of the enterprise in the form enterprises/{enterpriseId}.
13263 ///
13264 /// Sets the *name* path property to the given value.
13265 ///
13266 /// Even though the property as already been set when instantiating this call,
13267 /// we provide this method for API completeness.
13268 pub fn name(mut self, new_value: &str) -> EnterprisePatchCall<'a, C> {
13269 self._name = new_value.to_string();
13270 self
13271 }
13272 /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified.
13273 ///
13274 /// Sets the *update mask* query property to the given value.
13275 pub fn update_mask(mut self, new_value: common::FieldMask) -> EnterprisePatchCall<'a, C> {
13276 self._update_mask = Some(new_value);
13277 self
13278 }
13279 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13280 /// while executing the actual API request.
13281 ///
13282 /// ````text
13283 /// It should be used to handle progress information, and to implement a certain level of resilience.
13284 /// ````
13285 ///
13286 /// Sets the *delegate* property to the given value.
13287 pub fn delegate(
13288 mut self,
13289 new_value: &'a mut dyn common::Delegate,
13290 ) -> EnterprisePatchCall<'a, C> {
13291 self._delegate = Some(new_value);
13292 self
13293 }
13294
13295 /// Set any additional parameter of the query string used in the request.
13296 /// It should be used to set parameters which are not yet available through their own
13297 /// setters.
13298 ///
13299 /// Please note that this method must not be used to set any of the known parameters
13300 /// which have their own setter method. If done anyway, the request will fail.
13301 ///
13302 /// # Additional Parameters
13303 ///
13304 /// * *$.xgafv* (query-string) - V1 error format.
13305 /// * *access_token* (query-string) - OAuth access token.
13306 /// * *alt* (query-string) - Data format for response.
13307 /// * *callback* (query-string) - JSONP
13308 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13309 /// * *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.
13310 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13311 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13312 /// * *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.
13313 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13314 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13315 pub fn param<T>(mut self, name: T, value: T) -> EnterprisePatchCall<'a, C>
13316 where
13317 T: AsRef<str>,
13318 {
13319 self._additional_params
13320 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13321 self
13322 }
13323
13324 /// Identifies the authorization scope for the method you are building.
13325 ///
13326 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13327 /// [`Scope::Full`].
13328 ///
13329 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13330 /// tokens for more than one scope.
13331 ///
13332 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13333 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13334 /// sufficient, a read-write scope will do as well.
13335 pub fn add_scope<St>(mut self, scope: St) -> EnterprisePatchCall<'a, C>
13336 where
13337 St: AsRef<str>,
13338 {
13339 self._scopes.insert(String::from(scope.as_ref()));
13340 self
13341 }
13342 /// Identifies the authorization scope(s) for the method you are building.
13343 ///
13344 /// See [`Self::add_scope()`] for details.
13345 pub fn add_scopes<I, St>(mut self, scopes: I) -> EnterprisePatchCall<'a, C>
13346 where
13347 I: IntoIterator<Item = St>,
13348 St: AsRef<str>,
13349 {
13350 self._scopes
13351 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13352 self
13353 }
13354
13355 /// Removes all scopes, and no default scope will be used either.
13356 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13357 /// for details).
13358 pub fn clear_scopes(mut self) -> EnterprisePatchCall<'a, C> {
13359 self._scopes.clear();
13360 self
13361 }
13362}
13363
13364/// Get the device provisioning information by the identifier provided in the sign-in url.
13365///
13366/// A builder for the *get* method supported by a *provisioningInfo* resource.
13367/// It is not used directly, but through a [`ProvisioningInfoMethods`] instance.
13368///
13369/// # Example
13370///
13371/// Instantiate a resource method builder
13372///
13373/// ```test_harness,no_run
13374/// # extern crate hyper;
13375/// # extern crate hyper_rustls;
13376/// # extern crate google_androidmanagement1 as androidmanagement1;
13377/// # async fn dox() {
13378/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13379///
13380/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13381/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13382/// # secret,
13383/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13384/// # ).build().await.unwrap();
13385///
13386/// # let client = hyper_util::client::legacy::Client::builder(
13387/// # hyper_util::rt::TokioExecutor::new()
13388/// # )
13389/// # .build(
13390/// # hyper_rustls::HttpsConnectorBuilder::new()
13391/// # .with_native_roots()
13392/// # .unwrap()
13393/// # .https_or_http()
13394/// # .enable_http1()
13395/// # .build()
13396/// # );
13397/// # let mut hub = AndroidManagement::new(client, auth);
13398/// // You can configure optional parameters by calling the respective setters at will, and
13399/// // execute the final call using `doit()`.
13400/// // Values shown here are possibly random and not representative !
13401/// let result = hub.provisioning_info().get("name")
13402/// .doit().await;
13403/// # }
13404/// ```
13405pub struct ProvisioningInfoGetCall<'a, C>
13406where
13407 C: 'a,
13408{
13409 hub: &'a AndroidManagement<C>,
13410 _name: String,
13411 _delegate: Option<&'a mut dyn common::Delegate>,
13412 _additional_params: HashMap<String, String>,
13413 _scopes: BTreeSet<String>,
13414}
13415
13416impl<'a, C> common::CallBuilder for ProvisioningInfoGetCall<'a, C> {}
13417
13418impl<'a, C> ProvisioningInfoGetCall<'a, C>
13419where
13420 C: common::Connector,
13421{
13422 /// Perform the operation you have build so far.
13423 pub async fn doit(mut self) -> common::Result<(common::Response, ProvisioningInfo)> {
13424 use std::borrow::Cow;
13425 use std::io::{Read, Seek};
13426
13427 use common::{url::Params, ToParts};
13428 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13429
13430 let mut dd = common::DefaultDelegate;
13431 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13432 dlg.begin(common::MethodInfo {
13433 id: "androidmanagement.provisioningInfo.get",
13434 http_method: hyper::Method::GET,
13435 });
13436
13437 for &field in ["alt", "name"].iter() {
13438 if self._additional_params.contains_key(field) {
13439 dlg.finished(false);
13440 return Err(common::Error::FieldClash(field));
13441 }
13442 }
13443
13444 let mut params = Params::with_capacity(3 + self._additional_params.len());
13445 params.push("name", self._name);
13446
13447 params.extend(self._additional_params.iter());
13448
13449 params.push("alt", "json");
13450 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13451 if self._scopes.is_empty() {
13452 self._scopes.insert(Scope::Full.as_ref().to_string());
13453 }
13454
13455 #[allow(clippy::single_element_loop)]
13456 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13457 url = params.uri_replacement(url, param_name, find_this, true);
13458 }
13459 {
13460 let to_remove = ["name"];
13461 params.remove_params(&to_remove);
13462 }
13463
13464 let url = params.parse_with_url(&url);
13465
13466 loop {
13467 let token = match self
13468 .hub
13469 .auth
13470 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13471 .await
13472 {
13473 Ok(token) => token,
13474 Err(e) => match dlg.token(e) {
13475 Ok(token) => token,
13476 Err(e) => {
13477 dlg.finished(false);
13478 return Err(common::Error::MissingToken(e));
13479 }
13480 },
13481 };
13482 let mut req_result = {
13483 let client = &self.hub.client;
13484 dlg.pre_request();
13485 let mut req_builder = hyper::Request::builder()
13486 .method(hyper::Method::GET)
13487 .uri(url.as_str())
13488 .header(USER_AGENT, self.hub._user_agent.clone());
13489
13490 if let Some(token) = token.as_ref() {
13491 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13492 }
13493
13494 let request = req_builder
13495 .header(CONTENT_LENGTH, 0_u64)
13496 .body(common::to_body::<String>(None));
13497
13498 client.request(request.unwrap()).await
13499 };
13500
13501 match req_result {
13502 Err(err) => {
13503 if let common::Retry::After(d) = dlg.http_error(&err) {
13504 sleep(d).await;
13505 continue;
13506 }
13507 dlg.finished(false);
13508 return Err(common::Error::HttpError(err));
13509 }
13510 Ok(res) => {
13511 let (mut parts, body) = res.into_parts();
13512 let mut body = common::Body::new(body);
13513 if !parts.status.is_success() {
13514 let bytes = common::to_bytes(body).await.unwrap_or_default();
13515 let error = serde_json::from_str(&common::to_string(&bytes));
13516 let response = common::to_response(parts, bytes.into());
13517
13518 if let common::Retry::After(d) =
13519 dlg.http_failure(&response, error.as_ref().ok())
13520 {
13521 sleep(d).await;
13522 continue;
13523 }
13524
13525 dlg.finished(false);
13526
13527 return Err(match error {
13528 Ok(value) => common::Error::BadRequest(value),
13529 _ => common::Error::Failure(response),
13530 });
13531 }
13532 let response = {
13533 let bytes = common::to_bytes(body).await.unwrap_or_default();
13534 let encoded = common::to_string(&bytes);
13535 match serde_json::from_str(&encoded) {
13536 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13537 Err(error) => {
13538 dlg.response_json_decode_error(&encoded, &error);
13539 return Err(common::Error::JsonDecodeError(
13540 encoded.to_string(),
13541 error,
13542 ));
13543 }
13544 }
13545 };
13546
13547 dlg.finished(true);
13548 return Ok(response);
13549 }
13550 }
13551 }
13552 }
13553
13554 /// Required. The identifier that Android Device Policy passes to the 3P sign-in page in the form of provisioningInfo/{provisioning_info}.
13555 ///
13556 /// Sets the *name* path property to the given value.
13557 ///
13558 /// Even though the property as already been set when instantiating this call,
13559 /// we provide this method for API completeness.
13560 pub fn name(mut self, new_value: &str) -> ProvisioningInfoGetCall<'a, C> {
13561 self._name = new_value.to_string();
13562 self
13563 }
13564 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13565 /// while executing the actual API request.
13566 ///
13567 /// ````text
13568 /// It should be used to handle progress information, and to implement a certain level of resilience.
13569 /// ````
13570 ///
13571 /// Sets the *delegate* property to the given value.
13572 pub fn delegate(
13573 mut self,
13574 new_value: &'a mut dyn common::Delegate,
13575 ) -> ProvisioningInfoGetCall<'a, C> {
13576 self._delegate = Some(new_value);
13577 self
13578 }
13579
13580 /// Set any additional parameter of the query string used in the request.
13581 /// It should be used to set parameters which are not yet available through their own
13582 /// setters.
13583 ///
13584 /// Please note that this method must not be used to set any of the known parameters
13585 /// which have their own setter method. If done anyway, the request will fail.
13586 ///
13587 /// # Additional Parameters
13588 ///
13589 /// * *$.xgafv* (query-string) - V1 error format.
13590 /// * *access_token* (query-string) - OAuth access token.
13591 /// * *alt* (query-string) - Data format for response.
13592 /// * *callback* (query-string) - JSONP
13593 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13594 /// * *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.
13595 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13596 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13597 /// * *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.
13598 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13599 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13600 pub fn param<T>(mut self, name: T, value: T) -> ProvisioningInfoGetCall<'a, C>
13601 where
13602 T: AsRef<str>,
13603 {
13604 self._additional_params
13605 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13606 self
13607 }
13608
13609 /// Identifies the authorization scope for the method you are building.
13610 ///
13611 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13612 /// [`Scope::Full`].
13613 ///
13614 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13615 /// tokens for more than one scope.
13616 ///
13617 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13618 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13619 /// sufficient, a read-write scope will do as well.
13620 pub fn add_scope<St>(mut self, scope: St) -> ProvisioningInfoGetCall<'a, C>
13621 where
13622 St: AsRef<str>,
13623 {
13624 self._scopes.insert(String::from(scope.as_ref()));
13625 self
13626 }
13627 /// Identifies the authorization scope(s) for the method you are building.
13628 ///
13629 /// See [`Self::add_scope()`] for details.
13630 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProvisioningInfoGetCall<'a, C>
13631 where
13632 I: IntoIterator<Item = St>,
13633 St: AsRef<str>,
13634 {
13635 self._scopes
13636 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13637 self
13638 }
13639
13640 /// Removes all scopes, and no default scope will be used either.
13641 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13642 /// for details).
13643 pub fn clear_scopes(mut self) -> ProvisioningInfoGetCall<'a, C> {
13644 self._scopes.clear();
13645 self
13646 }
13647}
13648
13649/// Creates an enterprise signup URL.
13650///
13651/// A builder for the *create* method supported by a *signupUrl* resource.
13652/// It is not used directly, but through a [`SignupUrlMethods`] instance.
13653///
13654/// # Example
13655///
13656/// Instantiate a resource method builder
13657///
13658/// ```test_harness,no_run
13659/// # extern crate hyper;
13660/// # extern crate hyper_rustls;
13661/// # extern crate google_androidmanagement1 as androidmanagement1;
13662/// # async fn dox() {
13663/// # use androidmanagement1::{AndroidManagement, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13664///
13665/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13666/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13667/// # secret,
13668/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13669/// # ).build().await.unwrap();
13670///
13671/// # let client = hyper_util::client::legacy::Client::builder(
13672/// # hyper_util::rt::TokioExecutor::new()
13673/// # )
13674/// # .build(
13675/// # hyper_rustls::HttpsConnectorBuilder::new()
13676/// # .with_native_roots()
13677/// # .unwrap()
13678/// # .https_or_http()
13679/// # .enable_http1()
13680/// # .build()
13681/// # );
13682/// # let mut hub = AndroidManagement::new(client, auth);
13683/// // You can configure optional parameters by calling the respective setters at will, and
13684/// // execute the final call using `doit()`.
13685/// // Values shown here are possibly random and not representative !
13686/// let result = hub.signup_urls().create()
13687/// .project_id("invidunt")
13688/// .callback_url("Stet")
13689/// .admin_email("vero")
13690/// .doit().await;
13691/// # }
13692/// ```
13693pub struct SignupUrlCreateCall<'a, C>
13694where
13695 C: 'a,
13696{
13697 hub: &'a AndroidManagement<C>,
13698 _project_id: Option<String>,
13699 _callback_url: Option<String>,
13700 _admin_email: Option<String>,
13701 _delegate: Option<&'a mut dyn common::Delegate>,
13702 _additional_params: HashMap<String, String>,
13703 _scopes: BTreeSet<String>,
13704}
13705
13706impl<'a, C> common::CallBuilder for SignupUrlCreateCall<'a, C> {}
13707
13708impl<'a, C> SignupUrlCreateCall<'a, C>
13709where
13710 C: common::Connector,
13711{
13712 /// Perform the operation you have build so far.
13713 pub async fn doit(mut self) -> common::Result<(common::Response, SignupUrl)> {
13714 use std::borrow::Cow;
13715 use std::io::{Read, Seek};
13716
13717 use common::{url::Params, ToParts};
13718 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13719
13720 let mut dd = common::DefaultDelegate;
13721 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13722 dlg.begin(common::MethodInfo {
13723 id: "androidmanagement.signupUrls.create",
13724 http_method: hyper::Method::POST,
13725 });
13726
13727 for &field in ["alt", "projectId", "callbackUrl", "adminEmail"].iter() {
13728 if self._additional_params.contains_key(field) {
13729 dlg.finished(false);
13730 return Err(common::Error::FieldClash(field));
13731 }
13732 }
13733
13734 let mut params = Params::with_capacity(5 + self._additional_params.len());
13735 if let Some(value) = self._project_id.as_ref() {
13736 params.push("projectId", value);
13737 }
13738 if let Some(value) = self._callback_url.as_ref() {
13739 params.push("callbackUrl", value);
13740 }
13741 if let Some(value) = self._admin_email.as_ref() {
13742 params.push("adminEmail", value);
13743 }
13744
13745 params.extend(self._additional_params.iter());
13746
13747 params.push("alt", "json");
13748 let mut url = self.hub._base_url.clone() + "v1/signupUrls";
13749 if self._scopes.is_empty() {
13750 self._scopes.insert(Scope::Full.as_ref().to_string());
13751 }
13752
13753 let url = params.parse_with_url(&url);
13754
13755 loop {
13756 let token = match self
13757 .hub
13758 .auth
13759 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13760 .await
13761 {
13762 Ok(token) => token,
13763 Err(e) => match dlg.token(e) {
13764 Ok(token) => token,
13765 Err(e) => {
13766 dlg.finished(false);
13767 return Err(common::Error::MissingToken(e));
13768 }
13769 },
13770 };
13771 let mut req_result = {
13772 let client = &self.hub.client;
13773 dlg.pre_request();
13774 let mut req_builder = hyper::Request::builder()
13775 .method(hyper::Method::POST)
13776 .uri(url.as_str())
13777 .header(USER_AGENT, self.hub._user_agent.clone());
13778
13779 if let Some(token) = token.as_ref() {
13780 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13781 }
13782
13783 let request = req_builder
13784 .header(CONTENT_LENGTH, 0_u64)
13785 .body(common::to_body::<String>(None));
13786
13787 client.request(request.unwrap()).await
13788 };
13789
13790 match req_result {
13791 Err(err) => {
13792 if let common::Retry::After(d) = dlg.http_error(&err) {
13793 sleep(d).await;
13794 continue;
13795 }
13796 dlg.finished(false);
13797 return Err(common::Error::HttpError(err));
13798 }
13799 Ok(res) => {
13800 let (mut parts, body) = res.into_parts();
13801 let mut body = common::Body::new(body);
13802 if !parts.status.is_success() {
13803 let bytes = common::to_bytes(body).await.unwrap_or_default();
13804 let error = serde_json::from_str(&common::to_string(&bytes));
13805 let response = common::to_response(parts, bytes.into());
13806
13807 if let common::Retry::After(d) =
13808 dlg.http_failure(&response, error.as_ref().ok())
13809 {
13810 sleep(d).await;
13811 continue;
13812 }
13813
13814 dlg.finished(false);
13815
13816 return Err(match error {
13817 Ok(value) => common::Error::BadRequest(value),
13818 _ => common::Error::Failure(response),
13819 });
13820 }
13821 let response = {
13822 let bytes = common::to_bytes(body).await.unwrap_or_default();
13823 let encoded = common::to_string(&bytes);
13824 match serde_json::from_str(&encoded) {
13825 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13826 Err(error) => {
13827 dlg.response_json_decode_error(&encoded, &error);
13828 return Err(common::Error::JsonDecodeError(
13829 encoded.to_string(),
13830 error,
13831 ));
13832 }
13833 }
13834 };
13835
13836 dlg.finished(true);
13837 return Ok(response);
13838 }
13839 }
13840 }
13841 }
13842
13843 /// The ID of the Google Cloud Platform project which will own the enterprise.
13844 ///
13845 /// Sets the *project id* query property to the given value.
13846 pub fn project_id(mut self, new_value: &str) -> SignupUrlCreateCall<'a, C> {
13847 self._project_id = Some(new_value.to_string());
13848 self
13849 }
13850 /// The callback URL that the admin will be redirected to after successfully creating an enterprise. Before redirecting there the system will add a query parameter to this URL named enterpriseToken which will contain an opaque token to be used for the create enterprise request. The URL will be parsed then reformatted in order to add the enterpriseToken parameter, so there may be some minor formatting changes.
13851 ///
13852 /// Sets the *callback url* query property to the given value.
13853 pub fn callback_url(mut self, new_value: &str) -> SignupUrlCreateCall<'a, C> {
13854 self._callback_url = Some(new_value.to_string());
13855 self
13856 }
13857 /// Optional. Email address used to prefill the admin field of the enterprise signup form. This value is a hint only and can be altered by the user.
13858 ///
13859 /// Sets the *admin email* query property to the given value.
13860 pub fn admin_email(mut self, new_value: &str) -> SignupUrlCreateCall<'a, C> {
13861 self._admin_email = Some(new_value.to_string());
13862 self
13863 }
13864 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13865 /// while executing the actual API request.
13866 ///
13867 /// ````text
13868 /// It should be used to handle progress information, and to implement a certain level of resilience.
13869 /// ````
13870 ///
13871 /// Sets the *delegate* property to the given value.
13872 pub fn delegate(
13873 mut self,
13874 new_value: &'a mut dyn common::Delegate,
13875 ) -> SignupUrlCreateCall<'a, C> {
13876 self._delegate = Some(new_value);
13877 self
13878 }
13879
13880 /// Set any additional parameter of the query string used in the request.
13881 /// It should be used to set parameters which are not yet available through their own
13882 /// setters.
13883 ///
13884 /// Please note that this method must not be used to set any of the known parameters
13885 /// which have their own setter method. If done anyway, the request will fail.
13886 ///
13887 /// # Additional Parameters
13888 ///
13889 /// * *$.xgafv* (query-string) - V1 error format.
13890 /// * *access_token* (query-string) - OAuth access token.
13891 /// * *alt* (query-string) - Data format for response.
13892 /// * *callback* (query-string) - JSONP
13893 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13894 /// * *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.
13895 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13896 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13897 /// * *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.
13898 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13899 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13900 pub fn param<T>(mut self, name: T, value: T) -> SignupUrlCreateCall<'a, C>
13901 where
13902 T: AsRef<str>,
13903 {
13904 self._additional_params
13905 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13906 self
13907 }
13908
13909 /// Identifies the authorization scope for the method you are building.
13910 ///
13911 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13912 /// [`Scope::Full`].
13913 ///
13914 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13915 /// tokens for more than one scope.
13916 ///
13917 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13918 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13919 /// sufficient, a read-write scope will do as well.
13920 pub fn add_scope<St>(mut self, scope: St) -> SignupUrlCreateCall<'a, C>
13921 where
13922 St: AsRef<str>,
13923 {
13924 self._scopes.insert(String::from(scope.as_ref()));
13925 self
13926 }
13927 /// Identifies the authorization scope(s) for the method you are building.
13928 ///
13929 /// See [`Self::add_scope()`] for details.
13930 pub fn add_scopes<I, St>(mut self, scopes: I) -> SignupUrlCreateCall<'a, C>
13931 where
13932 I: IntoIterator<Item = St>,
13933 St: AsRef<str>,
13934 {
13935 self._scopes
13936 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13937 self
13938 }
13939
13940 /// Removes all scopes, and no default scope will be used either.
13941 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13942 /// for details).
13943 pub fn clear_scopes(mut self) -> SignupUrlCreateCall<'a, C> {
13944 self._scopes.clear();
13945 self
13946 }
13947}