use std::collections::HashMap; use std::cell::RefCell; use std::default::Default; use std::collections::BTreeMap; use serde_json as json; use std::io; use std::fs; use std::mem; use std::thread::sleep; use crate::client; // ############## // UTILITIES ### // ############ /// Identifies the an OAuth2 authorization scope. /// A scope is needed when requesting an /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { /// Manage Android devices and apps for your customers Full, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::Full => "https://www.googleapis.com/auth/androidmanagement", } } } impl Default for Scope { fn default() -> Scope { Scope::Full } } // ######## // HUB ### // ###### /// Central instance to access all AndroidManagement related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::Enterprise; /// use androidmanagement1::{Result, Error}; /// # async fn dox() { /// use std::default::Default; /// use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: oauth2::ApplicationSecret = Default::default(); /// // Instantiate the authenticator. It will choose a suitable authentication flow for you, /// // unless you replace `None` with the desired Flow. /// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about /// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and /// // retrieve them from storage. /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Enterprise::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().create(req) /// .signup_url_name("amet.") /// .project_id("takimata") /// .enterprise_token("amet.") /// .agreement_accepted(true) /// .doit().await; /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::Io(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` #[derive(Clone)] pub struct AndroidManagement<> { pub client: hyper::Client, hyper::body::Body>, pub auth: oauth2::authenticator::Authenticator>, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, > client::Hub for AndroidManagement<> {} impl<'a, > AndroidManagement<> { pub fn new(client: hyper::Client, hyper::body::Body>, authenticator: oauth2::authenticator::Authenticator>) -> AndroidManagement<> { AndroidManagement { client, auth: authenticator, _user_agent: "google-api-rust-client/3.0.0".to_string(), _base_url: "https://androidmanagement.googleapis.com/".to_string(), _root_url: "https://androidmanagement.googleapis.com/".to_string(), } } pub fn enterprises(&'a self) -> EnterpriseMethods<'a> { EnterpriseMethods { hub: &self } } pub fn signup_urls(&'a self) -> SignupUrlMethods<'a> { SignupUrlMethods { hub: &self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/3.0.0`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://androidmanagement.googleapis.com/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://androidmanagement.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// Security policies set to secure values by default. To maintain the security posture of a device, we don't recommend overriding any of the default values. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdvancedSecurityOverrides { /// 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. #[serde(rename="commonCriteriaMode")] pub common_criteria_mode: Option, /// Controls access to developer settings: developer options and safe boot. Replaces safeBootDisabled (deprecated) and debuggingFeaturesAllowed (deprecated). #[serde(rename="developerSettings")] pub developer_settings: Option, /// Whether Google Play Protect verification (https://support.google.com/accounts/answer/2812853) is enforced. Replaces ensureVerifyAppsEnabled (deprecated). #[serde(rename="googlePlayProtectVerifyApps")] pub google_play_protect_verify_apps: Option, /// 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. #[serde(rename="personalAppsThatCanReadWorkNotifications")] pub personal_apps_that_can_read_work_notifications: Option>, /// The policy for untrusted apps (apps from unknown sources) enforced on the device. Replaces install_unknown_sources_allowed (deprecated). #[serde(rename="untrustedAppsPolicy")] pub untrusted_apps_policy: Option, } impl client::Part for AdvancedSecurityOverrides {} /// Configuration for an always-on VPN connection. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AlwaysOnVpnPackage { /// Disallows networking when the VPN is not connected. #[serde(rename="lockdownEnabled")] pub lockdown_enabled: Option, /// The package name of the VPN app. #[serde(rename="packageName")] pub package_name: Option, } impl client::Part for AlwaysOnVpnPackage {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApiLevelCondition { /// 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. #[serde(rename="minApiLevel")] pub min_api_level: Option, } impl client::Part for ApiLevelCondition {} /// Id to name association of a app track. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AppTrackInfo { /// The track name associated with the trackId, set in the Play Console. The name is modifiable from Play Console. #[serde(rename="trackAlias")] pub track_alias: Option, /// The unmodifiable unique track identifier, taken from the releaseTrackId in the URL of the Play Console page that displays the app’s track information. #[serde(rename="trackId")] pub track_id: Option, } impl client::Part for AppTrackInfo {} /// This represents a single version of the app. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AppVersion { /// True if this version is a production track. pub production: Option, /// Track ids that the app version is published in. This doesn't include the production track (see production instead). #[serde(rename="trackIds")] pub track_ids: Option>, /// Unique increasing identifier for the app version. #[serde(rename="versionCode")] pub version_code: Option, /// 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"). #[serde(rename="versionString")] pub version_string: Option, } impl client::Part for AppVersion {} /// Information about an app. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [applications get enterprises](EnterpriseApplicationGetCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Application { /// 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). #[serde(rename="appPricing")] pub app_pricing: Option, /// Application tracks visible to the enterprise. #[serde(rename="appTracks")] pub app_tracks: Option>, /// Versions currently available for this app. #[serde(rename="appVersions")] pub app_versions: Option>, /// The name of the author of the apps (for example, the app developer). pub author: Option, /// The countries which this app is available in as per ISO 3166-1 alpha-2. #[serde(rename="availableCountries")] pub available_countries: Option>, /// The app category (e.g. RACING, SOCIAL, etc.) pub category: Option, /// The content rating for this app. #[serde(rename="contentRating")] pub content_rating: Option, /// The localized promotional description, if available. pub description: Option, /// How and to whom the package is made available. #[serde(rename="distributionChannel")] pub distribution_channel: Option, /// Noteworthy features (if any) of this app. pub features: Option>, /// Full app description, if available. #[serde(rename="fullDescription")] pub full_description: Option, /// A link to an image that can be used as an icon for the app. This image is suitable for use at up to 512px x 512px #[serde(rename="iconUrl")] pub icon_url: Option, /// The set of managed properties available to be pre-configured for the app. #[serde(rename="managedProperties")] pub managed_properties: Option>, /// The minimum Android SDK necessary to run the app. #[serde(rename="minAndroidSdkVersion")] pub min_android_sdk_version: Option, /// The name of the app in the form enterprises/{enterprise}/applications/{package_name}. pub name: Option, /// The permissions required by the app. pub permissions: Option>, /// A link to the (consumer) Google Play details page for the app. #[serde(rename="playStoreUrl")] pub play_store_url: Option, /// A localised description of the recent changes made to the app. #[serde(rename="recentChanges")] pub recent_changes: Option, /// A list of screenshot links representing the app. #[serde(rename="screenshotUrls")] pub screenshot_urls: Option>, /// A link to a smaller image that can be used as an icon for the app. This image is suitable for use at up to 128px x 128px. #[serde(rename="smallIconUrl")] pub small_icon_url: Option, /// The title of the app. Localized. pub title: Option, /// Output only. The approximate time (within 7 days) the app was last published. #[serde(rename="updateTime")] pub update_time: Option, } impl client::ResponseResult for Application {} /// An app-related event. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApplicationEvent { /// The creation time of the event. #[serde(rename="createTime")] pub create_time: Option, /// App event type. #[serde(rename="eventType")] pub event_type: Option, } impl client::Part for ApplicationEvent {} /// A permission required by the app. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApplicationPermission { /// A longer description of the permission, providing more detail on what it affects. Localized. pub description: Option, /// The name of the permission. Localized. pub name: Option, /// An opaque string uniquely identifying the permission. Not localized. #[serde(rename="permissionId")] pub permission_id: Option, } impl client::Part for ApplicationPermission {} /// Policy for an individual app. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApplicationPolicy { /// 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. #[serde(rename="accessibleTrackIds")] pub accessible_track_ids: Option>, /// Controls the auto-update mode for the app. #[serde(rename="autoUpdateMode")] pub auto_update_mode: Option, /// Controls whether the app can communicate with itself across a device’s work and personal profiles, subject to user consent. #[serde(rename="connectedWorkAndPersonalApp")] pub connected_work_and_personal_app: Option, /// 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. #[serde(rename="defaultPermissionPolicy")] pub default_permission_policy: Option, /// The scopes delegated to the app from Android Device Policy. #[serde(rename="delegatedScopes")] pub delegated_scopes: Option>, /// Whether the app is disabled. When disabled, the app data is still preserved. pub disabled: Option, /// 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. #[serde(rename="extensionConfig")] pub extension_config: Option, /// The type of installation to perform. #[serde(rename="installType")] pub install_type: Option, /// Whether the app is allowed to lock itself in full-screen mode. DEPRECATED. Use InstallType KIOSK or kioskCustomLauncherEnabled to to configure a dedicated device. #[serde(rename="lockTaskAllowed")] pub lock_task_allowed: Option, /// 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 #[serde(rename="managedConfiguration")] pub managed_configuration: Option>, /// The managed configurations template for the app, saved from the managed configurations iframe. This field is ignored if managed_configuration is set. #[serde(rename="managedConfigurationTemplate")] pub managed_configuration_template: Option, /// 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. #[serde(rename="minimumVersionCode")] pub minimum_version_code: Option, /// The package name of the app. For example, com.google.android.youtube for the YouTube app. #[serde(rename="packageName")] pub package_name: Option, /// Explicit permission grants or denials for the app. These values override the default_permission_policy and permission_grants which apply to all apps. #[serde(rename="permissionGrants")] pub permission_grants: Option>, } impl client::Part for ApplicationPolicy {} /// Information reported about an installed app. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApplicationReport { /// The source of the package. #[serde(rename="applicationSource")] pub application_source: Option, /// The display name of the app. #[serde(rename="displayName")] pub display_name: Option, /// List of app events. The most recent 20 events are stored in the list. pub events: Option>, /// The package name of the app that installed this app. #[serde(rename="installerPackageName")] pub installer_package_name: Option, /// List of keyed app states reported by the app. #[serde(rename="keyedAppStates")] pub keyed_app_states: Option>, /// Package name of the app. #[serde(rename="packageName")] pub package_name: Option, /// 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. #[serde(rename="packageSha256Hash")] pub package_sha256_hash: Option, /// 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. #[serde(rename="signingKeyCertFingerprints")] pub signing_key_cert_fingerprints: Option>, /// Application state. pub state: Option, /// The app version code, which can be used to determine whether one version is more recent than another. #[serde(rename="versionCode")] pub version_code: Option, /// The app version as displayed to the user. #[serde(rename="versionName")] pub version_name: Option, } impl client::Part for ApplicationReport {} /// Settings controlling the behavior of application reports. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApplicationReportingSettings { /// Whether removed apps are included in application reports. #[serde(rename="includeRemovedApps")] pub include_removed_apps: Option, } impl client::Part for ApplicationReportingSettings {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BlockAction { /// 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. #[serde(rename="blockAfterDays")] pub block_after_days: Option, /// Specifies the scope of this BlockAction. Only applicable to devices that are company-owned. #[serde(rename="blockScope")] pub block_scope: Option, } impl client::Part for BlockAction {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChoosePrivateKeyRule { /// 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. #[serde(rename="packageNames")] pub package_names: Option>, /// The alias of the private key to be used. #[serde(rename="privateKeyAlias")] pub private_key_alias: Option, /// 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. #[serde(rename="urlPattern")] pub url_pattern: Option, } impl client::Part for ChoosePrivateKeyRule {} /// A command. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [devices issue command enterprises](EnterpriseDeviceIssueCommandCall) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Command { /// The timestamp at which the command was created. The timestamp is automatically generated by the server. #[serde(rename="createTime")] pub create_time: Option, /// 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. pub duration: Option, /// If the command failed, an error code explaining the failure. This is not set when the command is cancelled by the caller. #[serde(rename="errorCode")] pub error_code: Option, /// For commands of type RESET_PASSWORD, optionally specifies the new password. #[serde(rename="newPassword")] pub new_password: Option, /// For commands of type RESET_PASSWORD, optionally specifies flags. #[serde(rename="resetPasswordFlags")] pub reset_password_flags: Option>, /// The type of the command. #[serde(rename="type")] pub type_: Option, /// 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. #[serde(rename="userName")] pub user_name: Option, } impl client::RequestValue for Command {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommonCriteriaModeInfo { /// Whether Common Criteria Mode is enabled. #[serde(rename="commonCriteriaModeStatus")] pub common_criteria_mode_status: Option, } impl client::Part for CommonCriteriaModeInfo {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ComplianceRule { /// A condition which is satisfied if the Android Framework API level on the device doesn't meet a minimum requirement. #[serde(rename="apiLevelCondition")] pub api_level_condition: Option, /// 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. #[serde(rename="disableApps")] pub disable_apps: Option, /// A condition which is satisfied if there exists any matching NonComplianceDetail for the device. #[serde(rename="nonComplianceDetailCondition")] pub non_compliance_detail_condition: Option, /// If set, the rule includes a mitigating action to disable apps specified in the list, but app data is preserved. #[serde(rename="packageNamesToDisable")] pub package_names_to_disable: Option>, } impl client::Part for ComplianceRule {} /// Contact details for managed Google Play enterprises. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContactInfo { /// Email address for a point of contact, which will be used to send important announcements related to managed Google Play. #[serde(rename="contactEmail")] pub contact_email: Option, /// The email of the data protection officer. The email is validated but not verified. #[serde(rename="dataProtectionOfficerEmail")] pub data_protection_officer_email: Option, /// The name of the data protection officer. #[serde(rename="dataProtectionOfficerName")] pub data_protection_officer_name: Option, /// The phone number of the data protection officer The phone number is validated but not verified. #[serde(rename="dataProtectionOfficerPhone")] pub data_protection_officer_phone: Option, /// The email of the EU representative. The email is validated but not verified. #[serde(rename="euRepresentativeEmail")] pub eu_representative_email: Option, /// The name of the EU representative. #[serde(rename="euRepresentativeName")] pub eu_representative_name: Option, /// The phone number of the EU representative. The phone number is validated but not verified. #[serde(rename="euRepresentativePhone")] pub eu_representative_phone: Option, } impl client::Part for ContactInfo {} /// This feature is not generally available. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContentProviderEndpoint { /// This feature is not generally available. #[serde(rename="packageName")] pub package_name: Option, /// Required. This feature is not generally available. #[serde(rename="signingCertsSha256")] pub signing_certs_sha256: Option>, /// This feature is not generally available. pub uri: Option, } impl client::Part for ContentProviderEndpoint {} /// Cross-profile policies applied on the device. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CrossProfilePolicies { /// Whether text copied from one profile (personal or work) can be pasted in the other profile. #[serde(rename="crossProfileCopyPaste")] pub cross_profile_copy_paste: Option, /// 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. #[serde(rename="crossProfileDataSharing")] pub cross_profile_data_sharing: Option, /// Whether contacts stored in the work profile can be shown in personal profile contact searches and incoming calls. #[serde(rename="showWorkContactsInPersonalProfile")] pub show_work_contacts_in_personal_profile: Option, } impl client::Part for CrossProfilePolicies {} /// 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 (e.g., an anniversary) A year on its own, with a zero month and a zero day A year and month, with a zero day (e.g., a credit card expiration date)Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Date { /// 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. pub day: Option, /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. pub month: Option, /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. pub year: Option, } impl client::Part for Date {} /// A device owned by an enterprise. Unless otherwise noted, all fields are read-only and can't be modified by enterprises.devices.patch. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [devices get enterprises](EnterpriseDeviceGetCall) (response) /// * [devices patch enterprises](EnterpriseDevicePatchCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Device { /// The API level of the Android platform version running on the device. #[serde(rename="apiLevel")] pub api_level: Option, /// Reports for apps installed on the device. This information is only available when application_reports_enabled is true in the device's policy. #[serde(rename="applicationReports")] pub application_reports: Option>, /// 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. #[serde(rename="appliedPasswordPolicies")] pub applied_password_policies: Option>, /// The name of the policy currently applied to the device. #[serde(rename="appliedPolicyName")] pub applied_policy_name: Option, /// The version of the policy currently applied to the device. #[serde(rename="appliedPolicyVersion")] pub applied_policy_version: Option, /// The state currently applied to the device. #[serde(rename="appliedState")] pub applied_state: Option, /// 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. #[serde(rename="commonCriteriaModeInfo")] pub common_criteria_mode_info: Option, /// Device settings information. This information is only available if deviceSettingsEnabled is true in the device's policy. #[serde(rename="deviceSettings")] pub device_settings: Option, /// 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. #[serde(rename="disabledReason")] pub disabled_reason: Option, /// Detailed information about displays on the device. This information is only available if displayInfoEnabled is true in the device's policy. pub displays: Option>, /// The time of device enrollment. #[serde(rename="enrollmentTime")] pub enrollment_time: Option, /// If the device was enrolled with an enrollment token with additional data provided, this field contains that data. #[serde(rename="enrollmentTokenData")] pub enrollment_token_data: Option, /// If the device was enrolled with an enrollment token, this field contains the name of the token. #[serde(rename="enrollmentTokenName")] pub enrollment_token_name: Option, /// Detailed information about the device hardware. #[serde(rename="hardwareInfo")] pub hardware_info: Option, /// Hardware status samples in chronological order. This information is only available if hardwareStatusEnabled is true in the device's policy. #[serde(rename="hardwareStatusSamples")] pub hardware_status_samples: Option>, /// Deprecated. #[serde(rename="lastPolicyComplianceReportTime")] pub last_policy_compliance_report_time: Option, /// The last time the device fetched its policy. #[serde(rename="lastPolicySyncTime")] pub last_policy_sync_time: Option, /// The last time the device sent a status report. #[serde(rename="lastStatusReportTime")] pub last_status_report_time: Option, /// The type of management mode Android Device Policy takes on the device. This influences which policy settings are supported. #[serde(rename="managementMode")] pub management_mode: Option, /// Events related to memory and storage measurements in chronological order. This information is only available if memoryInfoEnabled is true in the device's policy. #[serde(rename="memoryEvents")] pub memory_events: Option>, /// Memory information: contains information about device memory and storage. #[serde(rename="memoryInfo")] pub memory_info: Option, /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. pub name: Option, /// Device network information. This information is only available if networkInfoEnabled is true in the device's policy. #[serde(rename="networkInfo")] pub network_info: Option, /// Details about policy settings that the device is not compliant with. #[serde(rename="nonComplianceDetails")] pub non_compliance_details: Option>, /// Ownership of the managed device. pub ownership: Option, /// Whether the device is compliant with its policy. #[serde(rename="policyCompliant")] pub policy_compliant: Option, /// 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. #[serde(rename="policyName")] pub policy_name: Option, /// Power management events on the device in chronological order. This information is only available if powerManagementEventsEnabled is true in the device's policy. #[serde(rename="powerManagementEvents")] pub power_management_events: Option>, /// 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. #[serde(rename="previousDeviceNames")] pub previous_device_names: Option>, /// Device's security posture value that reflects how secure the device is. #[serde(rename="securityPosture")] pub security_posture: Option, /// Detailed information about the device software. This information is only available if softwareInfoEnabled is true in the device's policy. #[serde(rename="softwareInfo")] pub software_info: Option, /// 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. pub state: Option, /// 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. #[serde(rename="systemProperties")] pub system_properties: Option>, /// The user who owns the device. pub user: Option, /// The resource name of the user that owns this device in the form enterprises/{enterpriseId}/users/{userId}. #[serde(rename="userName")] pub user_name: Option, } impl client::RequestValue for Device {} impl client::ResponseResult for Device {} /// Information about security related device settings on device. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeviceSettings { /// Whether ADB (https://developer.android.com/studio/command-line/adb.html) is enabled on the device. #[serde(rename="adbEnabled")] pub adb_enabled: Option, /// Whether developer mode is enabled on the device. #[serde(rename="developmentSettingsEnabled")] pub development_settings_enabled: Option, /// Encryption status from DevicePolicyManager. #[serde(rename="encryptionStatus")] pub encryption_status: Option, /// Whether the device is secured with PIN/password. #[serde(rename="isDeviceSecure")] pub is_device_secure: Option, /// Whether the storage encryption is enabled. #[serde(rename="isEncrypted")] pub is_encrypted: Option, /// Whether installing apps from unknown sources is enabled. #[serde(rename="unknownSourcesEnabled")] pub unknown_sources_enabled: Option, /// Whether Google Play Protect verification (https://support.google.com/accounts/answer/2812853) is enforced on the device. #[serde(rename="verifyAppsEnabled")] pub verify_apps_enabled: Option, } impl client::Part for DeviceSettings {} /// Device display information. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Display { /// Display density expressed as dots-per-inch. pub density: Option, /// Unique display id. #[serde(rename="displayId")] pub display_id: Option, /// Display height in pixels. pub height: Option, /// Name of the display. pub name: Option, /// Refresh rate of the display in frames per second. #[serde(rename="refreshRate")] pub refresh_rate: Option, /// State of the display. pub state: Option, /// Display width in pixels. pub width: Option, } impl client::Part for Display {} /// 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); } The JSON representation for Empty is empty JSON object {}. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [devices operations cancel enterprises](EnterpriseDeviceOperationCancelCall) (response) /// * [devices operations delete enterprises](EnterpriseDeviceOperationDeleteCall) (response) /// * [devices delete enterprises](EnterpriseDeviceDeleteCall) (response) /// * [enrollment tokens delete enterprises](EnterpriseEnrollmentTokenDeleteCall) (response) /// * [policies delete enterprises](EnterprisePolicyDeleteCall) (response) /// * [web apps delete enterprises](EnterpriseWebAppDeleteCall) (response) /// * [delete enterprises](EnterpriseDeleteCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Empty { _never_set: Option } impl client::ResponseResult for Empty {} /// An enrollment token. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [enrollment tokens create enterprises](EnterpriseEnrollmentTokenCreateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EnrollmentToken { /// 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. #[serde(rename="additionalData")] pub additional_data: Option, /// 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. #[serde(rename="allowPersonalUsage")] pub allow_personal_usage: Option, /// The length of time the enrollment token is valid, ranging from 1 minute to 90 days. If not specified, the default duration is 1 hour. pub duration: Option, /// The expiration time of the token. This is a read-only field generated by the server. #[serde(rename="expirationTimestamp")] pub expiration_timestamp: Option, /// The name of the enrollment token, which is generated by the server during creation, in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}. pub name: Option, /// 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. #[serde(rename="oneTimeOnly")] pub one_time_only: Option, /// 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. #[serde(rename="policyName")] pub policy_name: Option, /// 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. #[serde(rename="qrCode")] pub qr_code: Option, /// The user associated with this enrollment token. If it's specified when the enrollment token is created and the user does not exist, the user will be created. This field must not contain personally identifiable information. Only the account_identifier field needs to be set. pub user: Option, /// 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. pub value: Option, } impl client::RequestValue for EnrollmentToken {} impl client::ResponseResult for EnrollmentToken {} /// The configuration applied to an enterprise. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [applications get enterprises](EnterpriseApplicationGetCall) (none) /// * [devices operations cancel enterprises](EnterpriseDeviceOperationCancelCall) (none) /// * [devices operations delete enterprises](EnterpriseDeviceOperationDeleteCall) (none) /// * [devices operations get enterprises](EnterpriseDeviceOperationGetCall) (none) /// * [devices operations list enterprises](EnterpriseDeviceOperationListCall) (none) /// * [devices delete enterprises](EnterpriseDeviceDeleteCall) (none) /// * [devices get enterprises](EnterpriseDeviceGetCall) (none) /// * [devices issue command enterprises](EnterpriseDeviceIssueCommandCall) (none) /// * [devices list enterprises](EnterpriseDeviceListCall) (none) /// * [devices patch enterprises](EnterpriseDevicePatchCall) (none) /// * [enrollment tokens create enterprises](EnterpriseEnrollmentTokenCreateCall) (none) /// * [enrollment tokens delete enterprises](EnterpriseEnrollmentTokenDeleteCall) (none) /// * [policies delete enterprises](EnterprisePolicyDeleteCall) (none) /// * [policies get enterprises](EnterprisePolicyGetCall) (none) /// * [policies list enterprises](EnterprisePolicyListCall) (none) /// * [policies patch enterprises](EnterprisePolicyPatchCall) (none) /// * [web apps create enterprises](EnterpriseWebAppCreateCall) (none) /// * [web apps delete enterprises](EnterpriseWebAppDeleteCall) (none) /// * [web apps get enterprises](EnterpriseWebAppGetCall) (none) /// * [web apps list enterprises](EnterpriseWebAppListCall) (none) /// * [web apps patch enterprises](EnterpriseWebAppPatchCall) (none) /// * [web tokens create enterprises](EnterpriseWebTokenCreateCall) (none) /// * [create enterprises](EnterpriseCreateCall) (request|response) /// * [delete enterprises](EnterpriseDeleteCall) (none) /// * [get enterprises](EnterpriseGetCall) (response) /// * [list enterprises](EnterpriseListCall) (none) /// * [patch enterprises](EnterprisePatchCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Enterprise { /// Deprecated and unused. #[serde(rename="appAutoApprovalEnabled")] pub app_auto_approval_enabled: Option, /// The enterprise contact info of an EMM-managed enterprise. #[serde(rename="contactInfo")] pub contact_info: Option, /// The types of Google Pub/Sub notifications enabled for the enterprise. #[serde(rename="enabledNotificationTypes")] pub enabled_notification_types: Option>, /// The name of the enterprise displayed to users. #[serde(rename="enterpriseDisplayName")] pub enterprise_display_name: Option, /// 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. pub logo: Option, /// The name of the enterprise which is generated by the server during creation, in the form enterprises/{enterpriseId}. pub name: Option, /// 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. #[serde(rename="primaryColor")] pub primary_color: Option, /// The topic that Cloud Pub/Sub notifications are published to, in the form projects/{project}/topics/{topic}. This field is only required if Pub/Sub notifications are enabled. #[serde(rename="pubsubTopic")] pub pubsub_topic: Option, /// Sign-in details of the enterprise. #[serde(rename="signinDetails")] pub signin_details: Option>, /// 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. #[serde(rename="termsAndConditions")] pub terms_and_conditions: Option>, } impl client::RequestValue for Enterprise {} impl client::Resource for Enterprise {} impl client::ResponseResult for Enterprise {} /// Configuration to enable an app as an extension app, with the capability of interacting with Android Device Policy offline. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExtensionConfig { /// Fully qualified class name of the receiver service class for Android Device Policy to notify the extension app of any local command status updates. #[serde(rename="notificationReceiver")] pub notification_receiver: Option, /// Hex-encoded SHA256 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. #[serde(rename="signingKeyFingerprintsSha256")] pub signing_key_fingerprints_sha256: Option>, } impl client::Part for ExtensionConfig {} /// Data hosted at an external location. The data is to be downloaded by Android Device Policy and verified against the hash. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExternalData { /// 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. #[serde(rename="sha256Hash")] pub sha256_hash: Option, /// 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. pub url: Option, } impl client::Part for ExternalData {} /// 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 a device is outside the freeze period, normal update behavior 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FreezePeriod { /// 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}. #[serde(rename="endDate")] pub end_date: Option, /// The start date (inclusive) of the freeze period. Note: year must not be set. For example, {"month": 1,"date": 30}. #[serde(rename="startDate")] pub start_date: Option, } impl client::Part for FreezePeriod {} /// Information about device hardware. The fields related to temperature thresholds are only available if hardwareStatusEnabled is true in the device's policy. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HardwareInfo { /// Battery shutdown temperature thresholds in Celsius for each battery on the device. #[serde(rename="batteryShutdownTemperatures")] pub battery_shutdown_temperatures: Option>, /// Battery throttling temperature thresholds in Celsius for each battery on the device. #[serde(rename="batteryThrottlingTemperatures")] pub battery_throttling_temperatures: Option>, /// Brand of the device. For example, Google. pub brand: Option, /// CPU shutdown temperature thresholds in Celsius for each CPU on the device. #[serde(rename="cpuShutdownTemperatures")] pub cpu_shutdown_temperatures: Option>, /// CPU throttling temperature thresholds in Celsius for each CPU on the device. #[serde(rename="cpuThrottlingTemperatures")] pub cpu_throttling_temperatures: Option>, /// Baseband version. For example, MDM9625_104662.22.05.34p. #[serde(rename="deviceBasebandVersion")] pub device_baseband_version: Option, /// 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. #[serde(rename="enterpriseSpecificId")] pub enterprise_specific_id: Option, /// GPU shutdown temperature thresholds in Celsius for each GPU on the device. #[serde(rename="gpuShutdownTemperatures")] pub gpu_shutdown_temperatures: Option>, /// GPU throttling temperature thresholds in Celsius for each GPU on the device. #[serde(rename="gpuThrottlingTemperatures")] pub gpu_throttling_temperatures: Option>, /// Name of the hardware. For example, Angler. pub hardware: Option, /// Manufacturer. For example, Motorola. pub manufacturer: Option, /// The model of the device. For example, Asus Nexus 7. pub model: Option, /// The device serial number. #[serde(rename="serialNumber")] pub serial_number: Option, /// Device skin shutdown temperature thresholds in Celsius. #[serde(rename="skinShutdownTemperatures")] pub skin_shutdown_temperatures: Option>, /// Device skin throttling temperature thresholds in Celsius. #[serde(rename="skinThrottlingTemperatures")] pub skin_throttling_temperatures: Option>, } impl client::Part for HardwareInfo {} /// Hardware status. Temperatures may be compared to the temperature thresholds available in hardwareInfo to determine hardware health. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HardwareStatus { /// Current battery temperatures in Celsius for each battery on the device. #[serde(rename="batteryTemperatures")] pub battery_temperatures: Option>, /// Current CPU temperatures in Celsius for each CPU on the device. #[serde(rename="cpuTemperatures")] pub cpu_temperatures: Option>, /// 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. #[serde(rename="cpuUsages")] pub cpu_usages: Option>, /// The time the measurements were taken. #[serde(rename="createTime")] pub create_time: Option, /// 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. #[serde(rename="fanSpeeds")] pub fan_speeds: Option>, /// Current GPU temperatures in Celsius for each GPU on the device. #[serde(rename="gpuTemperatures")] pub gpu_temperatures: Option>, /// Current device skin temperatures in Celsius. #[serde(rename="skinTemperatures")] pub skin_temperatures: Option>, } impl client::Part for HardwareStatus {} /// Keyed app state reported by the app. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct KeyedAppState { /// The creation time of the app state on the device. #[serde(rename="createTime")] pub create_time: Option, /// 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”). pub data: Option, /// 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. pub key: Option, /// The time the app state was most recently updated. #[serde(rename="lastUpdateTime")] pub last_update_time: Option, /// 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. pub message: Option, /// The severity of the app state. pub severity: Option, } impl client::Part for KeyedAppState {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct KioskCustomization { /// Specifies whether the Settings app is allowed in kiosk mode. #[serde(rename="deviceSettings")] pub device_settings: Option, /// Sets the behavior of a device in kiosk mode when a user presses and holds (long-presses) the Power button. #[serde(rename="powerButtonActions")] pub power_button_actions: Option, /// Specifies whether system info and notifications are disabled in kiosk mode. #[serde(rename="statusBar")] pub status_bar: Option, /// 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. #[serde(rename="systemErrorWarnings")] pub system_error_warnings: Option, /// Specifies which navigation features are enabled (e.g. Home, Overview buttons) in kiosk mode. #[serde(rename="systemNavigation")] pub system_navigation: Option, } impl client::Part for KioskCustomization {} /// An action to launch an app. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LaunchAppAction { /// Package name of app to be launched #[serde(rename="packageName")] pub package_name: Option, } impl client::Part for LaunchAppAction {} /// Response to a request to list devices for a given enterprise. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [devices list enterprises](EnterpriseDeviceListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListDevicesResponse { /// The list of devices. pub devices: Option>, /// If there are more results, a token to retrieve next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for ListDevicesResponse {} /// Response to a request to list enterprises. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list enterprises](EnterpriseListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListEnterprisesResponse { /// The list of enterprises. pub enterprises: Option>, /// If there are more results, a token to retrieve next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for ListEnterprisesResponse {} /// The response message for Operations.ListOperations. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [devices operations list enterprises](EnterpriseDeviceOperationListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListOperationsResponse { /// The standard List next-page token. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A list of operations that matches the specified filter in the request. pub operations: Option>, } impl client::ResponseResult for ListOperationsResponse {} /// Response to a request to list policies for a given enterprise. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [policies list enterprises](EnterprisePolicyListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListPoliciesResponse { /// If there are more results, a token to retrieve next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// The list of policies. pub policies: Option>, } impl client::ResponseResult for ListPoliciesResponse {} /// Response to a request to list web apps for a given enterprise. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [web apps list enterprises](EnterpriseWebAppListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListWebAppsResponse { /// If there are more results, a token to retrieve next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// The list of web apps. #[serde(rename="webApps")] pub web_apps: Option>, } impl client::ResponseResult for ListWebAppsResponse {} /// The managed configurations template for the app, saved from the managed configurations iframe. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ManagedConfigurationTemplate { /// Optional, a map containing configuration variables defined for the configuration. #[serde(rename="configurationVariables")] pub configuration_variables: Option>, /// The ID of the managed configurations template. #[serde(rename="templateId")] pub template_id: Option, } impl client::Part for ManagedConfigurationTemplate {} /// Managed property. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ManagedProperty { /// The default value of the property. BUNDLE_ARRAY properties don't have a default value. #[serde(rename="defaultValue")] pub default_value: Option, /// A longer description of the property, providing more detail of what it affects. Localized. pub description: Option, /// For CHOICE or MULTISELECT properties, the list of possible entries. pub entries: Option>, /// The unique key that the app uses to identify the property, e.g. "com.google.android.gm.fieldname". pub key: Option, /// For BUNDLE_ARRAY properties, the list of nested properties. A BUNDLE_ARRAY property is at most two levels deep. #[serde(rename="nestedProperties")] pub nested_properties: Option>, /// The name of the property. Localized. pub title: Option, /// The type of the property. #[serde(rename="type")] pub type_: Option, } impl client::Part for ManagedProperty {} /// An entry of a managed property. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ManagedPropertyEntry { /// The human-readable name of the value. Localized. pub name: Option, /// The machine-readable value of the entry, which should be used in the configuration. Not localized. pub value: Option, } impl client::Part for ManagedPropertyEntry {} /// An event related to memory and storage measurements. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MemoryEvent { /// The number of free bytes in the medium, or for EXTERNAL_STORAGE_DETECTED, the total capacity in bytes of the storage medium. #[serde(rename="byteCount")] pub byte_count: Option, /// The creation time of the event. #[serde(rename="createTime")] pub create_time: Option, /// Event type. #[serde(rename="eventType")] pub event_type: Option, } impl client::Part for MemoryEvent {} /// Information about device memory and storage. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MemoryInfo { /// Total internal storage on device in bytes. #[serde(rename="totalInternalStorage")] pub total_internal_storage: Option, /// Total RAM on device in bytes. #[serde(rename="totalRam")] pub total_ram: Option, } impl client::Part for MemoryInfo {} /// Device network info. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NetworkInfo { /// IMEI number of the GSM device. For example, A1000031212. pub imei: Option, /// MEID number of the CDMA device. For example, A00000292788E1. pub meid: Option, /// Alphabetic name of current registered operator. For example, Vodafone. #[serde(rename="networkOperatorName")] pub network_operator_name: Option, /// Provides telephony information associated with each SIM card on the device. Only supported on fully managed devices starting from Android API level 23. #[serde(rename="telephonyInfos")] pub telephony_infos: Option>, /// Wi-Fi MAC address of the device. For example, 7c:11:11:11:11:11. #[serde(rename="wifiMacAddress")] pub wifi_mac_address: Option, } impl client::Part for NetworkInfo {} /// Provides detail about non-compliance with a policy setting. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NonComplianceDetail { /// If the policy setting could not be applied, the current value of the setting on the device. #[serde(rename="currentValue")] pub current_value: Option, /// 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 #[serde(rename="fieldPath")] pub field_path: Option, /// 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. #[serde(rename="installationFailureReason")] pub installation_failure_reason: Option, /// The reason the device is not in compliance with the setting. #[serde(rename="nonComplianceReason")] pub non_compliance_reason: Option, /// The package name indicating which app is out of compliance, if applicable. #[serde(rename="packageName")] pub package_name: Option, /// The name of the policy setting. This is the JSON field name of a top-level Policy field. #[serde(rename="settingName")] pub setting_name: Option, } impl client::Part for NonComplianceDetail {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NonComplianceDetailCondition { /// The reason the device is not in compliance with the setting. If not set, then this condition matches any reason. #[serde(rename="nonComplianceReason")] pub non_compliance_reason: Option, /// The package name of the app that's out of compliance. If not set, then this condition matches any package name. #[serde(rename="packageName")] pub package_name: Option, /// 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. #[serde(rename="settingName")] pub setting_name: Option, } impl client::Part for NonComplianceDetailCondition {} /// This feature is not generally available. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OncCertificateProvider { /// This feature is not generally available. #[serde(rename="certificateReferences")] pub certificate_references: Option>, /// This feature is not generally available. #[serde(rename="contentProviderEndpoint")] pub content_provider_endpoint: Option, } impl client::Part for OncCertificateProvider {} /// This resource represents a long-running operation that is the result of a network API call. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [devices operations get enterprises](EnterpriseDeviceOperationGetCall) (response) /// * [devices issue command enterprises](EnterpriseDeviceIssueCommandCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// 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. pub done: Option, /// The error result of the operation in case of failure or cancellation. pub error: Option, /// 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. pub metadata: Option>, /// 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}. pub name: Option, /// The normal response of the operation in case of success. 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. pub response: Option>, } impl client::ResponseResult for Operation {} /// A list of package names. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PackageNameList { /// A list of package names. #[serde(rename="packageNames")] pub package_names: Option>, } impl client::Part for PackageNameList {} /// Requirements for the password used to unlock a device. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PasswordRequirements { /// Number of incorrect device-unlock passwords that can be entered before a device is wiped. A value of 0 means there is no restriction. #[serde(rename="maximumFailedPasswordsForWipe")] pub maximum_failed_passwords_for_wipe: Option, /// Password expiration timeout. #[serde(rename="passwordExpirationTimeout")] pub password_expiration_timeout: Option, /// 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. #[serde(rename="passwordHistoryLength")] pub password_history_length: Option, /// 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. #[serde(rename="passwordMinimumLength")] pub password_minimum_length: Option, /// Minimum number of letters required in the password. Only enforced when password_quality is COMPLEX. #[serde(rename="passwordMinimumLetters")] pub password_minimum_letters: Option, /// Minimum number of lower case letters required in the password. Only enforced when password_quality is COMPLEX. #[serde(rename="passwordMinimumLowerCase")] pub password_minimum_lower_case: Option, /// Minimum number of non-letter characters (numerical digits or symbols) required in the password. Only enforced when password_quality is COMPLEX. #[serde(rename="passwordMinimumNonLetter")] pub password_minimum_non_letter: Option, /// Minimum number of numerical digits required in the password. Only enforced when password_quality is COMPLEX. #[serde(rename="passwordMinimumNumeric")] pub password_minimum_numeric: Option, /// Minimum number of symbols required in the password. Only enforced when password_quality is COMPLEX. #[serde(rename="passwordMinimumSymbols")] pub password_minimum_symbols: Option, /// Minimum number of upper case letters required in the password. Only enforced when password_quality is COMPLEX. #[serde(rename="passwordMinimumUpperCase")] pub password_minimum_upper_case: Option, /// The required password quality. #[serde(rename="passwordQuality")] pub password_quality: Option, /// The scope that the password requirement applies to. #[serde(rename="passwordScope")] pub password_scope: Option, /// 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. #[serde(rename="requirePasswordUnlock")] pub require_password_unlock: Option, /// 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 has no effect on other devices. 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. #[serde(rename="unifiedLockSettings")] pub unified_lock_settings: Option, } impl client::Part for PasswordRequirements {} /// Configuration for an Android permission and its grant state. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionGrant { /// The Android permission or group, e.g. android.permission.READ_CALENDAR or android.permission_group.CALENDAR. pub permission: Option, /// The policy for granting the permission. pub policy: Option, } impl client::Part for PermissionGrant {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersistentPreferredActivity { /// 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. pub actions: Option>, /// 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. pub categories: Option>, /// 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. #[serde(rename="receiverActivity")] pub receiver_activity: Option, } impl client::Part for PersistentPreferredActivity {} /// Policies for apps in the personal profile of a company-owned device with a work profile. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonalApplicationPolicy { /// The type of installation to perform. #[serde(rename="installType")] pub install_type: Option, /// The package name of the application. #[serde(rename="packageName")] pub package_name: Option, } impl client::Part for PersonalApplicationPolicy {} /// Policies controlling personal usage on a company-owned device with a work profile. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonalUsagePolicies { /// Account types that can't be managed by the user. #[serde(rename="accountTypesWithManagementDisabled")] pub account_types_with_management_disabled: Option>, /// Whether camera is disabled. #[serde(rename="cameraDisabled")] pub camera_disabled: Option, /// Controls how long the work profile can stay off. The duration must be at least 3 days. #[serde(rename="maxDaysWithWorkOff")] pub max_days_with_work_off: Option, /// Policy applied to applications in the personal profile. #[serde(rename="personalApplications")] pub personal_applications: Option>, /// Used together with personalApplications to control how apps in the personal profile are allowed or blocked. #[serde(rename="personalPlayStoreMode")] pub personal_play_store_mode: Option, /// Whether screen capture is disabled. #[serde(rename="screenCaptureDisabled")] pub screen_capture_disabled: Option, } impl client::Part for PersonalUsagePolicies {} /// A policy resource represents a group of settings that govern the behavior of a managed device and the apps installed on it. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [policies get enterprises](EnterprisePolicyGetCall) (response) /// * [policies patch enterprises](EnterprisePolicyPatchCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Policy { /// Account types that can't be managed by the user. #[serde(rename="accountTypesWithManagementDisabled")] pub account_types_with_management_disabled: Option>, /// Whether adding new users and profiles is disabled. #[serde(rename="addUserDisabled")] pub add_user_disabled: Option, /// Whether adjusting the master volume is disabled. Also mutes the device. #[serde(rename="adjustVolumeDisabled")] pub adjust_volume_disabled: Option, /// Security policies set to secure values by default. To maintain the security posture of a device, we don't recommend overriding any of the default values. #[serde(rename="advancedSecurityOverrides")] pub advanced_security_overrides: Option, /// Configuration for an always-on VPN connection. Use with vpn_config_disabled to prevent modification of this setting. #[serde(rename="alwaysOnVpnPackage")] pub always_on_vpn_package: Option, /// The app tracks for Android Device Policy the device can access. The device receives the latest version among all accessible tracks. If no tracks are specified, then the device only uses the production track. #[serde(rename="androidDevicePolicyTracks")] pub android_device_policy_tracks: Option>, /// Deprecated. Use autoUpdateMode instead.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. #[serde(rename="appAutoUpdatePolicy")] pub app_auto_update_policy: Option, /// Policy applied to apps. pub applications: Option>, /// Whether auto date, time, and time zone are enabled on a company-owned device. If this is set, then autoTimeRequired is ignored. #[serde(rename="autoDateAndTimeZone")] pub auto_date_and_time_zone: Option, /// Whether auto time is required, which prevents the user from manually setting the date and time. If autoDateAndTimeZone is set, this field is ignored. #[serde(rename="autoTimeRequired")] pub auto_time_required: Option, /// 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. #[serde(rename="blockApplicationsEnabled")] pub block_applications_enabled: Option, /// Whether configuring bluetooth is disabled. #[serde(rename="bluetoothConfigDisabled")] pub bluetooth_config_disabled: Option, /// Whether bluetooth contact sharing is disabled. #[serde(rename="bluetoothContactSharingDisabled")] pub bluetooth_contact_sharing_disabled: Option, /// Whether bluetooth is disabled. Prefer this setting over bluetooth_config_disabled because bluetooth_config_disabled can be bypassed by the user. #[serde(rename="bluetoothDisabled")] pub bluetooth_disabled: Option, /// Controls the use of the camera and whether the user has access to the camera access toggle. #[serde(rename="cameraAccess")] pub camera_access: Option, /// 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. #[serde(rename="cameraDisabled")] pub camera_disabled: Option, /// Whether configuring cell broadcast is disabled. #[serde(rename="cellBroadcastsConfigDisabled")] pub cell_broadcasts_config_disabled: Option, /// Rules for determining apps' access to private keys. See ChoosePrivateKeyRule for details. #[serde(rename="choosePrivateKeyRules")] pub choose_private_key_rules: Option>, /// 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. #[serde(rename="complianceRules")] pub compliance_rules: Option>, /// Whether creating windows besides app windows is disabled. #[serde(rename="createWindowsDisabled")] pub create_windows_disabled: Option, /// Whether configuring user credentials is disabled. #[serde(rename="credentialsConfigDisabled")] pub credentials_config_disabled: Option, /// Cross-profile policies applied on the device. #[serde(rename="crossProfilePolicies")] pub cross_profile_policies: Option, /// Whether roaming data services are disabled. #[serde(rename="dataRoamingDisabled")] pub data_roaming_disabled: Option, /// Whether the user is allowed to enable debugging features. #[serde(rename="debuggingFeaturesAllowed")] pub debugging_features_allowed: Option, /// The default permission policy for runtime permission requests. #[serde(rename="defaultPermissionPolicy")] pub default_permission_policy: Option, /// The device owner information to be shown on the lock screen. #[serde(rename="deviceOwnerLockScreenInfo")] pub device_owner_lock_screen_info: Option, /// Whether encryption is enabled #[serde(rename="encryptionPolicy")] pub encryption_policy: Option, /// Whether app verification is force-enabled. #[serde(rename="ensureVerifyAppsEnabled")] pub ensure_verify_apps_enabled: Option, /// Whether factory resetting from settings is disabled. #[serde(rename="factoryResetDisabled")] pub factory_reset_disabled: Option, /// 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. #[serde(rename="frpAdminEmails")] pub frp_admin_emails: Option>, /// Whether the user is allowed to have fun. Controls whether the Easter egg game in Settings is disabled. #[serde(rename="funDisabled")] pub fun_disabled: Option, /// Whether user installation of apps is disabled. #[serde(rename="installAppsDisabled")] pub install_apps_disabled: Option, /// This field has no effect. #[serde(rename="installUnknownSourcesAllowed")] pub install_unknown_sources_allowed: Option, /// Whether the keyguard is disabled. #[serde(rename="keyguardDisabled")] pub keyguard_disabled: Option, /// Disabled keyguard customizations, such as widgets. #[serde(rename="keyguardDisabledFeatures")] pub keyguard_disabled_features: Option>, /// 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. #[serde(rename="kioskCustomLauncherEnabled")] pub kiosk_custom_launcher_enabled: Option, /// 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. #[serde(rename="kioskCustomization")] pub kiosk_customization: Option, /// The degree of location detection enabled. #[serde(rename="locationMode")] pub location_mode: Option, /// A message displayed to the user in the device administators settings screen. #[serde(rename="longSupportMessage")] pub long_support_message: Option, /// Maximum time in milliseconds for user activity until the device locks. A value of 0 means there is no restriction. #[serde(rename="maximumTimeToLock")] pub maximum_time_to_lock: Option, /// Controls the use of the microphone and whether the user has access to the microphone access toggle. This applies only on fully managed devices. #[serde(rename="microphoneAccess")] pub microphone_access: Option, /// The minimum allowed Android API level. #[serde(rename="minimumApiLevel")] pub minimum_api_level: Option, /// Whether configuring mobile networks is disabled. #[serde(rename="mobileNetworksConfigDisabled")] pub mobile_networks_config_disabled: Option, /// Whether adding or removing accounts is disabled. #[serde(rename="modifyAccountsDisabled")] pub modify_accounts_disabled: Option, /// Whether the user mounting physical external media is disabled. #[serde(rename="mountPhysicalMediaDisabled")] pub mount_physical_media_disabled: Option, /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}. pub name: Option, /// 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. #[serde(rename="networkEscapeHatchEnabled")] pub network_escape_hatch_enabled: Option, /// Whether resetting network settings is disabled. #[serde(rename="networkResetDisabled")] pub network_reset_disabled: Option, /// This feature is not generally available. #[serde(rename="oncCertificateProviders")] pub onc_certificate_providers: Option>, /// Network configuration for the device. See configure networks for more information. #[serde(rename="openNetworkConfiguration")] pub open_network_configuration: Option>, /// Whether using NFC to beam data from apps is disabled. #[serde(rename="outgoingBeamDisabled")] pub outgoing_beam_disabled: Option, /// Whether outgoing calls are disabled. #[serde(rename="outgoingCallsDisabled")] pub outgoing_calls_disabled: Option, /// Password requirement policies. Different policies can be set for work profile or fully managed devices by setting the password_scope field in the policy. #[serde(rename="passwordPolicies")] pub password_policies: Option>, /// 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 #[serde(rename="passwordRequirements")] pub password_requirements: Option, /// Explicit permission or group grants or denials for all apps. These values override the default_permission_policy. #[serde(rename="permissionGrants")] pub permission_grants: Option>, /// 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. #[serde(rename="permittedAccessibilityServices")] pub permitted_accessibility_services: Option, /// 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. #[serde(rename="permittedInputMethods")] pub permitted_input_methods: Option, /// Default intent handler activities. #[serde(rename="persistentPreferredActivities")] pub persistent_preferred_activities: Option>, /// Policies managing personal usage on a company-owned device. #[serde(rename="personalUsagePolicies")] pub personal_usage_policies: Option, /// 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. #[serde(rename="playStoreMode")] pub play_store_mode: Option, /// Rules that define the behavior when a particular policy can not be applied on device #[serde(rename="policyEnforcementRules")] pub policy_enforcement_rules: Option>, /// 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. #[serde(rename="preferentialNetworkService")] pub preferential_network_service: Option, /// 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. #[serde(rename="privateKeySelectionEnabled")] pub private_key_selection_enabled: Option, /// 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. #[serde(rename="recommendedGlobalProxy")] pub recommended_global_proxy: Option, /// Whether removing other users is disabled. #[serde(rename="removeUserDisabled")] pub remove_user_disabled: Option, /// Whether rebooting the device into safe boot is disabled. #[serde(rename="safeBootDisabled")] pub safe_boot_disabled: Option, /// Whether screen capture is disabled. #[serde(rename="screenCaptureDisabled")] pub screen_capture_disabled: Option, /// Whether changing the user icon is disabled. #[serde(rename="setUserIconDisabled")] pub set_user_icon_disabled: Option, /// Whether changing the wallpaper is disabled. #[serde(rename="setWallpaperDisabled")] pub set_wallpaper_disabled: Option, /// Action to take during the setup process. At most one action may be specified. #[serde(rename="setupActions")] pub setup_actions: Option>, /// Whether location sharing is disabled. #[serde(rename="shareLocationDisabled")] pub share_location_disabled: Option, /// 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. #[serde(rename="shortSupportMessage")] pub short_support_message: Option, /// 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. #[serde(rename="skipFirstUseHintsEnabled")] pub skip_first_use_hints_enabled: Option, /// Whether sending and receiving SMS messages is disabled. #[serde(rename="smsDisabled")] pub sms_disabled: Option, /// 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. #[serde(rename="statusBarDisabled")] pub status_bar_disabled: Option, /// Status reporting settings #[serde(rename="statusReportingSettings")] pub status_reporting_settings: Option, /// 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. #[serde(rename="stayOnPluggedModes")] pub stay_on_plugged_modes: Option>, /// 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. #[serde(rename="systemUpdate")] pub system_update: Option, /// Whether configuring tethering and portable hotspots is disabled. #[serde(rename="tetheringConfigDisabled")] pub tethering_config_disabled: Option, /// Whether user uninstallation of applications is disabled. #[serde(rename="uninstallAppsDisabled")] pub uninstall_apps_disabled: Option, /// 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. #[serde(rename="unmuteMicrophoneDisabled")] pub unmute_microphone_disabled: Option, /// Whether transferring files over USB is disabled. #[serde(rename="usbFileTransferDisabled")] pub usb_file_transfer_disabled: Option, /// Whether USB storage is enabled. Deprecated. #[serde(rename="usbMassStorageEnabled")] pub usb_mass_storage_enabled: Option, /// The version of the policy. This is a read-only field. The version is incremented each time the policy is updated. pub version: Option, /// Whether configuring VPN is disabled. #[serde(rename="vpnConfigDisabled")] pub vpn_config_disabled: Option, /// Whether configuring Wi-Fi access points is disabled.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). #[serde(rename="wifiConfigDisabled")] pub wifi_config_disabled: Option, /// DEPRECATED - Use wifi_config_disabled. #[serde(rename="wifiConfigsLockdownEnabled")] pub wifi_configs_lockdown_enabled: Option, } impl client::RequestValue for Policy {} impl client::ResponseResult for Policy {} /// A rule that defines the actions to take if a device or work profile is not compliant with the policy specified in settingName. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PolicyEnforcementRule { /// An action to block access to apps and data on a fully managed 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. #[serde(rename="blockAction")] pub block_action: Option, /// The top-level policy to enforce. For example, applications or passwordPolicies. #[serde(rename="settingName")] pub setting_name: Option, /// An action to reset a fully managed device or delete a work profile. Note: blockAction must also be specified. #[serde(rename="wipeAction")] pub wipe_action: Option, } impl client::Part for PolicyEnforcementRule {} /// Additional details regarding the security posture of the device. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostureDetail { /// Corresponding admin-facing advice to mitigate this security risk and improve the security posture of the device. pub advice: Option>, /// A specific security risk that negatively affects the security posture of the device. #[serde(rename="securityRisk")] pub security_risk: Option, } impl client::Part for PostureDetail {} /// A power management event. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PowerManagementEvent { /// For BATTERY_LEVEL_COLLECTED events, the battery level as a percentage. #[serde(rename="batteryLevel")] pub battery_level: Option, /// The creation time of the event. #[serde(rename="createTime")] pub create_time: Option, /// Event type. #[serde(rename="eventType")] pub event_type: Option, } impl client::Part for PowerManagementEvent {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProxyInfo { /// For a direct proxy, the hosts for which the proxy is bypassed. The host names may contain wildcards such as *.example.com. #[serde(rename="excludedHosts")] pub excluded_hosts: Option>, /// The host of the direct proxy. pub host: Option, /// The URI of the PAC script used to configure the proxy. #[serde(rename="pacUri")] pub pac_uri: Option, /// The port of the direct proxy. pub port: Option, } impl client::Part for ProxyInfo {} /// The security posture of the device, as determined by the current device state and the policies applied. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SecurityPosture { /// Device's security posture value. #[serde(rename="devicePosture")] pub device_posture: Option, /// Additional details regarding the security posture of the device. #[serde(rename="postureDetails")] pub posture_details: Option>, } impl client::Part for SecurityPosture {} /// An action executed during setup. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SetupAction { /// Description of this action. pub description: Option, /// 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. #[serde(rename="launchApp")] pub launch_app: Option, /// Title of this action. pub title: Option, } impl client::Part for SetupAction {} /// A resource containing sign in details for an enterprise. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SigninDetail { /// 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. #[serde(rename="allowPersonalUsage")] pub allow_personal_usage: Option, /// 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. #[serde(rename="qrCode")] pub qr_code: Option, /// An enterprise wide enrollment token used to trigger custom sign-in flow. This is a read-only field generated by the server. #[serde(rename="signinEnrollmentToken")] pub signin_enrollment_token: Option, /// 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. #[serde(rename="signinUrl")] pub signin_url: Option, } impl client::Part for SigninDetail {} /// An enterprise signup URL. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [create signup urls](SignupUrlCreateCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SignupUrl { /// The name of the resource. Use this value in the signupUrl field when calling enterprises.create to complete the enterprise signup flow. pub name: Option, /// A URL where an enterprise admin can register their enterprise. The page can't be rendered in an iframe. pub url: Option, } impl client::Resource for SignupUrl {} impl client::ResponseResult for SignupUrl {} /// Information about device software. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SoftwareInfo { /// Android build ID string meant for displaying to the user. For example, shamu-userdebug 6.0.1 MOB30I 2756745 dev-keys. #[serde(rename="androidBuildNumber")] pub android_build_number: Option, /// Build time. #[serde(rename="androidBuildTime")] pub android_build_time: Option, /// The Android Device Policy app version code. #[serde(rename="androidDevicePolicyVersionCode")] pub android_device_policy_version_code: Option, /// The Android Device Policy app version as displayed to the user. #[serde(rename="androidDevicePolicyVersionName")] pub android_device_policy_version_name: Option, /// The user-visible Android version string. For example, 6.0.1. #[serde(rename="androidVersion")] pub android_version: Option, /// The system bootloader version number, e.g. 0.6.7. #[serde(rename="bootloaderVersion")] pub bootloader_version: Option, /// 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. #[serde(rename="deviceBuildSignature")] pub device_build_signature: Option, /// Kernel version, for example, 2.6.32.9-g103d848. #[serde(rename="deviceKernelVersion")] pub device_kernel_version: Option, /// An IETF BCP 47 language code for the primary locale on the device. #[serde(rename="primaryLanguageCode")] pub primary_language_code: Option, /// Security patch level, e.g. 2016-05-01. #[serde(rename="securityPatchLevel")] pub security_patch_level: Option, /// Information about a potential pending system update. #[serde(rename="systemUpdateInfo")] pub system_update_info: Option, } impl client::Part for SoftwareInfo {} /// 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). /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Status { /// The status code, which should be an enum value of google.rpc.Code. pub code: Option, /// A list of messages that carry the error details. There is a common set of message types for APIs to use. pub details: Option>>, /// 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. pub message: Option, } impl client::Part for Status {} /// Settings controlling the behavior of status reports. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StatusReportingSettings { /// Application reporting settings. Only applicable if application_reports_enabled is true. #[serde(rename="applicationReportingSettings")] pub application_reporting_settings: Option, /// Whether app reports are enabled. #[serde(rename="applicationReportsEnabled")] pub application_reports_enabled: Option, /// Whether Common Criteria Mode reporting is enabled. #[serde(rename="commonCriteriaModeEnabled")] pub common_criteria_mode_enabled: Option, /// Whether device settings reporting is enabled. #[serde(rename="deviceSettingsEnabled")] pub device_settings_enabled: Option, /// Whether displays reporting is enabled. Report data is not available for personally owned devices with work profiles. #[serde(rename="displayInfoEnabled")] pub display_info_enabled: Option, /// Whether hardware status reporting is enabled. Report data is not available for personally owned devices with work profiles. #[serde(rename="hardwareStatusEnabled")] pub hardware_status_enabled: Option, /// Whether memory event reporting is enabled. #[serde(rename="memoryInfoEnabled")] pub memory_info_enabled: Option, /// Whether network info reporting is enabled. #[serde(rename="networkInfoEnabled")] pub network_info_enabled: Option, /// Whether power management event reporting is enabled. Report data is not available for personally owned devices with work profiles. #[serde(rename="powerManagementEventsEnabled")] pub power_management_events_enabled: Option, /// Whether software info reporting is enabled. #[serde(rename="softwareInfoEnabled")] pub software_info_enabled: Option, /// Whether system properties reporting is enabled. #[serde(rename="systemPropertiesEnabled")] pub system_properties_enabled: Option, } impl client::Part for StatusReportingSettings {} /// Configuration for managing system updates /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SystemUpdate { /// 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. #[serde(rename="endMinutes")] pub end_minutes: Option, /// 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. #[serde(rename="freezePeriods")] pub freeze_periods: Option>, /// 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. #[serde(rename="startMinutes")] pub start_minutes: Option, /// The type of system update to configure. #[serde(rename="type")] pub type_: Option, } impl client::Part for SystemUpdate {} /// Information about a potential pending system update. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SystemUpdateInfo { /// 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). #[serde(rename="updateReceivedTime")] pub update_received_time: Option, /// The status of an update: whether an update exists and what type it is. #[serde(rename="updateStatus")] pub update_status: Option, } impl client::Part for SystemUpdateInfo {} /// Telephony information associated with a given SIM card on the device. Only supported on fully managed devices starting from Android API level 23. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TelephonyInfo { /// The carrier name associated with this SIM card. #[serde(rename="carrierName")] pub carrier_name: Option, /// The phone number associated with this SIM card. #[serde(rename="phoneNumber")] pub phone_number: Option, } impl client::Part for TelephonyInfo {} /// A terms and conditions page to be accepted during provisioning. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TermsAndConditions { /// A well-formatted HTML string. It will be parsed on the client with android.text.Html#fromHtml. pub content: Option, /// A short header which appears above the HTML content. pub header: Option, } impl client::Part for TermsAndConditions {} /// A user belonging to an enterprise. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct User { /// 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. #[serde(rename="accountIdentifier")] pub account_identifier: Option, } impl client::Part for User {} /// Provides a user-facing message with locale info. The maximum message length is 4096 characters. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserFacingMessage { /// 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. #[serde(rename="defaultMessage")] pub default_message: Option, /// 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. #[serde(rename="localizedMessages")] pub localized_messages: Option>, } impl client::Part for UserFacingMessage {} /// A web app. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [web apps create enterprises](EnterpriseWebAppCreateCall) (request|response) /// * [web apps get enterprises](EnterpriseWebAppGetCall) (response) /// * [web apps patch enterprises](EnterpriseWebAppPatchCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebApp { /// The display mode of the web app. #[serde(rename="displayMode")] pub display_mode: Option, /// A list of icons for the web app. Must have at least one element. pub icons: Option>, /// The name of the web app, which is generated by the server during creation in the form enterprises/{enterpriseId}/webApps/{packageName}. pub name: Option, /// The start URL, i.e. the URL that should load when the user opens the application. #[serde(rename="startUrl")] pub start_url: Option, /// 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). pub title: Option, /// 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. #[serde(rename="versionCode")] pub version_code: Option, } impl client::RequestValue for WebApp {} impl client::ResponseResult for WebApp {} /// An icon for a web app. Supported formats are: png, jpg and webp. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebAppIcon { /// 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. #[serde(rename="imageData")] pub image_data: Option, } impl client::Part for WebAppIcon {} /// A web token used to access the managed Google Play iframe. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [web tokens create enterprises](EnterpriseWebTokenCreateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebToken { /// 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 #[serde(rename="enabledFeatures")] pub enabled_features: Option>, /// The name of the web token, which is generated by the server during creation in the form enterprises/{enterpriseId}/webTokens/{webTokenId}. pub name: Option, /// 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. #[serde(rename="parentFrameUrl")] pub parent_frame_url: Option, /// 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. pub permissions: Option>, /// 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. pub value: Option, } impl client::RequestValue for WebToken {} impl client::ResponseResult for WebToken {} /// An action to reset a fully managed device or delete a work profile. Note: blockAction must also be specified. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WipeAction { /// Whether the factory-reset protection data is preserved on the device. This setting doesn’t apply to work profiles. #[serde(rename="preserveFrp")] pub preserve_frp: Option, /// Number of days the policy is non-compliant before the device or work profile is wiped. wipeAfterDays must be greater than blockAfterDays. #[serde(rename="wipeAfterDays")] pub wipe_after_days: Option, } impl client::Part for WipeAction {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *enterprise* resources. /// It is not used directly, but through the `AndroidManagement` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_androidmanagement1 as androidmanagement1; /// /// # async fn dox() { /// use std::default::Default; /// use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `applications_get(...)`, `create(...)`, `delete(...)`, `devices_delete(...)`, `devices_get(...)`, `devices_issue_command(...)`, `devices_list(...)`, `devices_operations_cancel(...)`, `devices_operations_delete(...)`, `devices_operations_get(...)`, `devices_operations_list(...)`, `devices_patch(...)`, `enrollment_tokens_create(...)`, `enrollment_tokens_delete(...)`, `get(...)`, `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(...)` /// // to build up your call. /// let rb = hub.enterprises(); /// # } /// ``` pub struct EnterpriseMethods<'a> where { hub: &'a AndroidManagement<>, } impl<'a> client::MethodsBuilder for EnterpriseMethods<'a> {} impl<'a> EnterpriseMethods<'a> { /// Create a builder to help you perform the following task: /// /// Gets info about an application. /// /// # Arguments /// /// * `name` - The name of the application in the form enterprises/{enterpriseId}/applications/{package_name}. pub fn applications_get(&self, name: &str) -> EnterpriseApplicationGetCall<'a> { EnterpriseApplicationGetCall { hub: self.hub, _name: name.to_string(), _language_code: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `name` - The name of the operation resource to be cancelled. pub fn devices_operations_cancel(&self, name: &str) -> EnterpriseDeviceOperationCancelCall<'a> { EnterpriseDeviceOperationCancelCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. /// /// # Arguments /// /// * `name` - The name of the operation resource to be deleted. pub fn devices_operations_delete(&self, name: &str) -> EnterpriseDeviceOperationDeleteCall<'a> { EnterpriseDeviceOperationDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `name` - The name of the operation resource. pub fn devices_operations_get(&self, name: &str) -> EnterpriseDeviceOperationGetCall<'a> { EnterpriseDeviceOperationGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED.NOTE: the name binding allows API services to override the binding to use different resource name schemes, such as users/*/operations. To override the binding, API services can add a binding such as "/v1/{name=users/*}/operations" to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id. /// /// # Arguments /// /// * `name` - The name of the operation's parent resource. pub fn devices_operations_list(&self, name: &str) -> EnterpriseDeviceOperationListCall<'a> { EnterpriseDeviceOperationListCall { hub: self.hub, _name: name.to_string(), _page_token: Default::default(), _page_size: Default::default(), _filter: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a device. This operation wipes the device. /// /// # Arguments /// /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. pub fn devices_delete(&self, name: &str) -> EnterpriseDeviceDeleteCall<'a> { EnterpriseDeviceDeleteCall { hub: self.hub, _name: name.to_string(), _wipe_reason_message: Default::default(), _wipe_data_flags: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a device. /// /// # Arguments /// /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. pub fn devices_get(&self, name: &str) -> EnterpriseDeviceGetCall<'a> { EnterpriseDeviceGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. pub fn devices_issue_command(&self, request: Command, name: &str) -> EnterpriseDeviceIssueCommandCall<'a> { EnterpriseDeviceIssueCommandCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists devices for a given enterprise. /// /// # Arguments /// /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn devices_list(&self, parent: &str) -> EnterpriseDeviceListCall<'a> { EnterpriseDeviceListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a device. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. pub fn devices_patch(&self, request: Device, name: &str) -> EnterpriseDevicePatchCall<'a> { EnterpriseDevicePatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates an enrollment token for a given enterprise. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn enrollment_tokens_create(&self, request: EnrollmentToken, parent: &str) -> EnterpriseEnrollmentTokenCreateCall<'a> { EnterpriseEnrollmentTokenCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes an enrollment token. This operation invalidates the token, preventing its future use. /// /// # Arguments /// /// * `name` - The name of the enrollment token in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}. pub fn enrollment_tokens_delete(&self, name: &str) -> EnterpriseEnrollmentTokenDeleteCall<'a> { EnterpriseEnrollmentTokenDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a policy. This operation is only permitted if no devices are currently referencing the policy. /// /// # Arguments /// /// * `name` - The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}. pub fn policies_delete(&self, name: &str) -> EnterprisePolicyDeleteCall<'a> { EnterprisePolicyDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a policy. /// /// # Arguments /// /// * `name` - The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}. pub fn policies_get(&self, name: &str) -> EnterprisePolicyGetCall<'a> { EnterprisePolicyGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists policies for a given enterprise. /// /// # Arguments /// /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn policies_list(&self, parent: &str) -> EnterprisePolicyListCall<'a> { EnterprisePolicyListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates or creates a policy. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}. pub fn policies_patch(&self, request: Policy, name: &str) -> EnterprisePolicyPatchCall<'a> { EnterprisePolicyPatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a web app. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn web_apps_create(&self, request: WebApp, parent: &str) -> EnterpriseWebAppCreateCall<'a> { EnterpriseWebAppCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a web app. /// /// # Arguments /// /// * `name` - The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}. pub fn web_apps_delete(&self, name: &str) -> EnterpriseWebAppDeleteCall<'a> { EnterpriseWebAppDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a web app. /// /// # Arguments /// /// * `name` - The name of the web app in the form enterprises/{enterpriseId}/webApp/{packageName}. pub fn web_apps_get(&self, name: &str) -> EnterpriseWebAppGetCall<'a> { EnterpriseWebAppGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists web apps for a given enterprise. /// /// # Arguments /// /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn web_apps_list(&self, parent: &str) -> EnterpriseWebAppListCall<'a> { EnterpriseWebAppListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a web app. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}. pub fn web_apps_patch(&self, request: WebApp, name: &str) -> EnterpriseWebAppPatchCall<'a> { EnterpriseWebAppPatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a web token to access an embeddable managed Google Play web UI for a given enterprise. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn web_tokens_create(&self, request: WebToken, parent: &str) -> EnterpriseWebTokenCreateCall<'a> { EnterpriseWebTokenCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates an enterprise. This is the last step in the enterprise signup flow. /// /// # Arguments /// /// * `request` - No description provided. pub fn create(&self, request: Enterprise) -> EnterpriseCreateCall<'a> { EnterpriseCreateCall { hub: self.hub, _request: request, _signup_url_name: Default::default(), _project_id: Default::default(), _enterprise_token: Default::default(), _agreement_accepted: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes an enterprise. Only available for EMM-managed enterprises. /// /// # Arguments /// /// * `name` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn delete(&self, name: &str) -> EnterpriseDeleteCall<'a> { EnterpriseDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets an enterprise. /// /// # Arguments /// /// * `name` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn get(&self, name: &str) -> EnterpriseGetCall<'a> { EnterpriseGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists EMM-managed enterprises. Only BASIC fields are returned. pub fn list(&self) -> EnterpriseListCall<'a> { EnterpriseListCall { hub: self.hub, _view: Default::default(), _project_id: Default::default(), _page_token: Default::default(), _page_size: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an enterprise. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The name of the enterprise in the form enterprises/{enterpriseId}. pub fn patch(&self, request: Enterprise, name: &str) -> EnterprisePatchCall<'a> { EnterprisePatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *signupUrl* resources. /// It is not used directly, but through the `AndroidManagement` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_androidmanagement1 as androidmanagement1; /// /// # async fn dox() { /// use std::default::Default; /// use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `create(...)` /// // to build up your call. /// let rb = hub.signup_urls(); /// # } /// ``` pub struct SignupUrlMethods<'a> where { hub: &'a AndroidManagement<>, } impl<'a> client::MethodsBuilder for SignupUrlMethods<'a> {} impl<'a> SignupUrlMethods<'a> { /// Create a builder to help you perform the following task: /// /// Creates an enterprise signup URL. pub fn create(&self) -> SignupUrlCreateCall<'a> { SignupUrlCreateCall { hub: self.hub, _project_id: Default::default(), _callback_url: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Gets info about an application. /// /// A builder for the *applications.get* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().applications_get("name") /// .language_code("Lorem") /// .doit().await; /// # } /// ``` pub struct EnterpriseApplicationGetCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _language_code: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseApplicationGetCall<'a> {} impl<'a> EnterpriseApplicationGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Application)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.applications.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._language_code { params.push(("languageCode", value.to_string())); } for &field in ["alt", "name", "languageCode"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the application in the form enterprises/{enterpriseId}/applications/{package_name}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseApplicationGetCall<'a> { self._name = new_value.to_string(); self } /// 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. /// /// Sets the *language code* query property to the given value. pub fn language_code(mut self, new_value: &str) -> EnterpriseApplicationGetCall<'a> { self._language_code = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseApplicationGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseApplicationGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseApplicationGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// 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. /// /// A builder for the *devices.operations.cancel* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_operations_cancel("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceOperationCancelCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceOperationCancelCall<'a> {} impl<'a> EnterpriseDeviceOperationCancelCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.operations.cancel", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the operation resource to be cancelled. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeviceOperationCancelCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceOperationCancelCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceOperationCancelCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceOperationCancelCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. /// /// A builder for the *devices.operations.delete* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_operations_delete("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceOperationDeleteCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceOperationDeleteCall<'a> {} impl<'a> EnterpriseDeviceOperationDeleteCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.operations.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the operation resource to be deleted. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeviceOperationDeleteCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceOperationDeleteCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceOperationDeleteCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceOperationDeleteCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// 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. /// /// A builder for the *devices.operations.get* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_operations_get("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceOperationGetCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceOperationGetCall<'a> {} impl<'a> EnterpriseDeviceOperationGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Operation)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.operations.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the operation resource. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeviceOperationGetCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceOperationGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceOperationGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceOperationGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED.NOTE: the name binding allows API services to override the binding to use different resource name schemes, such as users/*/operations. To override the binding, API services can add a binding such as "/v1/{name=users/*}/operations" to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id. /// /// A builder for the *devices.operations.list* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_operations_list("name") /// .page_token("ipsum") /// .page_size(-88) /// .filter("amet") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceOperationListCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _page_token: Option, _page_size: Option, _filter: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceOperationListCall<'a> {} impl<'a> EnterpriseDeviceOperationListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListOperationsResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.operations.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } if let Some(value) = self._filter { params.push(("filter", value.to_string())); } for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the operation's parent resource. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeviceOperationListCall<'a> { self._name = new_value.to_string(); self } /// The standard list page token. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> EnterpriseDeviceOperationListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// The standard list page size. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> EnterpriseDeviceOperationListCall<'a> { self._page_size = Some(new_value); self } /// The standard list filter. /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> EnterpriseDeviceOperationListCall<'a> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceOperationListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceOperationListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceOperationListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes a device. This operation wipes the device. /// /// A builder for the *devices.delete* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_delete("name") /// .wipe_reason_message("ipsum") /// .add_wipe_data_flags("sed") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceDeleteCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _wipe_reason_message: Option, _wipe_data_flags: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceDeleteCall<'a> {} impl<'a> EnterpriseDeviceDeleteCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._wipe_reason_message { params.push(("wipeReasonMessage", value.to_string())); } if self._wipe_data_flags.len() > 0 { for f in self._wipe_data_flags.iter() { params.push(("wipeDataFlags", f.to_string())); } } for &field in ["alt", "name", "wipeReasonMessage", "wipeDataFlags"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeviceDeleteCall<'a> { self._name = new_value.to_string(); self } /// 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. /// /// Sets the *wipe reason message* query property to the given value. pub fn wipe_reason_message(mut self, new_value: &str) -> EnterpriseDeviceDeleteCall<'a> { self._wipe_reason_message = Some(new_value.to_string()); self } /// Optional flags that control the device wiping behavior. /// /// Append the given value to the *wipe data flags* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_wipe_data_flags(mut self, new_value: &str) -> EnterpriseDeviceDeleteCall<'a> { self._wipe_data_flags.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceDeleteCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceDeleteCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceDeleteCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets a device. /// /// A builder for the *devices.get* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_get("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceGetCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceGetCall<'a> {} impl<'a> EnterpriseDeviceGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Device)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeviceGetCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// 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. /// /// A builder for the *devices.issueCommand* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::Command; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Command::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_issue_command(req, "name") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceIssueCommandCall<'a> where { hub: &'a AndroidManagement<>, _request: Command, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceIssueCommandCall<'a> {} impl<'a> EnterpriseDeviceIssueCommandCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Operation)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.issueCommand", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}:issueCommand"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Command) -> EnterpriseDeviceIssueCommandCall<'a> { self._request = new_value; self } /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeviceIssueCommandCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceIssueCommandCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceIssueCommandCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceIssueCommandCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists devices for a given enterprise. /// /// A builder for the *devices.list* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_list("parent") /// .page_token("est") /// .page_size(-50) /// .doit().await; /// # } /// ``` pub struct EnterpriseDeviceListCall<'a> where { hub: &'a AndroidManagement<>, _parent: String, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeviceListCall<'a> {} impl<'a> EnterpriseDeviceListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListDevicesResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } for &field in ["alt", "parent", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/devices"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> EnterpriseDeviceListCall<'a> { self._parent = new_value.to_string(); self } /// A token identifying a page of results returned by the server. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> EnterpriseDeviceListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// The requested page size. The actual page size may be fixed to a min or max value. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> EnterpriseDeviceListCall<'a> { self._page_size = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeviceListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeviceListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeviceListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates a device. /// /// A builder for the *devices.patch* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::Device; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Device::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().devices_patch(req, "name") /// .update_mask("est") /// .doit().await; /// # } /// ``` pub struct EnterpriseDevicePatchCall<'a> where { hub: &'a AndroidManagement<>, _request: Device, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDevicePatchCall<'a> {} impl<'a> EnterpriseDevicePatchCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Device)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.devices.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._update_mask { params.push(("updateMask", value.to_string())); } for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Device) -> EnterpriseDevicePatchCall<'a> { self._request = new_value; self } /// The name of the device in the form enterprises/{enterpriseId}/devices/{deviceId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDevicePatchCall<'a> { self._name = new_value.to_string(); self } /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified. /// /// Sets the *update mask* query property to the given value. pub fn update_mask(mut self, new_value: &str) -> EnterpriseDevicePatchCall<'a> { self._update_mask = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDevicePatchCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDevicePatchCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDevicePatchCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates an enrollment token for a given enterprise. /// /// A builder for the *enrollmentTokens.create* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::EnrollmentToken; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = EnrollmentToken::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().enrollment_tokens_create(req, "parent") /// .doit().await; /// # } /// ``` pub struct EnterpriseEnrollmentTokenCreateCall<'a> where { hub: &'a AndroidManagement<>, _request: EnrollmentToken, _parent: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseEnrollmentTokenCreateCall<'a> {} impl<'a> EnterpriseEnrollmentTokenCreateCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, EnrollmentToken)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.enrollmentTokens.create", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); for &field in ["alt", "parent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/enrollmentTokens"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: EnrollmentToken) -> EnterpriseEnrollmentTokenCreateCall<'a> { self._request = new_value; self } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> EnterpriseEnrollmentTokenCreateCall<'a> { self._parent = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseEnrollmentTokenCreateCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseEnrollmentTokenCreateCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseEnrollmentTokenCreateCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an enrollment token. This operation invalidates the token, preventing its future use. /// /// A builder for the *enrollmentTokens.delete* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().enrollment_tokens_delete("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseEnrollmentTokenDeleteCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseEnrollmentTokenDeleteCall<'a> {} impl<'a> EnterpriseEnrollmentTokenDeleteCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.enrollmentTokens.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the enrollment token in the form enterprises/{enterpriseId}/enrollmentTokens/{enrollmentTokenId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseEnrollmentTokenDeleteCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseEnrollmentTokenDeleteCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseEnrollmentTokenDeleteCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseEnrollmentTokenDeleteCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes a policy. This operation is only permitted if no devices are currently referencing the policy. /// /// A builder for the *policies.delete* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().policies_delete("name") /// .doit().await; /// # } /// ``` pub struct EnterprisePolicyDeleteCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterprisePolicyDeleteCall<'a> {} impl<'a> EnterprisePolicyDeleteCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.policies.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterprisePolicyDeleteCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterprisePolicyDeleteCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterprisePolicyDeleteCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterprisePolicyDeleteCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets a policy. /// /// A builder for the *policies.get* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().policies_get("name") /// .doit().await; /// # } /// ``` pub struct EnterprisePolicyGetCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterprisePolicyGetCall<'a> {} impl<'a> EnterprisePolicyGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Policy)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.policies.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterprisePolicyGetCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterprisePolicyGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterprisePolicyGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterprisePolicyGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists policies for a given enterprise. /// /// A builder for the *policies.list* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().policies_list("parent") /// .page_token("labore") /// .page_size(-43) /// .doit().await; /// # } /// ``` pub struct EnterprisePolicyListCall<'a> where { hub: &'a AndroidManagement<>, _parent: String, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterprisePolicyListCall<'a> {} impl<'a> EnterprisePolicyListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListPoliciesResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.policies.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } for &field in ["alt", "parent", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/policies"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> EnterprisePolicyListCall<'a> { self._parent = new_value.to_string(); self } /// A token identifying a page of results returned by the server. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> EnterprisePolicyListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// The requested page size. The actual page size may be fixed to a min or max value. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> EnterprisePolicyListCall<'a> { self._page_size = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterprisePolicyListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterprisePolicyListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterprisePolicyListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates or creates a policy. /// /// A builder for the *policies.patch* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::Policy; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Policy::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().policies_patch(req, "name") /// .update_mask("sed") /// .doit().await; /// # } /// ``` pub struct EnterprisePolicyPatchCall<'a> where { hub: &'a AndroidManagement<>, _request: Policy, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterprisePolicyPatchCall<'a> {} impl<'a> EnterprisePolicyPatchCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Policy)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.policies.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._update_mask { params.push(("updateMask", value.to_string())); } for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Policy) -> EnterprisePolicyPatchCall<'a> { self._request = new_value; self } /// The name of the policy in the form enterprises/{enterpriseId}/policies/{policyId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterprisePolicyPatchCall<'a> { self._name = new_value.to_string(); self } /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified. /// /// Sets the *update mask* query property to the given value. pub fn update_mask(mut self, new_value: &str) -> EnterprisePolicyPatchCall<'a> { self._update_mask = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterprisePolicyPatchCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterprisePolicyPatchCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterprisePolicyPatchCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates a web app. /// /// A builder for the *webApps.create* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::WebApp; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = WebApp::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().web_apps_create(req, "parent") /// .doit().await; /// # } /// ``` pub struct EnterpriseWebAppCreateCall<'a> where { hub: &'a AndroidManagement<>, _request: WebApp, _parent: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseWebAppCreateCall<'a> {} impl<'a> EnterpriseWebAppCreateCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, WebApp)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.webApps.create", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); for &field in ["alt", "parent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/webApps"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: WebApp) -> EnterpriseWebAppCreateCall<'a> { self._request = new_value; self } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> EnterpriseWebAppCreateCall<'a> { self._parent = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseWebAppCreateCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseWebAppCreateCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseWebAppCreateCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes a web app. /// /// A builder for the *webApps.delete* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().web_apps_delete("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseWebAppDeleteCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseWebAppDeleteCall<'a> {} impl<'a> EnterpriseWebAppDeleteCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.webApps.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseWebAppDeleteCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseWebAppDeleteCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseWebAppDeleteCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseWebAppDeleteCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets a web app. /// /// A builder for the *webApps.get* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().web_apps_get("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseWebAppGetCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseWebAppGetCall<'a> {} impl<'a> EnterpriseWebAppGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, WebApp)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.webApps.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the web app in the form enterprises/{enterpriseId}/webApp/{packageName}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseWebAppGetCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseWebAppGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseWebAppGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseWebAppGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists web apps for a given enterprise. /// /// A builder for the *webApps.list* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().web_apps_list("parent") /// .page_token("sed") /// .page_size(-24) /// .doit().await; /// # } /// ``` pub struct EnterpriseWebAppListCall<'a> where { hub: &'a AndroidManagement<>, _parent: String, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseWebAppListCall<'a> {} impl<'a> EnterpriseWebAppListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListWebAppsResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.webApps.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } for &field in ["alt", "parent", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/webApps"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> EnterpriseWebAppListCall<'a> { self._parent = new_value.to_string(); self } /// A token identifying a page of results returned by the server. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> EnterpriseWebAppListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// The requested page size. This is a hint and the actual page size in the response may be different. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> EnterpriseWebAppListCall<'a> { self._page_size = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseWebAppListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseWebAppListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseWebAppListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates a web app. /// /// A builder for the *webApps.patch* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::WebApp; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = WebApp::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().web_apps_patch(req, "name") /// .update_mask("vero") /// .doit().await; /// # } /// ``` pub struct EnterpriseWebAppPatchCall<'a> where { hub: &'a AndroidManagement<>, _request: WebApp, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseWebAppPatchCall<'a> {} impl<'a> EnterpriseWebAppPatchCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, WebApp)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.webApps.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._update_mask { params.push(("updateMask", value.to_string())); } for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: WebApp) -> EnterpriseWebAppPatchCall<'a> { self._request = new_value; self } /// The name of the web app in the form enterprises/{enterpriseId}/webApps/{packageName}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseWebAppPatchCall<'a> { self._name = new_value.to_string(); self } /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified. /// /// Sets the *update mask* query property to the given value. pub fn update_mask(mut self, new_value: &str) -> EnterpriseWebAppPatchCall<'a> { self._update_mask = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseWebAppPatchCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseWebAppPatchCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseWebAppPatchCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates a web token to access an embeddable managed Google Play web UI for a given enterprise. /// /// A builder for the *webTokens.create* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::WebToken; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = WebToken::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().web_tokens_create(req, "parent") /// .doit().await; /// # } /// ``` pub struct EnterpriseWebTokenCreateCall<'a> where { hub: &'a AndroidManagement<>, _request: WebToken, _parent: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseWebTokenCreateCall<'a> {} impl<'a> EnterpriseWebTokenCreateCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, WebToken)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.webTokens.create", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); for &field in ["alt", "parent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/webTokens"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: WebToken) -> EnterpriseWebTokenCreateCall<'a> { self._request = new_value; self } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> EnterpriseWebTokenCreateCall<'a> { self._parent = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseWebTokenCreateCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseWebTokenCreateCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseWebTokenCreateCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates an enterprise. This is the last step in the enterprise signup flow. /// /// A builder for the *create* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::Enterprise; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Enterprise::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().create(req) /// .signup_url_name("sed") /// .project_id("duo") /// .enterprise_token("dolore") /// .agreement_accepted(false) /// .doit().await; /// # } /// ``` pub struct EnterpriseCreateCall<'a> where { hub: &'a AndroidManagement<>, _request: Enterprise, _signup_url_name: Option, _project_id: Option, _enterprise_token: Option, _agreement_accepted: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseCreateCall<'a> {} impl<'a> EnterpriseCreateCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Enterprise)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.create", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); if let Some(value) = self._signup_url_name { params.push(("signupUrlName", value.to_string())); } if let Some(value) = self._project_id { params.push(("projectId", value.to_string())); } if let Some(value) = self._enterprise_token { params.push(("enterpriseToken", value.to_string())); } if let Some(value) = self._agreement_accepted { params.push(("agreementAccepted", value.to_string())); } for &field in ["alt", "signupUrlName", "projectId", "enterpriseToken", "agreementAccepted"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/enterprises"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Enterprise) -> EnterpriseCreateCall<'a> { self._request = new_value; self } /// The name of the SignupUrl used to sign up for the enterprise. Only set this when creating a customer-managed enterprise. /// /// Sets the *signup url name* query property to the given value. pub fn signup_url_name(mut self, new_value: &str) -> EnterpriseCreateCall<'a> { self._signup_url_name = Some(new_value.to_string()); self } /// The ID of the Google Cloud Platform project which will own the enterprise. /// /// Sets the *project id* query property to the given value. pub fn project_id(mut self, new_value: &str) -> EnterpriseCreateCall<'a> { self._project_id = Some(new_value.to_string()); self } /// The enterprise token appended to the callback URL. Only set this when creating a customer-managed enterprise. /// /// Sets the *enterprise token* query property to the given value. pub fn enterprise_token(mut self, new_value: &str) -> EnterpriseCreateCall<'a> { self._enterprise_token = Some(new_value.to_string()); self } /// Whether the enterprise admin has seen and agreed to the managed Google Play Agreement (https://www.android.com/enterprise/terms/). Always set this to true when creating an EMM-managed enterprise. Do not create the enterprise until the admin has viewed and accepted the agreement. /// /// Sets the *agreement accepted* query property to the given value. pub fn agreement_accepted(mut self, new_value: bool) -> EnterpriseCreateCall<'a> { self._agreement_accepted = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseCreateCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseCreateCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseCreateCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an enterprise. Only available for EMM-managed enterprises. /// /// A builder for the *delete* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().delete("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseDeleteCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseDeleteCall<'a> {} impl<'a> EnterpriseDeleteCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseDeleteCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseDeleteCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseDeleteCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseDeleteCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets an enterprise. /// /// A builder for the *get* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().get("name") /// .doit().await; /// # } /// ``` pub struct EnterpriseGetCall<'a> where { hub: &'a AndroidManagement<>, _name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseGetCall<'a> {} impl<'a> EnterpriseGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Enterprise)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterpriseGetCall<'a> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists EMM-managed enterprises. Only BASIC fields are returned. /// /// A builder for the *list* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().list() /// .view("et") /// .project_id("et") /// .page_token("sadipscing") /// .page_size(-15) /// .doit().await; /// # } /// ``` pub struct EnterpriseListCall<'a> where { hub: &'a AndroidManagement<>, _view: Option, _project_id: Option, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterpriseListCall<'a> {} impl<'a> EnterpriseListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListEnterprisesResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); if let Some(value) = self._view { params.push(("view", value.to_string())); } if let Some(value) = self._project_id { params.push(("projectId", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } for &field in ["alt", "view", "projectId", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/enterprises"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Specifies which Enterprise fields to return. This method only supports BASIC. /// /// Sets the *view* query property to the given value. pub fn view(mut self, new_value: &str) -> EnterpriseListCall<'a> { self._view = Some(new_value.to_string()); self } /// Required. The Cloud project ID of the EMM managing the enterprises. /// /// Sets the *project id* query property to the given value. pub fn project_id(mut self, new_value: &str) -> EnterpriseListCall<'a> { self._project_id = Some(new_value.to_string()); self } /// A token identifying a page of results returned by the server. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> EnterpriseListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// The requested page size. The actual page size may be fixed to a min or max value. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> EnterpriseListCall<'a> { self._page_size = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterpriseListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterpriseListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterpriseListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an enterprise. /// /// A builder for the *patch* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// use androidmanagement1::api::Enterprise; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Enterprise::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.enterprises().patch(req, "name") /// .update_mask("duo") /// .doit().await; /// # } /// ``` pub struct EnterprisePatchCall<'a> where { hub: &'a AndroidManagement<>, _request: Enterprise, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for EnterprisePatchCall<'a> {} impl<'a> EnterprisePatchCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Enterprise)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.enterprises.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._update_mask { params.push(("updateMask", value.to_string())); } for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Enterprise) -> EnterprisePatchCall<'a> { self._request = new_value; self } /// The name of the enterprise in the form enterprises/{enterpriseId}. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> EnterprisePatchCall<'a> { self._name = new_value.to_string(); self } /// The field mask indicating the fields to update. If not set, all modifiable fields will be modified. /// /// Sets the *update mask* query property to the given value. pub fn update_mask(mut self, new_value: &str) -> EnterprisePatchCall<'a> { self._update_mask = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EnterprisePatchCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> EnterprisePatchCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EnterprisePatchCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates an enterprise signup URL. /// /// A builder for the *create* method supported by a *signupUrl* resource. /// It is not used directly, but through a `SignupUrlMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_androidmanagement1 as androidmanagement1; /// # async fn dox() { /// # use std::default::Default; /// # use androidmanagement1::{AndroidManagement, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = AndroidManagement::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.signup_urls().create() /// .project_id("vero") /// .callback_url("vero") /// .doit().await; /// # } /// ``` pub struct SignupUrlCreateCall<'a> where { hub: &'a AndroidManagement<>, _project_id: Option, _callback_url: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for SignupUrlCreateCall<'a> {} impl<'a> SignupUrlCreateCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, SignupUrl)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "androidmanagement.signupUrls.create", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); if let Some(value) = self._project_id { params.push(("projectId", value.to_string())); } if let Some(value) = self._callback_url { params.push(("callbackUrl", value.to_string())); } for &field in ["alt", "projectId", "callbackUrl"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/signupUrls"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the Google Cloud Platform project which will own the enterprise. /// /// Sets the *project id* query property to the given value. pub fn project_id(mut self, new_value: &str) -> SignupUrlCreateCall<'a> { self._project_id = Some(new_value.to_string()); self } /// 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. /// /// Sets the *callback url* query property to the given value. pub fn callback_url(mut self, new_value: &str) -> SignupUrlCreateCall<'a> { self._callback_url = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SignupUrlCreateCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> SignupUrlCreateCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SignupUrlCreateCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } }