mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-21 18:54:07 +01:00
8236 lines
357 KiB
Rust
8236 lines
357 KiB
Rust
// DO NOT EDIT !
|
||
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
||
// DO NOT EDIT !
|
||
|
||
//! This documentation was generated from *Android Provisioning Partner* crate version *1.0.11+20190622*, where *20190622* is the exact revision of the *androiddeviceprovisioning:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.11*.
|
||
//!
|
||
//! Everything else about the *Android Provisioning Partner* *v1* API can be found at the
|
||
//! [official documentation site](https://developers.google.com/zero-touch/).
|
||
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/androiddeviceprovisioning1).
|
||
//! # Features
|
||
//!
|
||
//! Handle the following *Resources* with ease from the central [hub](struct.AndroidProvisioningPartner.html) ...
|
||
//!
|
||
//! * customers
|
||
//! * [*configurations create*](struct.CustomerConfigurationCreateCall.html), [*configurations delete*](struct.CustomerConfigurationDeleteCall.html), [*configurations get*](struct.CustomerConfigurationGetCall.html), [*configurations list*](struct.CustomerConfigurationListCall.html), [*configurations patch*](struct.CustomerConfigurationPatchCall.html), [*devices apply configuration*](struct.CustomerDeviceApplyConfigurationCall.html), [*devices get*](struct.CustomerDeviceGetCall.html), [*devices list*](struct.CustomerDeviceListCall.html), [*devices remove configuration*](struct.CustomerDeviceRemoveConfigurationCall.html), [*devices unclaim*](struct.CustomerDeviceUnclaimCall.html), [*dpcs list*](struct.CustomerDpcListCall.html) and [*list*](struct.CustomerListCall.html)
|
||
//! * [operations](struct.Operation.html)
|
||
//! * [*get*](struct.OperationGetCall.html)
|
||
//! * partners
|
||
//! * [*customers create*](struct.PartnerCustomerCreateCall.html), [*customers list*](struct.PartnerCustomerListCall.html), [*devices claim*](struct.PartnerDeviceClaimCall.html), [*devices claim async*](struct.PartnerDeviceClaimAsyncCall.html), [*devices find by identifier*](struct.PartnerDeviceFindByIdentifierCall.html), [*devices find by owner*](struct.PartnerDeviceFindByOwnerCall.html), [*devices get*](struct.PartnerDeviceGetCall.html), [*devices metadata*](struct.PartnerDeviceMetadataCall.html), [*devices unclaim*](struct.PartnerDeviceUnclaimCall.html), [*devices unclaim async*](struct.PartnerDeviceUnclaimAsyncCall.html), [*devices update metadata async*](struct.PartnerDeviceUpdateMetadataAsyncCall.html), [*vendors customers list*](struct.PartnerVendorCustomerListCall.html) and [*vendors list*](struct.PartnerVendorListCall.html)
|
||
//!
|
||
//!
|
||
//!
|
||
//!
|
||
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs).
|
||
//!
|
||
//! # Structure of this Library
|
||
//!
|
||
//! The API is structured into the following primary items:
|
||
//!
|
||
//! * **[Hub](struct.AndroidProvisioningPartner.html)**
|
||
//! * a central object to maintain state and allow accessing all *Activities*
|
||
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
|
||
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
|
||
//! * **[Resources](trait.Resource.html)**
|
||
//! * primary types that you can apply *Activities* to
|
||
//! * a collection of properties and *Parts*
|
||
//! * **[Parts](trait.Part.html)**
|
||
//! * a collection of properties
|
||
//! * never directly used in *Activities*
|
||
//! * **[Activities](trait.CallBuilder.html)**
|
||
//! * operations to apply to *Resources*
|
||
//!
|
||
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
|
||
//!
|
||
//! Generally speaking, you can invoke *Activities* like this:
|
||
//!
|
||
//! ```Rust,ignore
|
||
//! let r = hub.resource().activity(...).doit()
|
||
//! ```
|
||
//!
|
||
//! Or specifically ...
|
||
//!
|
||
//! ```ignore
|
||
//! let r = hub.customers().devices_apply_configuration(...).doit()
|
||
//! let r = hub.customers().devices_unclaim(...).doit()
|
||
//! let r = hub.customers().configurations_delete(...).doit()
|
||
//! let r = hub.customers().devices_remove_configuration(...).doit()
|
||
//! let r = hub.partners().devices_unclaim(...).doit()
|
||
//! ```
|
||
//!
|
||
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
|
||
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
|
||
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
|
||
//! The `doit()` method performs the actual communication with the server and returns the respective result.
|
||
//!
|
||
//! # Usage
|
||
//!
|
||
//! ## Setting up your Project
|
||
//!
|
||
//! To use this library, you would put the following lines into your `Cargo.toml` file:
|
||
//!
|
||
//! ```toml
|
||
//! [dependencies]
|
||
//! google-androiddeviceprovisioning1 = "*"
|
||
//! # This project intentionally uses an old version of Hyper. See
|
||
//! # https://github.com/Byron/google-apis-rs/issues/173 for more
|
||
//! # information.
|
||
//! hyper = "^0.10"
|
||
//! hyper-rustls = "^0.6"
|
||
//! serde = "^1.0"
|
||
//! serde_json = "^1.0"
|
||
//! yup-oauth2 = "^1.0"
|
||
//! ```
|
||
//!
|
||
//! ## A complete example
|
||
//!
|
||
//! ```test_harness,no_run
|
||
//! extern crate hyper;
|
||
//! extern crate hyper_rustls;
|
||
//! extern crate yup_oauth2 as oauth2;
|
||
//! extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
//! use androiddeviceprovisioning1::CustomerApplyConfigurationRequest;
|
||
//! use androiddeviceprovisioning1::{Result, Error};
|
||
//! # #[test] fn egal() {
|
||
//! use std::default::Default;
|
||
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
//! use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
//!
|
||
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
||
//! // `client_secret`, among other things.
|
||
//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
//! hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
//! <MemoryStorage as Default>::default(), None);
|
||
//! let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = CustomerApplyConfigurationRequest::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.customers().devices_apply_configuration(req, "parent")
|
||
//! .doit();
|
||
//!
|
||
//! 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::MissingAPIKey
|
||
//! |Error::MissingToken(_)
|
||
//! |Error::Cancelled
|
||
//! |Error::UploadSizeLimitExceeded(_, _)
|
||
//! |Error::Failure(_)
|
||
//! |Error::BadRequest(_)
|
||
//! |Error::FieldClash(_)
|
||
//! |Error::JsonDecodeError(_, _) => println!("{}", e),
|
||
//! },
|
||
//! Ok(res) => println!("Success: {:?}", res),
|
||
//! }
|
||
//! # }
|
||
//! ```
|
||
//! ## Handling Errors
|
||
//!
|
||
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
||
//! the doit() methods, or handed as possibly intermediate results to either the
|
||
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
|
||
//!
|
||
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
||
//! makes the system potentially resilient to all kinds of errors.
|
||
//!
|
||
//! ## Uploads and Downloads
|
||
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
||
//! read by you to obtain the media.
|
||
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
||
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
||
//! this call: `.param("alt", "media")`.
|
||
//!
|
||
//! Methods supporting uploads can do so using up to 2 different protocols:
|
||
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
||
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
||
//!
|
||
//! ## Customization and Callbacks
|
||
//!
|
||
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
||
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
||
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
||
//! retry on failure.
|
||
//!
|
||
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
||
//!
|
||
//! ## Optional Parts in Server-Requests
|
||
//!
|
||
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
|
||
//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
||
//! are valid.
|
||
//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to
|
||
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
||
//!
|
||
//! ## Builder Arguments
|
||
//!
|
||
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
||
//! These will always take a single argument, for which the following statements are true.
|
||
//!
|
||
//! * [PODs][wiki-pod] are handed by copy
|
||
//! * strings are passed as `&str`
|
||
//! * [request values](trait.RequestValue.html) are moved
|
||
//!
|
||
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
||
//!
|
||
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
||
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
||
//! [google-go-api]: https://github.com/google/google-api-go-client
|
||
//!
|
||
//!
|
||
|
||
// Unused attributes happen thanks to defined, but unused structures
|
||
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
||
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
||
// unused imports in fully featured APIs. Same with unused_mut ... .
|
||
#![allow(unused_imports, unused_mut, dead_code)]
|
||
|
||
// DO NOT EDIT !
|
||
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
||
// DO NOT EDIT !
|
||
|
||
#[macro_use]
|
||
extern crate serde_derive;
|
||
|
||
extern crate hyper;
|
||
extern crate serde;
|
||
extern crate serde_json;
|
||
extern crate yup_oauth2 as oauth2;
|
||
extern crate mime;
|
||
extern crate url;
|
||
|
||
mod cmn;
|
||
|
||
use std::collections::HashMap;
|
||
use std::cell::RefCell;
|
||
use std::borrow::BorrowMut;
|
||
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 std::time::Duration;
|
||
|
||
pub use cmn::*;
|
||
|
||
|
||
// ##############
|
||
// UTILITIES ###
|
||
// ############
|
||
|
||
|
||
|
||
|
||
// ########
|
||
// HUB ###
|
||
// ######
|
||
|
||
/// Central instance to access all AndroidProvisioningPartner related resource activities
|
||
///
|
||
/// # Examples
|
||
///
|
||
/// Instantiate a new hub
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate yup_oauth2 as oauth2;
|
||
/// extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::CustomerApplyConfigurationRequest;
|
||
/// use androiddeviceprovisioning1::{Result, Error};
|
||
/// # #[test] fn egal() {
|
||
/// use std::default::Default;
|
||
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
||
/// // `client_secret`, among other things.
|
||
/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// <MemoryStorage as Default>::default(), None);
|
||
/// let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = CustomerApplyConfigurationRequest::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.customers().devices_apply_configuration(req, "parent")
|
||
/// .doit();
|
||
///
|
||
/// 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::MissingAPIKey
|
||
/// |Error::MissingToken(_)
|
||
/// |Error::Cancelled
|
||
/// |Error::UploadSizeLimitExceeded(_, _)
|
||
/// |Error::Failure(_)
|
||
/// |Error::BadRequest(_)
|
||
/// |Error::FieldClash(_)
|
||
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
|
||
/// },
|
||
/// Ok(res) => println!("Success: {:?}", res),
|
||
/// }
|
||
/// # }
|
||
/// ```
|
||
pub struct AndroidProvisioningPartner<C, A> {
|
||
client: RefCell<C>,
|
||
auth: RefCell<A>,
|
||
_user_agent: String,
|
||
_base_url: String,
|
||
_root_url: String,
|
||
}
|
||
|
||
impl<'a, C, A> Hub for AndroidProvisioningPartner<C, A> {}
|
||
|
||
impl<'a, C, A> AndroidProvisioningPartner<C, A>
|
||
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
pub fn new(client: C, authenticator: A) -> AndroidProvisioningPartner<C, A> {
|
||
AndroidProvisioningPartner {
|
||
client: RefCell::new(client),
|
||
auth: RefCell::new(authenticator),
|
||
_user_agent: "google-api-rust-client/1.0.11".to_string(),
|
||
_base_url: "https://androiddeviceprovisioning.googleapis.com/".to_string(),
|
||
_root_url: "https://androiddeviceprovisioning.googleapis.com/".to_string(),
|
||
}
|
||
}
|
||
|
||
pub fn customers(&'a self) -> CustomerMethods<'a, C, A> {
|
||
CustomerMethods { hub: &self }
|
||
}
|
||
pub fn operations(&'a self) -> OperationMethods<'a, C, A> {
|
||
OperationMethods { hub: &self }
|
||
}
|
||
pub fn partners(&'a self) -> PartnerMethods<'a, C, A> {
|
||
PartnerMethods { hub: &self }
|
||
}
|
||
|
||
/// Set the user-agent header field to use in all requests to the server.
|
||
/// It defaults to `google-api-rust-client/1.0.11`.
|
||
///
|
||
/// 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://androiddeviceprovisioning.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://androiddeviceprovisioning.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 ###
|
||
// ##########
|
||
/// Identifies one unclaim request.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct PartnerUnclaim {
|
||
/// The duration of the vacation unlock starting from when the request is
|
||
/// processed. (1 day is treated as 24 hours)
|
||
#[serde(rename="vacationModeDays")]
|
||
pub vacation_mode_days: Option<i32>,
|
||
/// Device identifier of the device.
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// The expiration time of the vacation unlock.
|
||
#[serde(rename="vacationModeExpireTime")]
|
||
pub vacation_mode_expire_time: Option<String>,
|
||
/// Device ID of the device.
|
||
#[serde(rename="deviceId")]
|
||
pub device_id: Option<String>,
|
||
/// Required. The section type of the device's provisioning record.
|
||
#[serde(rename="sectionType")]
|
||
pub section_type: Option<String>,
|
||
}
|
||
|
||
impl Part for PartnerUnclaim {}
|
||
|
||
|
||
/// Request message for customer to remove the configuration from device.
|
||
///
|
||
/// # 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 remove configuration customers](struct.CustomerDeviceRemoveConfigurationCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CustomerRemoveConfigurationRequest {
|
||
/// Required. The device to remove the configuration from.
|
||
pub device: Option<DeviceReference>,
|
||
}
|
||
|
||
impl RequestValue for CustomerRemoveConfigurationRequest {}
|
||
|
||
|
||
/// Response containing found devices.
|
||
///
|
||
/// # 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 find by identifier partners](struct.PartnerDeviceFindByIdentifierCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct FindDevicesByDeviceIdentifierResponse {
|
||
/// A token used to access the next page of results. Omitted if no further
|
||
/// results are available.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
/// The total count of items in the list irrespective of pagination.
|
||
#[serde(rename="totalSize")]
|
||
pub total_size: Option<i32>,
|
||
/// Found devices.
|
||
pub devices: Option<Vec<Device>>,
|
||
}
|
||
|
||
impl ResponseResult for FindDevicesByDeviceIdentifierResponse {}
|
||
|
||
|
||
/// Request to find devices by customers.
|
||
///
|
||
/// # 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 find by owner partners](struct.PartnerDeviceFindByOwnerCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct FindDevicesByOwnerRequest {
|
||
/// A token specifying which result page to return.
|
||
#[serde(rename="pageToken")]
|
||
pub page_token: Option<String>,
|
||
/// Required. The maximum number of devices to show in a page of results. Must
|
||
/// be between 1 and 100 inclusive.
|
||
pub limit: Option<String>,
|
||
/// Required. The list of customer IDs to search for.
|
||
#[serde(rename="customerId")]
|
||
pub customer_id: Option<Vec<String>>,
|
||
/// Required. The section type of the device's provisioning record.
|
||
#[serde(rename="sectionType")]
|
||
pub section_type: Option<String>,
|
||
}
|
||
|
||
impl RequestValue for FindDevicesByOwnerRequest {}
|
||
|
||
|
||
/// Request to unclaim devices asynchronously in batch.
|
||
///
|
||
/// # 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 unclaim async partners](struct.PartnerDeviceUnclaimAsyncCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct UnclaimDevicesRequest {
|
||
/// Required. The list of devices to unclaim.
|
||
pub unclaims: Option<Vec<PartnerUnclaim>>,
|
||
}
|
||
|
||
impl RequestValue for UnclaimDevicesRequest {}
|
||
|
||
|
||
/// Request message for customer to assign a configuration to device.
|
||
///
|
||
/// # 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 apply configuration customers](struct.CustomerDeviceApplyConfigurationCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CustomerApplyConfigurationRequest {
|
||
/// Required. The device the configuration is applied to.
|
||
pub device: Option<DeviceReference>,
|
||
/// Required. The configuration applied to the device in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`.
|
||
pub configuration: Option<String>,
|
||
}
|
||
|
||
impl RequestValue for CustomerApplyConfigurationRequest {}
|
||
|
||
|
||
/// Request message to create a customer.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [customers create partners](struct.PartnerCustomerCreateCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CreateCustomerRequest {
|
||
/// Required. The company data to populate the new customer. Must contain a
|
||
/// value for `companyName` and at least one `owner_email` that's associated
|
||
/// with a Google Account. The values for `companyId` and `name` must be empty.
|
||
pub customer: Option<Company>,
|
||
}
|
||
|
||
impl RequestValue for CreateCustomerRequest {}
|
||
|
||
|
||
/// Request message to claim a device on behalf of a customer.
|
||
///
|
||
/// # 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 claim partners](struct.PartnerDeviceClaimCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ClaimDeviceRequest {
|
||
/// Optional. The metadata to attach to the device.
|
||
#[serde(rename="deviceMetadata")]
|
||
pub device_metadata: Option<DeviceMetadata>,
|
||
/// Required. The device identifier of the device to claim.
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// Required. The section type of the device's provisioning record.
|
||
#[serde(rename="sectionType")]
|
||
pub section_type: Option<String>,
|
||
/// Required. The ID of the customer for whom the device is being claimed.
|
||
#[serde(rename="customerId")]
|
||
pub customer_id: Option<String>,
|
||
}
|
||
|
||
impl RequestValue for ClaimDeviceRequest {}
|
||
|
||
|
||
/// 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:
|
||
///
|
||
/// ````text
|
||
/// 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 apply configuration customers](struct.CustomerDeviceApplyConfigurationCall.html) (response)
|
||
/// * [devices unclaim customers](struct.CustomerDeviceUnclaimCall.html) (response)
|
||
/// * [configurations delete customers](struct.CustomerConfigurationDeleteCall.html) (response)
|
||
/// * [devices remove configuration customers](struct.CustomerDeviceRemoveConfigurationCall.html) (response)
|
||
/// * [devices unclaim partners](struct.PartnerDeviceUnclaimCall.html) (response)
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Empty { _never_set: Option<bool> }
|
||
|
||
impl ResponseResult for Empty {}
|
||
|
||
|
||
/// Response message to list customers of the vendor.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [vendors customers list partners](struct.PartnerVendorCustomerListCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListVendorCustomersResponse {
|
||
/// A token to retrieve the next page of results. Omitted if no further results
|
||
/// are available.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
/// The total count of items in the list irrespective of pagination.
|
||
#[serde(rename="totalSize")]
|
||
pub total_size: Option<i32>,
|
||
/// List of customers of the vendor.
|
||
pub customers: Option<Vec<Company>>,
|
||
}
|
||
|
||
impl ResponseResult for ListVendorCustomersResponse {}
|
||
|
||
|
||
/// 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 {
|
||
/// 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<String>,
|
||
/// The status code, which should be an enum value of google.rpc.Code.
|
||
pub code: Option<i32>,
|
||
/// A list of messages that carry the error details. There is a common set of
|
||
/// message types for APIs to use.
|
||
pub details: Option<Vec<HashMap<String, String>>>,
|
||
}
|
||
|
||
impl Part for Status {}
|
||
|
||
|
||
/// Response message for listing my customers.
|
||
///
|
||
/// # 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 customers](struct.CustomerListCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CustomerListCustomersResponse {
|
||
/// A token used to access the next page of results. Omitted if no further
|
||
/// results are available.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
/// The customer accounts the calling user is a member of.
|
||
pub customers: Option<Vec<Company>>,
|
||
}
|
||
|
||
impl ResponseResult for CustomerListCustomersResponse {}
|
||
|
||
|
||
/// Request message for customer to unclaim a device.
|
||
///
|
||
/// # 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 unclaim customers](struct.CustomerDeviceUnclaimCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CustomerUnclaimDeviceRequest {
|
||
/// Required. The device to unclaim.
|
||
pub device: Option<DeviceReference>,
|
||
}
|
||
|
||
impl RequestValue for CustomerUnclaimDeviceRequest {}
|
||
|
||
|
||
/// A reseller, vendor, or customer in the zero-touch reseller and customer APIs.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [customers create partners](struct.PartnerCustomerCreateCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Company {
|
||
/// Output only. The API resource name of the company. The resource name is one
|
||
/// of the following formats:
|
||
///
|
||
/// * `partners/[PARTNER_ID]/customers/[CUSTOMER_ID]`
|
||
/// * `partners/[PARTNER_ID]/vendors/[VENDOR_ID]`
|
||
/// * `partners/[PARTNER_ID]/vendors/[VENDOR_ID]/customers/[CUSTOMER_ID]`
|
||
///
|
||
/// Assigned by the server.
|
||
pub name: Option<String>,
|
||
/// Output only. The ID of the company. Assigned by the server.
|
||
#[serde(rename="companyId")]
|
||
pub company_id: Option<String>,
|
||
/// Required. The name of the company. For example _XYZ Corp_. Displayed to the
|
||
/// company's employees in the zero-touch enrollment portal.
|
||
#[serde(rename="companyName")]
|
||
pub company_name: Option<String>,
|
||
/// Output only. Whether any user from the company has accepted the latest
|
||
/// Terms of Service (ToS). See
|
||
/// TermsStatus.
|
||
#[serde(rename="termsStatus")]
|
||
pub terms_status: Option<String>,
|
||
/// Input only. Email address of customer's users in the owner role. At least
|
||
/// one `owner_email` is required. Each email address must be associated with a
|
||
/// Google Account. Owners share the same access as admins but can also add,
|
||
/// delete, and edit your organization's portal users.
|
||
#[serde(rename="ownerEmails")]
|
||
pub owner_emails: Option<Vec<String>>,
|
||
/// Input only. Optional. Email address of customer's users in the admin role.
|
||
/// Each email address must be associated with a Google Account.
|
||
#[serde(rename="adminEmails")]
|
||
pub admin_emails: Option<Vec<String>>,
|
||
}
|
||
|
||
impl ResponseResult for Company {}
|
||
|
||
|
||
/// Response message to list vendors of the partner.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [vendors list partners](struct.PartnerVendorListCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListVendorsResponse {
|
||
/// A token to retrieve the next page of results. Omitted if no further results
|
||
/// are available.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
/// The total count of items in the list irrespective of pagination.
|
||
#[serde(rename="totalSize")]
|
||
pub total_size: Option<i32>,
|
||
/// List of vendors of the reseller partner. Fields `name`, `companyId` and
|
||
/// `companyName` are populated to the Company object.
|
||
pub vendors: Option<Vec<Company>>,
|
||
}
|
||
|
||
impl ResponseResult for ListVendorsResponse {}
|
||
|
||
|
||
/// Request to claim devices asynchronously in batch. Claiming a device adds the
|
||
/// device to zero-touch enrollment and shows the device in the customer's view
|
||
/// of the portal.
|
||
///
|
||
/// # 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 claim async partners](struct.PartnerDeviceClaimAsyncCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ClaimDevicesRequest {
|
||
/// Required. A list of device claims.
|
||
pub claims: Option<Vec<PartnerClaim>>,
|
||
}
|
||
|
||
impl RequestValue for ClaimDevicesRequest {}
|
||
|
||
|
||
/// An Android device registered for zero-touch enrollment.
|
||
///
|
||
/// # 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 partners](struct.PartnerDeviceGetCall.html) (response)
|
||
/// * [devices get customers](struct.CustomerDeviceGetCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Device {
|
||
/// The hardware IDs that identify a manufactured device. To learn more, read
|
||
/// [Identifiers](/zero-touch/guides/identifiers).
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// Output only. The API resource name in the format
|
||
/// `partners/[PARTNER_ID]/devices/[DEVICE_ID]`. Assigned by the server.
|
||
pub name: Option<String>,
|
||
/// Output only. The provisioning claims for a device. Devices claimed for
|
||
/// zero-touch enrollment have a claim with the type `SECTION_TYPE_ZERO_TOUCH`.
|
||
/// Call
|
||
/// `partners.devices.unclaim`
|
||
/// or
|
||
/// `partners.devices.unclaimAsync`
|
||
/// to remove the device from zero-touch enrollment.
|
||
pub claims: Option<Vec<DeviceClaim>>,
|
||
/// The metadata attached to the device. Structured as key-value pairs. To
|
||
/// learn more, read [Device metadata](/zero-touch/guides/metadata).
|
||
#[serde(rename="deviceMetadata")]
|
||
pub device_metadata: Option<DeviceMetadata>,
|
||
/// Not available to resellers.
|
||
pub configuration: Option<String>,
|
||
/// Output only. The ID of the device. Assigned by the server.
|
||
#[serde(rename="deviceId")]
|
||
pub device_id: Option<String>,
|
||
}
|
||
|
||
impl ResponseResult for Device {}
|
||
|
||
|
||
/// A record of a device claimed by a reseller for a customer. Devices claimed
|
||
/// for zero-touch enrollment have a claim with the type
|
||
/// `SECTION_TYPE_ZERO_TOUCH`. To learn more, read
|
||
/// [Claim devices for customers](/zero-touch/guides/how-it-works#claim).
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct DeviceClaim {
|
||
/// The timestamp when the device was put into ‘vacation mode’. This value is
|
||
/// present iff the device is in 'vacation mode'.
|
||
#[serde(rename="vacationModeStartTime")]
|
||
pub vacation_mode_start_time: Option<String>,
|
||
/// The ID of the Customer that purchased the device.
|
||
#[serde(rename="ownerCompanyId")]
|
||
pub owner_company_id: Option<String>,
|
||
/// The timestamp when the device will exit ‘vacation mode’. This value is
|
||
/// present iff the device is in 'vacation mode'.
|
||
#[serde(rename="vacationModeExpireTime")]
|
||
pub vacation_mode_expire_time: Option<String>,
|
||
/// Output only. The type of claim made on the device.
|
||
#[serde(rename="sectionType")]
|
||
pub section_type: Option<String>,
|
||
/// The ID of the reseller that claimed the device.
|
||
#[serde(rename="resellerId")]
|
||
pub reseller_id: Option<String>,
|
||
}
|
||
|
||
impl Part for DeviceClaim {}
|
||
|
||
|
||
/// A configuration collects the provisioning options for Android devices. Each
|
||
/// configuration combines the following:
|
||
///
|
||
/// * The EMM device policy controller (DPC) installed on the devices.
|
||
/// * EMM policies enforced on the devices.
|
||
/// * Metadata displayed on the device to help users during setup.
|
||
///
|
||
/// Customers can add as many configurations as they need. However, zero-touch
|
||
/// enrollment works best when a customer sets a default configuration that's
|
||
/// applied to any new devices the organization purchases.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [configurations get customers](struct.CustomerConfigurationGetCall.html) (response)
|
||
/// * [configurations patch customers](struct.CustomerConfigurationPatchCall.html) (request|response)
|
||
/// * [configurations create customers](struct.CustomerConfigurationCreateCall.html) (request|response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Configuration {
|
||
/// The JSON-formatted EMM provisioning extras that are passed to the DPC.
|
||
#[serde(rename="dpcExtras")]
|
||
pub dpc_extras: Option<String>,
|
||
/// Required. The telephone number that device users can call, using another
|
||
/// device, to get help. Zero-touch enrollment shows this number to device
|
||
/// users before device provisioning. Accepts numerals, spaces, the plus sign,
|
||
/// hyphens, and parentheses.
|
||
#[serde(rename="contactPhone")]
|
||
pub contact_phone: Option<String>,
|
||
/// Output only. The API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`. Assigned by
|
||
/// the server.
|
||
pub name: Option<String>,
|
||
/// Required. The name of the organization. Zero-touch enrollment shows this
|
||
/// organization name to device users during device provisioning.
|
||
#[serde(rename="companyName")]
|
||
pub company_name: Option<String>,
|
||
/// Output only. The ID of the configuration. Assigned by the server.
|
||
#[serde(rename="configurationId")]
|
||
pub configuration_id: Option<String>,
|
||
/// A message, containing one or two sentences, to help device users get help
|
||
/// or give them more details about what’s happening to their device.
|
||
/// Zero-touch enrollment shows this message before the device is provisioned.
|
||
#[serde(rename="customMessage")]
|
||
pub custom_message: Option<String>,
|
||
/// Required. The resource name of the selected DPC (device policy controller)
|
||
/// in the format `customers/[CUSTOMER_ID]/dpcs/*`. To list the supported DPCs,
|
||
/// call
|
||
/// `customers.dpcs.list`.
|
||
#[serde(rename="dpcResourcePath")]
|
||
pub dpc_resource_path: Option<String>,
|
||
/// Required. The email address that device users can contact to get help.
|
||
/// Zero-touch enrollment shows this email address to device users before
|
||
/// device provisioning. The value is validated on input.
|
||
#[serde(rename="contactEmail")]
|
||
pub contact_email: Option<String>,
|
||
/// Required. A short name that describes the configuration's purpose. For
|
||
/// example, _Sales team_ or _Temporary employees_. The zero-touch enrollment
|
||
/// portal displays this name to IT admins.
|
||
#[serde(rename="configurationName")]
|
||
pub configuration_name: Option<String>,
|
||
/// Required. Whether this is the default configuration that zero-touch
|
||
/// enrollment applies to any new devices the organization purchases in the
|
||
/// future. Only one customer configuration can be the default. Setting this
|
||
/// value to `true`, changes the previous default configuration's `isDefault`
|
||
/// value to `false`.
|
||
#[serde(rename="isDefault")]
|
||
pub is_default: Option<bool>,
|
||
}
|
||
|
||
impl RequestValue for Configuration {}
|
||
impl ResponseResult for Configuration {}
|
||
|
||
|
||
/// Request to set metadata for a device.
|
||
///
|
||
/// # 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 metadata partners](struct.PartnerDeviceMetadataCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct UpdateDeviceMetadataRequest {
|
||
/// Required. The metdata to attach to the device.
|
||
#[serde(rename="deviceMetadata")]
|
||
pub device_metadata: Option<DeviceMetadata>,
|
||
}
|
||
|
||
impl RequestValue for UpdateDeviceMetadataRequest {}
|
||
|
||
|
||
/// Response message containing device id of the claim.
|
||
///
|
||
/// # 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 claim partners](struct.PartnerDeviceClaimCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ClaimDeviceResponse {
|
||
/// The resource name of the device in the format
|
||
/// `partners/[PARTNER_ID]/devices/[DEVICE_ID]`.
|
||
#[serde(rename="deviceName")]
|
||
pub device_name: Option<String>,
|
||
/// The device ID of the claimed device.
|
||
#[serde(rename="deviceId")]
|
||
pub device_id: Option<String>,
|
||
}
|
||
|
||
impl ResponseResult for ClaimDeviceResponse {}
|
||
|
||
|
||
/// Encapsulates hardware and product IDs to identify a manufactured device.
|
||
/// To understand requirements on identifier sets, read
|
||
/// [Identifiers](/zero-touch/guides/identifiers).
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct DeviceIdentifier {
|
||
/// The device’s IMEI number. Validated on input.
|
||
pub imei: Option<String>,
|
||
/// The device model's name. Matches the device's built-in value returned from
|
||
/// `android.os.Build.MODEL`. Allowed values are listed in
|
||
/// [models](/zero-touch/resources/manufacturer-names#model-names).
|
||
pub model: Option<String>,
|
||
/// The manufacturer's serial number for the device. This value might not be
|
||
/// unique across different device models.
|
||
#[serde(rename="serialNumber")]
|
||
pub serial_number: Option<String>,
|
||
/// The device’s MEID number.
|
||
pub meid: Option<String>,
|
||
/// The device manufacturer’s name. Matches the device's built-in
|
||
/// value returned from `android.os.Build.MANUFACTURER`. Allowed values are
|
||
/// listed in
|
||
/// [manufacturers](/zero-touch/resources/manufacturer-names#manufacturers-names).
|
||
pub manufacturer: Option<String>,
|
||
}
|
||
|
||
impl Part for DeviceIdentifier {}
|
||
|
||
|
||
/// Response containing found devices.
|
||
///
|
||
/// # 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 find by owner partners](struct.PartnerDeviceFindByOwnerCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct FindDevicesByOwnerResponse {
|
||
/// A token used to access the next page of results.
|
||
/// Omitted if no further results are available.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
/// The total count of items in the list irrespective of pagination.
|
||
#[serde(rename="totalSize")]
|
||
pub total_size: Option<i32>,
|
||
/// The customer's devices.
|
||
pub devices: Option<Vec<Device>>,
|
||
}
|
||
|
||
impl ResponseResult for FindDevicesByOwnerResponse {}
|
||
|
||
|
||
/// Request message to unclaim a device.
|
||
///
|
||
/// # 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 unclaim partners](struct.PartnerDeviceUnclaimCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct UnclaimDeviceRequest {
|
||
/// The duration of the vacation unlock starting from when the request is
|
||
/// processed. (1 day is treated as 24 hours)
|
||
#[serde(rename="vacationModeDays")]
|
||
pub vacation_mode_days: Option<i32>,
|
||
/// The device identifier you used when you claimed this device.
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// The expiration time of the vacation unlock.
|
||
#[serde(rename="vacationModeExpireTime")]
|
||
pub vacation_mode_expire_time: Option<String>,
|
||
/// The device ID returned by `ClaimDevice`.
|
||
#[serde(rename="deviceId")]
|
||
pub device_id: Option<String>,
|
||
/// Required. The section type of the device's provisioning record.
|
||
#[serde(rename="sectionType")]
|
||
pub section_type: Option<String>,
|
||
}
|
||
|
||
impl RequestValue for UnclaimDeviceRequest {}
|
||
|
||
|
||
/// Response message of all customers related to this partner.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [customers list partners](struct.PartnerCustomerListCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListCustomersResponse {
|
||
/// A token to retrieve the next page of results. Omitted if no further results
|
||
/// are available.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
/// The total count of items in the list irrespective of pagination.
|
||
#[serde(rename="totalSize")]
|
||
pub total_size: Option<i32>,
|
||
/// List of customers related to this reseller partner.
|
||
pub customers: Option<Vec<Company>>,
|
||
}
|
||
|
||
impl ResponseResult for ListCustomersResponse {}
|
||
|
||
|
||
/// An EMM's DPC ([device policy
|
||
/// controller](http://developer.android.com/work/dpc/build-dpc.html)).
|
||
/// Zero-touch enrollment installs a DPC (listed in the `Configuration`) on a
|
||
/// device to maintain the customer's mobile policies. All the DPCs listed by the
|
||
/// API support zero-touch enrollment and are available in Google Play.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Dpc {
|
||
/// Output only. The DPC's Android application ID that looks like a Java
|
||
/// package name. Zero-touch enrollment installs the DPC app onto a device
|
||
/// using this identifier.
|
||
#[serde(rename="packageName")]
|
||
pub package_name: Option<String>,
|
||
/// Output only. The title of the DPC app in Google Play. For example, _Google
|
||
/// Apps Device Policy_. Useful in an application's user interface.
|
||
#[serde(rename="dpcName")]
|
||
pub dpc_name: Option<String>,
|
||
/// Output only. The API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/dpcs/[DPC_ID]`. Assigned by
|
||
/// the server. To maintain a reference to a DPC across customer accounts,
|
||
/// persist and match the last path component (`DPC_ID`).
|
||
pub name: Option<String>,
|
||
}
|
||
|
||
impl Part for Dpc {}
|
||
|
||
|
||
/// Request to update device metadata in batch.
|
||
///
|
||
/// # 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 update metadata async partners](struct.PartnerDeviceUpdateMetadataAsyncCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct UpdateDeviceMetadataInBatchRequest {
|
||
/// Required. The list of metadata updates.
|
||
pub updates: Option<Vec<UpdateMetadataArguments>>,
|
||
}
|
||
|
||
impl RequestValue for UpdateDeviceMetadataInBatchRequest {}
|
||
|
||
|
||
/// Identifies metdata updates to one 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 UpdateMetadataArguments {
|
||
/// Required. The metadata to update.
|
||
#[serde(rename="deviceMetadata")]
|
||
pub device_metadata: Option<DeviceMetadata>,
|
||
/// Device identifier.
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// Device ID of the device.
|
||
#[serde(rename="deviceId")]
|
||
pub device_id: Option<String>,
|
||
}
|
||
|
||
impl Part for UpdateMetadataArguments {}
|
||
|
||
|
||
/// A `DeviceReference` is an API abstraction that lets you supply a _device_
|
||
/// argument to a method using one of the following identifier types:
|
||
///
|
||
/// * A numeric API resource ID.
|
||
/// * Real-world hardware IDs, such as IMEI number, belonging to the manufactured
|
||
/// device.
|
||
///
|
||
/// Methods that operate on devices take a `DeviceReference` as a parameter type
|
||
/// because it's more flexible for the caller. To learn more about device
|
||
/// identifiers, read [Identifiers](/zero-touch/guides/identifiers).
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct DeviceReference {
|
||
/// The hardware IDs of the device.
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// The ID of the device.
|
||
#[serde(rename="deviceId")]
|
||
pub device_id: Option<String>,
|
||
}
|
||
|
||
impl Part for DeviceReference {}
|
||
|
||
|
||
/// 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 update metadata async partners](struct.PartnerDeviceUpdateMetadataAsyncCall.html) (response)
|
||
/// * [devices unclaim async partners](struct.PartnerDeviceUnclaimAsyncCall.html) (response)
|
||
/// * [get operations](struct.OperationGetCall.html) (response)
|
||
/// * [devices claim async partners](struct.PartnerDeviceClaimAsyncCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Operation {
|
||
/// This field will always be not set if the operation is created by `claimAsync`, `unclaimAsync`, or `updateMetadataAsync`. In this case, error information for each device is set in `response.perDeviceStatus.result.status`.
|
||
pub error: Option<Status>,
|
||
/// 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<bool>,
|
||
/// This field will contain a `DevicesLongRunningOperationResponse` object if the operation is created by `claimAsync`, `unclaimAsync`, or `updateMetadataAsync`.
|
||
pub response: Option<HashMap<String, String>>,
|
||
/// 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<String>,
|
||
/// This field will contain a `DevicesLongRunningOperationMetadata` object if the operation is created by `claimAsync`, `unclaimAsync`, or `updateMetadataAsync`.
|
||
pub metadata: Option<HashMap<String, String>>,
|
||
}
|
||
|
||
impl Resource for Operation {}
|
||
impl ResponseResult for Operation {}
|
||
|
||
|
||
/// Metadata entries that can be attached to a `Device`. To learn more, read
|
||
/// [Device metadata](/zero-touch/guides/metadata).
|
||
///
|
||
/// # 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 metadata partners](struct.PartnerDeviceMetadataCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct DeviceMetadata {
|
||
/// Metadata entries recorded as key-value pairs.
|
||
pub entries: Option<HashMap<String, String>>,
|
||
}
|
||
|
||
impl ResponseResult for DeviceMetadata {}
|
||
|
||
|
||
/// Response message of customer's listing DPCs.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [dpcs list customers](struct.CustomerDpcListCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CustomerListDpcsResponse {
|
||
/// The list of DPCs available to the customer that support zero-touch
|
||
/// enrollment.
|
||
pub dpcs: Option<Vec<Dpc>>,
|
||
}
|
||
|
||
impl ResponseResult for CustomerListDpcsResponse {}
|
||
|
||
|
||
/// Response message of customer's listing configuration.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [configurations list customers](struct.CustomerConfigurationListCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CustomerListConfigurationsResponse {
|
||
/// The configurations.
|
||
pub configurations: Option<Vec<Configuration>>,
|
||
}
|
||
|
||
impl ResponseResult for CustomerListConfigurationsResponse {}
|
||
|
||
|
||
/// Response message of customer's liting devices.
|
||
///
|
||
/// # 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 customers](struct.CustomerDeviceListCall.html) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CustomerListDevicesResponse {
|
||
/// A token used to access the next page of results. Omitted if no further
|
||
/// results are available.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
/// The customer's devices.
|
||
pub devices: Option<Vec<Device>>,
|
||
}
|
||
|
||
impl ResponseResult for CustomerListDevicesResponse {}
|
||
|
||
|
||
/// Request to find devices.
|
||
///
|
||
/// # 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 find by identifier partners](struct.PartnerDeviceFindByIdentifierCall.html) (request)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct FindDevicesByDeviceIdentifierRequest {
|
||
/// A token specifying which result page to return.
|
||
#[serde(rename="pageToken")]
|
||
pub page_token: Option<String>,
|
||
/// Required. The device identifier to search for.
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// Required. The maximum number of devices to show in a page of results. Must
|
||
/// be between 1 and 100 inclusive.
|
||
pub limit: Option<String>,
|
||
}
|
||
|
||
impl RequestValue for FindDevicesByDeviceIdentifierRequest {}
|
||
|
||
|
||
/// Identifies one claim request.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct PartnerClaim {
|
||
/// Required. The metadata to attach to the device at claim.
|
||
#[serde(rename="deviceMetadata")]
|
||
pub device_metadata: Option<DeviceMetadata>,
|
||
/// Required. Device identifier of the device.
|
||
#[serde(rename="deviceIdentifier")]
|
||
pub device_identifier: Option<DeviceIdentifier>,
|
||
/// Required. The section type of the device's provisioning record.
|
||
#[serde(rename="sectionType")]
|
||
pub section_type: Option<String>,
|
||
/// Required. The ID of the customer for whom the device is being claimed.
|
||
#[serde(rename="customerId")]
|
||
pub customer_id: Option<String>,
|
||
}
|
||
|
||
impl Part for PartnerClaim {}
|
||
|
||
|
||
|
||
// ###################
|
||
// MethodBuilders ###
|
||
// #################
|
||
|
||
/// A builder providing access to all methods supported on *operation* resources.
|
||
/// It is not used directly, but through the `AndroidProvisioningPartner` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate yup_oauth2 as oauth2;
|
||
/// extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
///
|
||
/// # #[test] fn egal() {
|
||
/// use std::default::Default;
|
||
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// let secret: ApplicationSecret = Default::default();
|
||
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// <MemoryStorage as Default>::default(), None);
|
||
/// let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `get(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.operations();
|
||
/// # }
|
||
/// ```
|
||
pub struct OperationMethods<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
}
|
||
|
||
impl<'a, C, A> MethodsBuilder for OperationMethods<'a, C, A> {}
|
||
|
||
impl<'a, C, A> OperationMethods<'a, C, A> {
|
||
|
||
/// 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 get(&self, name: &str) -> OperationGetCall<'a, C, A> {
|
||
OperationGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// A builder providing access to all methods supported on *partner* resources.
|
||
/// It is not used directly, but through the `AndroidProvisioningPartner` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate yup_oauth2 as oauth2;
|
||
/// extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
///
|
||
/// # #[test] fn egal() {
|
||
/// use std::default::Default;
|
||
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// let secret: ApplicationSecret = Default::default();
|
||
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// <MemoryStorage as Default>::default(), None);
|
||
/// let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `customers_create(...)`, `customers_list(...)`, `devices_claim(...)`, `devices_claim_async(...)`, `devices_find_by_identifier(...)`, `devices_find_by_owner(...)`, `devices_get(...)`, `devices_metadata(...)`, `devices_unclaim(...)`, `devices_unclaim_async(...)`, `devices_update_metadata_async(...)`, `vendors_customers_list(...)` and `vendors_list(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.partners();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerMethods<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
}
|
||
|
||
impl<'a, C, A> MethodsBuilder for PartnerMethods<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerMethods<'a, C, A> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates the reseller metadata attached to a batch of devices. This method
|
||
/// updates devices asynchronously and returns an `Operation` that can be used
|
||
/// to track progress. Read [Long‑running batch
|
||
/// operations](/zero-touch/guides/how-it-works#operations).
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `partnerId` - Required. The reseller partner ID.
|
||
pub fn devices_update_metadata_async(&self, request: UpdateDeviceMetadataInBatchRequest, partner_id: &str) -> PartnerDeviceUpdateMetadataAsyncCall<'a, C, A> {
|
||
PartnerDeviceUpdateMetadataAsyncCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_partner_id: partner_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets a device.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The device API resource name in the format
|
||
/// `partners/[PARTNER_ID]/devices/[DEVICE_ID]`.
|
||
pub fn devices_get(&self, name: &str) -> PartnerDeviceGetCall<'a, C, A> {
|
||
PartnerDeviceGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Finds devices claimed for customers. The results only contain devices
|
||
/// registered to the reseller that's identified by the `partnerId` argument.
|
||
/// The customer's devices purchased from other resellers don't appear in the
|
||
/// results.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `partnerId` - Required. The ID of the reseller partner.
|
||
pub fn devices_find_by_owner(&self, request: FindDevicesByOwnerRequest, partner_id: &str) -> PartnerDeviceFindByOwnerCall<'a, C, A> {
|
||
PartnerDeviceFindByOwnerCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_partner_id: partner_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists the customers that are enrolled to the reseller identified by the
|
||
/// `partnerId` argument. This list includes customers that the reseller
|
||
/// created and customers that enrolled themselves using the portal.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `partnerId` - Required. The ID of the reseller partner.
|
||
pub fn customers_list(&self, partner_id: &str) -> PartnerCustomerListCall<'a, C, A> {
|
||
PartnerCustomerListCall {
|
||
hub: self.hub,
|
||
_partner_id: partner_id.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Finds devices by hardware identifiers, such as IMEI.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `partnerId` - Required. The ID of the reseller partner.
|
||
pub fn devices_find_by_identifier(&self, request: FindDevicesByDeviceIdentifierRequest, partner_id: &str) -> PartnerDeviceFindByIdentifierCall<'a, C, A> {
|
||
PartnerDeviceFindByIdentifierCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_partner_id: partner_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists the customers of the vendor.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The resource name in the format
|
||
/// `partners/[PARTNER_ID]/vendors/[VENDOR_ID]`.
|
||
pub fn vendors_customers_list(&self, parent: &str) -> PartnerVendorCustomerListCall<'a, C, A> {
|
||
PartnerVendorCustomerListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists the vendors of the partner.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The resource name in the format `partners/[PARTNER_ID]`.
|
||
pub fn vendors_list(&self, parent: &str) -> PartnerVendorListCall<'a, C, A> {
|
||
PartnerVendorListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Claims a batch of devices for a customer asynchronously. Adds the devices
|
||
/// to zero-touch enrollment. To learn more, read [Long‑running batch
|
||
/// operations](/zero-touch/guides/how-it-works#operations).
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `partnerId` - Required. The ID of the reseller partner.
|
||
pub fn devices_claim_async(&self, request: ClaimDevicesRequest, partner_id: &str) -> PartnerDeviceClaimAsyncCall<'a, C, A> {
|
||
PartnerDeviceClaimAsyncCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_partner_id: partner_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Claims a device for a customer and adds it to zero-touch enrollment. If the
|
||
/// device is already claimed by another customer, the call returns an error.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `partnerId` - Required. The ID of the reseller partner.
|
||
pub fn devices_claim(&self, request: ClaimDeviceRequest, partner_id: &str) -> PartnerDeviceClaimCall<'a, C, A> {
|
||
PartnerDeviceClaimCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_partner_id: partner_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Unclaims a batch of devices for a customer asynchronously. Removes the
|
||
/// devices from zero-touch enrollment. To learn more, read [Long‑running batch
|
||
/// operations](/zero-touch/guides/how-it-works#operations).
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `partnerId` - Required. The reseller partner ID.
|
||
pub fn devices_unclaim_async(&self, request: UnclaimDevicesRequest, partner_id: &str) -> PartnerDeviceUnclaimAsyncCall<'a, C, A> {
|
||
PartnerDeviceUnclaimAsyncCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_partner_id: partner_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates reseller metadata associated with the device.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `metadataOwnerId` - Required. The owner of the newly set metadata. Set this to the partner ID.
|
||
/// * `deviceId` - Required. The ID of the device.
|
||
pub fn devices_metadata(&self, request: UpdateDeviceMetadataRequest, metadata_owner_id: &str, device_id: &str) -> PartnerDeviceMetadataCall<'a, C, A> {
|
||
PartnerDeviceMetadataCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_metadata_owner_id: metadata_owner_id.to_string(),
|
||
_device_id: device_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Creates a customer for zero-touch enrollment. After the method returns
|
||
/// successfully, admin and owner roles can manage devices and EMM configs
|
||
/// by calling API methods or using their zero-touch enrollment portal.
|
||
/// The customer receives an email that welcomes them to zero-touch enrollment
|
||
/// and explains how to sign into the portal.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The parent resource ID in the format `partners/[PARTNER_ID]` that
|
||
/// identifies the reseller.
|
||
pub fn customers_create(&self, request: CreateCustomerRequest, parent: &str) -> PartnerCustomerCreateCall<'a, C, A> {
|
||
PartnerCustomerCreateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Unclaims a device from a customer and removes it from zero-touch
|
||
/// enrollment.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `partnerId` - Required. The ID of the reseller partner.
|
||
pub fn devices_unclaim(&self, request: UnclaimDeviceRequest, partner_id: &str) -> PartnerDeviceUnclaimCall<'a, C, A> {
|
||
PartnerDeviceUnclaimCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_partner_id: partner_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// A builder providing access to all methods supported on *customer* resources.
|
||
/// It is not used directly, but through the `AndroidProvisioningPartner` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate yup_oauth2 as oauth2;
|
||
/// extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
///
|
||
/// # #[test] fn egal() {
|
||
/// use std::default::Default;
|
||
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// let secret: ApplicationSecret = Default::default();
|
||
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// <MemoryStorage as Default>::default(), None);
|
||
/// let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `configurations_create(...)`, `configurations_delete(...)`, `configurations_get(...)`, `configurations_list(...)`, `configurations_patch(...)`, `devices_apply_configuration(...)`, `devices_get(...)`, `devices_list(...)`, `devices_remove_configuration(...)`, `devices_unclaim(...)`, `dpcs_list(...)` and `list(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.customers();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerMethods<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
}
|
||
|
||
impl<'a, C, A> MethodsBuilder for CustomerMethods<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerMethods<'a, C, A> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Removes a configuration from device.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The customer managing the device in the format
|
||
/// `customers/[CUSTOMER_ID]`.
|
||
pub fn devices_remove_configuration(&self, request: CustomerRemoveConfigurationRequest, parent: &str) -> CustomerDeviceRemoveConfigurationCall<'a, C, A> {
|
||
CustomerDeviceRemoveConfigurationCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates a configuration's field values.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - Output only. The API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`. Assigned by
|
||
/// the server.
|
||
pub fn configurations_patch(&self, request: Configuration, name: &str) -> CustomerConfigurationPatchCall<'a, C, A> {
|
||
CustomerConfigurationPatchCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_update_mask: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets the details of a device.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The device to get. An API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/devices/[DEVICE_ID]`.
|
||
pub fn devices_get(&self, name: &str) -> CustomerDeviceGetCall<'a, C, A> {
|
||
CustomerDeviceGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Applies a Configuration to the device to register the device for zero-touch
|
||
/// enrollment. After applying a configuration to a device, the device
|
||
/// automatically provisions itself on first boot, or next factory reset.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The customer managing the device. An API resource name in the
|
||
/// format `customers/[CUSTOMER_ID]`.
|
||
pub fn devices_apply_configuration(&self, request: CustomerApplyConfigurationRequest, parent: &str) -> CustomerDeviceApplyConfigurationCall<'a, C, A> {
|
||
CustomerDeviceApplyConfigurationCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets the details of a configuration.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The configuration to get. An API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`.
|
||
pub fn configurations_get(&self, name: &str) -> CustomerConfigurationGetCall<'a, C, A> {
|
||
CustomerConfigurationGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes an unused configuration. The API call fails if the customer has
|
||
/// devices with the configuration applied.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The configuration to delete. An API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`. If the
|
||
/// configuration is applied to any devices, the API call fails.
|
||
pub fn configurations_delete(&self, name: &str) -> CustomerConfigurationDeleteCall<'a, C, A> {
|
||
CustomerConfigurationDeleteCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists a customer's devices.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The customer managing the devices. An API resource name in the
|
||
/// format `customers/[CUSTOMER_ID]`.
|
||
pub fn devices_list(&self, parent: &str) -> CustomerDeviceListCall<'a, C, A> {
|
||
CustomerDeviceListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists the user's customer accounts.
|
||
pub fn list(&self) -> CustomerListCall<'a, C, A> {
|
||
CustomerListCall {
|
||
hub: self.hub,
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Unclaims a device from a customer and removes it from zero-touch
|
||
/// enrollment.
|
||
///
|
||
/// After removing a device, a customer must contact their reseller to register
|
||
/// the device into zero-touch enrollment again.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The customer managing the device. An API resource name in the
|
||
/// format `customers/[CUSTOMER_ID]`.
|
||
pub fn devices_unclaim(&self, request: CustomerUnclaimDeviceRequest, parent: &str) -> CustomerDeviceUnclaimCall<'a, C, A> {
|
||
CustomerDeviceUnclaimCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists the DPCs (device policy controllers) that support zero-touch
|
||
/// enrollment.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The customer that can use the DPCs in configurations. An API
|
||
/// resource name in the format `customers/[CUSTOMER_ID]`.
|
||
pub fn dpcs_list(&self, parent: &str) -> CustomerDpcListCall<'a, C, A> {
|
||
CustomerDpcListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists a customer's configurations.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The customer that manages the listed configurations. An API
|
||
/// resource name in the format `customers/[CUSTOMER_ID]`.
|
||
pub fn configurations_list(&self, parent: &str) -> CustomerConfigurationListCall<'a, C, A> {
|
||
CustomerConfigurationListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Creates a new configuration. Once created, a customer can apply the
|
||
/// configuration to devices.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The customer that manages the configuration. An API resource name
|
||
/// in the format `customers/[CUSTOMER_ID]`.
|
||
pub fn configurations_create(&self, request: Configuration, parent: &str) -> CustomerConfigurationCreateCall<'a, C, A> {
|
||
CustomerConfigurationCreateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// ###################
|
||
// CallBuilders ###
|
||
// #################
|
||
|
||
/// 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 *get* method supported by a *operation* resource.
|
||
/// It is not used directly, but through a `OperationMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.operations().get("name")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct OperationGetCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for OperationGetCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.operations.get",
|
||
http_method: hyper::method::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(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}";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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) -> OperationGetCall<'a, C, 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 Delegate) -> OperationGetCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Updates the reseller metadata attached to a batch of devices. This method
|
||
/// updates devices asynchronously and returns an `Operation` that can be used
|
||
/// to track progress. Read [Long‑running batch
|
||
/// operations](/zero-touch/guides/how-it-works#operations).
|
||
///
|
||
/// A builder for the *devices.updateMetadataAsync* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::UpdateDeviceMetadataInBatchRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = UpdateDeviceMetadataInBatchRequest::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.partners().devices_update_metadata_async(req, "partnerId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceUpdateMetadataAsyncCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: UpdateDeviceMetadataInBatchRequest,
|
||
_partner_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceUpdateMetadataAsyncCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceUpdateMetadataAsyncCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.updateMetadataAsync",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.to_string()));
|
||
for &field in ["alt", "partnerId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/devices:updateMetadataAsync";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: UpdateDeviceMetadataInBatchRequest) -> PartnerDeviceUpdateMetadataAsyncCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The reseller partner ID.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerDeviceUpdateMetadataAsyncCall<'a, C, A> {
|
||
self._partner_id = 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 Delegate) -> PartnerDeviceUpdateMetadataAsyncCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceUpdateMetadataAsyncCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Gets a device.
|
||
///
|
||
/// A builder for the *devices.get* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.partners().devices_get("name")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceGetCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceGetCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Device)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.get",
|
||
http_method: hyper::method::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(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}";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The device API resource name in the format
|
||
/// `partners/[PARTNER_ID]/devices/[DEVICE_ID]`.
|
||
///
|
||
/// 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) -> PartnerDeviceGetCall<'a, C, 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 Delegate) -> PartnerDeviceGetCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceGetCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Finds devices claimed for customers. The results only contain devices
|
||
/// registered to the reseller that's identified by the `partnerId` argument.
|
||
/// The customer's devices purchased from other resellers don't appear in the
|
||
/// results.
|
||
///
|
||
/// A builder for the *devices.findByOwner* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::FindDevicesByOwnerRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = FindDevicesByOwnerRequest::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.partners().devices_find_by_owner(req, "partnerId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceFindByOwnerCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: FindDevicesByOwnerRequest,
|
||
_partner_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceFindByOwnerCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceFindByOwnerCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, FindDevicesByOwnerResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.findByOwner",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.to_string()));
|
||
for &field in ["alt", "partnerId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/devices:findByOwner";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: FindDevicesByOwnerRequest) -> PartnerDeviceFindByOwnerCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The ID of the reseller partner.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerDeviceFindByOwnerCall<'a, C, A> {
|
||
self._partner_id = 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 Delegate) -> PartnerDeviceFindByOwnerCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceFindByOwnerCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Lists the customers that are enrolled to the reseller identified by the
|
||
/// `partnerId` argument. This list includes customers that the reseller
|
||
/// created and customers that enrolled themselves using the portal.
|
||
///
|
||
/// A builder for the *customers.list* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.partners().customers_list("partnerId")
|
||
/// .page_token("takimata")
|
||
/// .page_size(-70)
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerCustomerListCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_partner_id: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerCustomerListCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerCustomerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, ListCustomersResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.customers.list",
|
||
http_method: hyper::method::Method::Get });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.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", "partnerId", "pageToken", "pageSize"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/customers";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The ID of the reseller partner.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerCustomerListCall<'a, C, A> {
|
||
self._partner_id = 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) -> PartnerCustomerListCall<'a, C, A> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of results to be returned. If not specified or 0, all
|
||
/// the records are returned.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> PartnerCustomerListCall<'a, C, 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 Delegate) -> PartnerCustomerListCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerCustomerListCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Finds devices by hardware identifiers, such as IMEI.
|
||
///
|
||
/// A builder for the *devices.findByIdentifier* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::FindDevicesByDeviceIdentifierRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = FindDevicesByDeviceIdentifierRequest::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.partners().devices_find_by_identifier(req, "partnerId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceFindByIdentifierCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: FindDevicesByDeviceIdentifierRequest,
|
||
_partner_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceFindByIdentifierCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceFindByIdentifierCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, FindDevicesByDeviceIdentifierResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.findByIdentifier",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.to_string()));
|
||
for &field in ["alt", "partnerId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/devices:findByIdentifier";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: FindDevicesByDeviceIdentifierRequest) -> PartnerDeviceFindByIdentifierCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The ID of the reseller partner.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerDeviceFindByIdentifierCall<'a, C, A> {
|
||
self._partner_id = 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 Delegate) -> PartnerDeviceFindByIdentifierCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceFindByIdentifierCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Lists the customers of the vendor.
|
||
///
|
||
/// A builder for the *vendors.customers.list* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.partners().vendors_customers_list("parent")
|
||
/// .page_token("labore")
|
||
/// .page_size(-9)
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerVendorCustomerListCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_parent: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerVendorCustomerListCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerVendorCustomerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, ListVendorCustomersResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.vendors.customers.list",
|
||
http_method: hyper::method::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(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}/customers";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The resource name in the format
|
||
/// `partners/[PARTNER_ID]/vendors/[VENDOR_ID]`.
|
||
///
|
||
/// 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) -> PartnerVendorCustomerListCall<'a, C, 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) -> PartnerVendorCustomerListCall<'a, C, A> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of results to be returned.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> PartnerVendorCustomerListCall<'a, C, 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 Delegate) -> PartnerVendorCustomerListCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerVendorCustomerListCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Lists the vendors of the partner.
|
||
///
|
||
/// A builder for the *vendors.list* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.partners().vendors_list("parent")
|
||
/// .page_token("dolores")
|
||
/// .page_size(-61)
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerVendorListCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_parent: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerVendorListCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerVendorListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, ListVendorsResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.vendors.list",
|
||
http_method: hyper::method::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(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}/vendors";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The resource name in the format `partners/[PARTNER_ID]`.
|
||
///
|
||
/// 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) -> PartnerVendorListCall<'a, C, 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) -> PartnerVendorListCall<'a, C, A> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of results to be returned.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> PartnerVendorListCall<'a, C, 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 Delegate) -> PartnerVendorListCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerVendorListCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Claims a batch of devices for a customer asynchronously. Adds the devices
|
||
/// to zero-touch enrollment. To learn more, read [Long‑running batch
|
||
/// operations](/zero-touch/guides/how-it-works#operations).
|
||
///
|
||
/// A builder for the *devices.claimAsync* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::ClaimDevicesRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = ClaimDevicesRequest::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.partners().devices_claim_async(req, "partnerId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceClaimAsyncCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: ClaimDevicesRequest,
|
||
_partner_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceClaimAsyncCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceClaimAsyncCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.claimAsync",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.to_string()));
|
||
for &field in ["alt", "partnerId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/devices:claimAsync";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: ClaimDevicesRequest) -> PartnerDeviceClaimAsyncCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The ID of the reseller partner.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerDeviceClaimAsyncCall<'a, C, A> {
|
||
self._partner_id = 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 Delegate) -> PartnerDeviceClaimAsyncCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceClaimAsyncCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Claims a device for a customer and adds it to zero-touch enrollment. If the
|
||
/// device is already claimed by another customer, the call returns an error.
|
||
///
|
||
/// A builder for the *devices.claim* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::ClaimDeviceRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = ClaimDeviceRequest::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.partners().devices_claim(req, "partnerId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceClaimCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: ClaimDeviceRequest,
|
||
_partner_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceClaimCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceClaimCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, ClaimDeviceResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.claim",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.to_string()));
|
||
for &field in ["alt", "partnerId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/devices:claim";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: ClaimDeviceRequest) -> PartnerDeviceClaimCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The ID of the reseller partner.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerDeviceClaimCall<'a, C, A> {
|
||
self._partner_id = 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 Delegate) -> PartnerDeviceClaimCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceClaimCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Unclaims a batch of devices for a customer asynchronously. Removes the
|
||
/// devices from zero-touch enrollment. To learn more, read [Long‑running batch
|
||
/// operations](/zero-touch/guides/how-it-works#operations).
|
||
///
|
||
/// A builder for the *devices.unclaimAsync* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::UnclaimDevicesRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = UnclaimDevicesRequest::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.partners().devices_unclaim_async(req, "partnerId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceUnclaimAsyncCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: UnclaimDevicesRequest,
|
||
_partner_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceUnclaimAsyncCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceUnclaimAsyncCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.unclaimAsync",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.to_string()));
|
||
for &field in ["alt", "partnerId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/devices:unclaimAsync";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: UnclaimDevicesRequest) -> PartnerDeviceUnclaimAsyncCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The reseller partner ID.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerDeviceUnclaimAsyncCall<'a, C, A> {
|
||
self._partner_id = 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 Delegate) -> PartnerDeviceUnclaimAsyncCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceUnclaimAsyncCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Updates reseller metadata associated with the device.
|
||
///
|
||
/// A builder for the *devices.metadata* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::UpdateDeviceMetadataRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = UpdateDeviceMetadataRequest::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.partners().devices_metadata(req, "metadataOwnerId", "deviceId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceMetadataCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: UpdateDeviceMetadataRequest,
|
||
_metadata_owner_id: String,
|
||
_device_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceMetadataCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceMetadataCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, DeviceMetadata)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.metadata",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
|
||
params.push(("metadataOwnerId", self._metadata_owner_id.to_string()));
|
||
params.push(("deviceId", self._device_id.to_string()));
|
||
for &field in ["alt", "metadataOwnerId", "deviceId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+metadataOwnerId}/devices/{+deviceId}/metadata";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+metadataOwnerId}", "metadataOwnerId"), ("{+deviceId}", "deviceId")].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<usize> = Vec::with_capacity(2);
|
||
for param_name in ["deviceId", "metadataOwnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: UpdateDeviceMetadataRequest) -> PartnerDeviceMetadataCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The owner of the newly set metadata. Set this to the partner ID.
|
||
///
|
||
/// Sets the *metadata owner id* 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 metadata_owner_id(mut self, new_value: &str) -> PartnerDeviceMetadataCall<'a, C, A> {
|
||
self._metadata_owner_id = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. The ID of the device.
|
||
///
|
||
/// Sets the *device id* 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 device_id(mut self, new_value: &str) -> PartnerDeviceMetadataCall<'a, C, A> {
|
||
self._device_id = 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 Delegate) -> PartnerDeviceMetadataCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceMetadataCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Creates a customer for zero-touch enrollment. After the method returns
|
||
/// successfully, admin and owner roles can manage devices and EMM configs
|
||
/// by calling API methods or using their zero-touch enrollment portal.
|
||
/// The customer receives an email that welcomes them to zero-touch enrollment
|
||
/// and explains how to sign into the portal.
|
||
///
|
||
/// A builder for the *customers.create* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::CreateCustomerRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = CreateCustomerRequest::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.partners().customers_create(req, "parent")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerCustomerCreateCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: CreateCustomerRequest,
|
||
_parent: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerCustomerCreateCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerCustomerCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Company)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.customers.create",
|
||
http_method: hyper::method::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(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}/customers";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: CreateCustomerRequest) -> PartnerCustomerCreateCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The parent resource ID in the format `partners/[PARTNER_ID]` that
|
||
/// identifies the reseller.
|
||
///
|
||
/// 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) -> PartnerCustomerCreateCall<'a, C, 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 Delegate) -> PartnerCustomerCreateCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerCustomerCreateCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Unclaims a device from a customer and removes it from zero-touch
|
||
/// enrollment.
|
||
///
|
||
/// A builder for the *devices.unclaim* method supported by a *partner* resource.
|
||
/// It is not used directly, but through a `PartnerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::UnclaimDeviceRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = UnclaimDeviceRequest::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.partners().devices_unclaim(req, "partnerId")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct PartnerDeviceUnclaimCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: UnclaimDeviceRequest,
|
||
_partner_id: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for PartnerDeviceUnclaimCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> PartnerDeviceUnclaimCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.partners.devices.unclaim",
|
||
http_method: hyper::method::Method::Post });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("partnerId", self._partner_id.to_string()));
|
||
for &field in ["alt", "partnerId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/partners/{+partnerId}/devices:unclaim";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+partnerId}", "partnerId")].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<usize> = Vec::with_capacity(1);
|
||
for param_name in ["partnerId"].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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: UnclaimDeviceRequest) -> PartnerDeviceUnclaimCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The ID of the reseller partner.
|
||
///
|
||
/// Sets the *partner id* 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 partner_id(mut self, new_value: &str) -> PartnerDeviceUnclaimCall<'a, C, A> {
|
||
self._partner_id = 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 Delegate) -> PartnerDeviceUnclaimCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> PartnerDeviceUnclaimCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Removes a configuration from device.
|
||
///
|
||
/// A builder for the *devices.removeConfiguration* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::CustomerRemoveConfigurationRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = CustomerRemoveConfigurationRequest::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.customers().devices_remove_configuration(req, "parent")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerDeviceRemoveConfigurationCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: CustomerRemoveConfigurationRequest,
|
||
_parent: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerDeviceRemoveConfigurationCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerDeviceRemoveConfigurationCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.devices.removeConfiguration",
|
||
http_method: hyper::method::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(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:removeConfiguration";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: CustomerRemoveConfigurationRequest) -> CustomerDeviceRemoveConfigurationCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The customer managing the device in the format
|
||
/// `customers/[CUSTOMER_ID]`.
|
||
///
|
||
/// 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) -> CustomerDeviceRemoveConfigurationCall<'a, C, 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 Delegate) -> CustomerDeviceRemoveConfigurationCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerDeviceRemoveConfigurationCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Updates a configuration's field values.
|
||
///
|
||
/// A builder for the *configurations.patch* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::Configuration;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = Configuration::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.customers().configurations_patch(req, "name")
|
||
/// .update_mask("ipsum")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerConfigurationPatchCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: Configuration,
|
||
_name: String,
|
||
_update_mask: Option<String>,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerConfigurationPatchCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerConfigurationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Configuration)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.configurations.patch",
|
||
http_method: hyper::method::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(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}";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: Configuration) -> CustomerConfigurationPatchCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Output only. The API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`. Assigned by
|
||
/// the server.
|
||
///
|
||
/// 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) -> CustomerConfigurationPatchCall<'a, C, A> {
|
||
self._name = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. The field mask applied to the target `Configuration` before
|
||
/// updating the fields. To learn more about using field masks, read
|
||
/// [FieldMask](/protocol-buffers/docs/reference/google.protobuf#fieldmask) in
|
||
/// the Protocol Buffers documentation.
|
||
///
|
||
/// Sets the *update mask* query property to the given value.
|
||
pub fn update_mask(mut self, new_value: &str) -> CustomerConfigurationPatchCall<'a, C, 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 Delegate) -> CustomerConfigurationPatchCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerConfigurationPatchCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Gets the details of a device.
|
||
///
|
||
/// A builder for the *devices.get* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.customers().devices_get("name")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerDeviceGetCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerDeviceGetCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerDeviceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Device)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.devices.get",
|
||
http_method: hyper::method::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(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}";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The device to get. An API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/devices/[DEVICE_ID]`.
|
||
///
|
||
/// 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) -> CustomerDeviceGetCall<'a, C, 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 Delegate) -> CustomerDeviceGetCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerDeviceGetCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Applies a Configuration to the device to register the device for zero-touch
|
||
/// enrollment. After applying a configuration to a device, the device
|
||
/// automatically provisions itself on first boot, or next factory reset.
|
||
///
|
||
/// A builder for the *devices.applyConfiguration* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::CustomerApplyConfigurationRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = CustomerApplyConfigurationRequest::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.customers().devices_apply_configuration(req, "parent")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerDeviceApplyConfigurationCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: CustomerApplyConfigurationRequest,
|
||
_parent: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerDeviceApplyConfigurationCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerDeviceApplyConfigurationCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.devices.applyConfiguration",
|
||
http_method: hyper::method::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(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:applyConfiguration";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: CustomerApplyConfigurationRequest) -> CustomerDeviceApplyConfigurationCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The customer managing the device. An API resource name in the
|
||
/// format `customers/[CUSTOMER_ID]`.
|
||
///
|
||
/// 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) -> CustomerDeviceApplyConfigurationCall<'a, C, 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 Delegate) -> CustomerDeviceApplyConfigurationCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerDeviceApplyConfigurationCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Gets the details of a configuration.
|
||
///
|
||
/// A builder for the *configurations.get* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.customers().configurations_get("name")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerConfigurationGetCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerConfigurationGetCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Configuration)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.configurations.get",
|
||
http_method: hyper::method::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(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}";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The configuration to get. An API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`.
|
||
///
|
||
/// 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) -> CustomerConfigurationGetCall<'a, C, 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 Delegate) -> CustomerConfigurationGetCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerConfigurationGetCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Deletes an unused configuration. The API call fails if the customer has
|
||
/// devices with the configuration applied.
|
||
///
|
||
/// A builder for the *configurations.delete* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.customers().configurations_delete("name")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerConfigurationDeleteCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerConfigurationDeleteCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerConfigurationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.configurations.delete",
|
||
http_method: hyper::method::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(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}";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The configuration to delete. An API resource name in the format
|
||
/// `customers/[CUSTOMER_ID]/configurations/[CONFIGURATION_ID]`. If the
|
||
/// configuration is applied to any devices, the API call fails.
|
||
///
|
||
/// 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) -> CustomerConfigurationDeleteCall<'a, C, 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 Delegate) -> CustomerConfigurationDeleteCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerConfigurationDeleteCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Lists a customer's devices.
|
||
///
|
||
/// A builder for the *devices.list* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.customers().devices_list("parent")
|
||
/// .page_token("Lorem")
|
||
/// .page_size("eos")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerDeviceListCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_parent: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<String>,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerDeviceListCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerDeviceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, CustomerListDevicesResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.devices.list",
|
||
http_method: hyper::method::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(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";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The customer managing the devices. An API resource name in the
|
||
/// format `customers/[CUSTOMER_ID]`.
|
||
///
|
||
/// 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) -> CustomerDeviceListCall<'a, C, A> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// A token specifying which result page to return.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> CustomerDeviceListCall<'a, C, A> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of devices to show in a page of results.
|
||
/// Must be between 1 and 100 inclusive.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: &str) -> CustomerDeviceListCall<'a, C, A> {
|
||
self._page_size = 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 Delegate) -> CustomerDeviceListCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerDeviceListCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Lists the user's customer accounts.
|
||
///
|
||
/// A builder for the *list* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.customers().list()
|
||
/// .page_token("erat")
|
||
/// .page_size(-95)
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerListCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerListCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, CustomerListCustomersResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.list",
|
||
http_method: hyper::method::Method::Get });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
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", "pageToken", "pageSize"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(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/customers";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
|
||
let url = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// A token specifying which result page to return.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> CustomerListCall<'a, C, A> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of customers to show in a page of results.
|
||
/// A number between 1 and 100 (inclusive).
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> CustomerListCall<'a, C, 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 Delegate) -> CustomerListCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerListCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Unclaims a device from a customer and removes it from zero-touch
|
||
/// enrollment.
|
||
///
|
||
/// After removing a device, a customer must contact their reseller to register
|
||
/// the device into zero-touch enrollment again.
|
||
///
|
||
/// A builder for the *devices.unclaim* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::CustomerUnclaimDeviceRequest;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = CustomerUnclaimDeviceRequest::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.customers().devices_unclaim(req, "parent")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerDeviceUnclaimCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: CustomerUnclaimDeviceRequest,
|
||
_parent: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerDeviceUnclaimCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerDeviceUnclaimCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.devices.unclaim",
|
||
http_method: hyper::method::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(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:unclaim";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: CustomerUnclaimDeviceRequest) -> CustomerDeviceUnclaimCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The customer managing the device. An API resource name in the
|
||
/// format `customers/[CUSTOMER_ID]`.
|
||
///
|
||
/// 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) -> CustomerDeviceUnclaimCall<'a, C, 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 Delegate) -> CustomerDeviceUnclaimCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerDeviceUnclaimCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Lists the DPCs (device policy controllers) that support zero-touch
|
||
/// enrollment.
|
||
///
|
||
/// A builder for the *dpcs.list* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.customers().dpcs_list("parent")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerDpcListCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_parent: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerDpcListCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerDpcListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, CustomerListDpcsResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.dpcs.list",
|
||
http_method: hyper::method::Method::Get });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + 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(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}/dpcs";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The customer that can use the DPCs in configurations. An API
|
||
/// resource name in the format `customers/[CUSTOMER_ID]`.
|
||
///
|
||
/// 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) -> CustomerDpcListCall<'a, C, 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 Delegate) -> CustomerDpcListCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerDpcListCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Lists a customer's configurations.
|
||
///
|
||
/// A builder for the *configurations.list* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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.customers().configurations_list("parent")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerConfigurationListCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_parent: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerConfigurationListCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerConfigurationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, CustomerListConfigurationsResponse)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.configurations.list",
|
||
http_method: hyper::method::Method::Get });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + 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(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}/configurations";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()));
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The customer that manages the listed configurations. An API
|
||
/// resource name in the format `customers/[CUSTOMER_ID]`.
|
||
///
|
||
/// 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) -> CustomerConfigurationListCall<'a, C, 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 Delegate) -> CustomerConfigurationListCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerConfigurationListCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Creates a new configuration. Once created, a customer can apply the
|
||
/// configuration to devices.
|
||
///
|
||
/// A builder for the *configurations.create* method supported by a *customer* resource.
|
||
/// It is not used directly, but through a `CustomerMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate yup_oauth2 as oauth2;
|
||
/// # extern crate google_androiddeviceprovisioning1 as androiddeviceprovisioning1;
|
||
/// use androiddeviceprovisioning1::Configuration;
|
||
/// # #[test] fn egal() {
|
||
/// # use std::default::Default;
|
||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||
/// # use androiddeviceprovisioning1::AndroidProvisioningPartner;
|
||
///
|
||
/// # let secret: ApplicationSecret = Default::default();
|
||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||
/// # <MemoryStorage as Default>::default(), None);
|
||
/// # let mut hub = AndroidProvisioningPartner::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), 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 = Configuration::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.customers().configurations_create(req, "parent")
|
||
/// .doit();
|
||
/// # }
|
||
/// ```
|
||
pub struct CustomerConfigurationCreateCall<'a, C, A>
|
||
where C: 'a, A: 'a {
|
||
|
||
hub: &'a AndroidProvisioningPartner<C, A>,
|
||
_request: Configuration,
|
||
_parent: String,
|
||
_delegate: Option<&'a mut Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a, C, A> CallBuilder for CustomerConfigurationCreateCall<'a, C, A> {}
|
||
|
||
impl<'a, C, A> CustomerConfigurationCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub fn doit(mut self) -> Result<(hyper::client::Response, Configuration)> {
|
||
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||
let mut dd = DefaultDelegate;
|
||
let mut dlg: &mut Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(MethodInfo { id: "androiddeviceprovisioning.customers.configurations.create",
|
||
http_method: hyper::method::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(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}/configurations";
|
||
|
||
let mut key = self.hub.auth.borrow_mut().api_key();
|
||
if key.is_none() {
|
||
key = dlg.api_key();
|
||
}
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
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<usize> = 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 = hyper::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
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 {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let mut client = &mut *self.hub.client.borrow_mut();
|
||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
||
.header(UserAgent(self.hub._user_agent.clone()))
|
||
.header(ContentType(json_mime_type.clone()))
|
||
.header(ContentLength(request_size as u64))
|
||
.body(&mut request_value_reader);
|
||
|
||
dlg.pre_request();
|
||
req.send()
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status.is_success() {
|
||
let mut json_err = String::new();
|
||
res.read_to_string(&mut json_err).unwrap();
|
||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||
json::from_str(&json_err).ok(),
|
||
json::from_str(&json_err).ok()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return match json::from_str::<ErrorResponse>(&json_err){
|
||
Err(_) => Err(Error::Failure(res)),
|
||
Ok(serr) => Err(Error::BadRequest(serr))
|
||
}
|
||
}
|
||
let result_value = {
|
||
let mut json_response = String::new();
|
||
res.read_to_string(&mut json_response).unwrap();
|
||
match json::from_str(&json_response) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&json_response, &err);
|
||
return Err(Error::JsonDecodeError(json_response, 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: Configuration) -> CustomerConfigurationCreateCall<'a, C, A> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The customer that manages the configuration. An API resource name
|
||
/// in the format `customers/[CUSTOMER_ID]`.
|
||
///
|
||
/// 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) -> CustomerConfigurationCreateCall<'a, C, 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 Delegate) -> CustomerConfigurationCreateCall<'a, C, 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
|
||
///
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *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.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *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.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
pub fn param<T>(mut self, name: T, value: T) -> CustomerConfigurationCreateCall<'a, C, A>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|