Files
google-apis-rs/gen/admin1_directory/src/lib.rs
Sebastian Thiel a399488c27 fix(version-up): v0.1.5
* fix documentation link in Cargo.toml
* adjust to latest hyper. It's not even out yet, but people
  can't build the APIs anyway.
2015-04-08 16:54:50 +02:00

20378 lines
865 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 *directory* crate version *0.1.5+20150309*, where *20150309* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*.
//!
//! Everything else about the *directory* *v1_directory* API can be found at the
//! [official documentation site](https://developers.google.com/admin-sdk/directory/).
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_directory).
//! # Features
//!
//! Handle the following *Resources* with ease from the central [hub](struct.Directory.html) ...
//!
//! * [asps](struct.Asp.html)
//! * [*delete*](struct.AspDeleteCall.html), [*get*](struct.AspGetCall.html) and [*list*](struct.AspListCall.html)
//! * [channels](struct.Channel.html)
//! * [*stop*](struct.ChannelStopCall.html)
//! * chromeosdevices
//! * [*get*](struct.ChromeosdeviceGetCall.html), [*list*](struct.ChromeosdeviceListCall.html), [*patch*](struct.ChromeosdevicePatchCall.html) and [*update*](struct.ChromeosdeviceUpdateCall.html)
//! * [groups](struct.Group.html)
//! * [*aliases delete*](struct.GroupAliaseDeleteCall.html), [*aliases insert*](struct.GroupAliaseInsertCall.html), [*aliases list*](struct.GroupAliaseListCall.html), [*delete*](struct.GroupDeleteCall.html), [*get*](struct.GroupGetCall.html), [*insert*](struct.GroupInsertCall.html), [*list*](struct.GroupListCall.html), [*patch*](struct.GroupPatchCall.html) and [*update*](struct.GroupUpdateCall.html)
//! * [members](struct.Member.html)
//! * [*delete*](struct.MemberDeleteCall.html), [*get*](struct.MemberGetCall.html), [*insert*](struct.MemberInsertCall.html), [*list*](struct.MemberListCall.html), [*patch*](struct.MemberPatchCall.html) and [*update*](struct.MemberUpdateCall.html)
//! * mobiledevices
//! * [*action*](struct.MobiledeviceActionCall.html), [*delete*](struct.MobiledeviceDeleteCall.html), [*get*](struct.MobiledeviceGetCall.html) and [*list*](struct.MobiledeviceListCall.html)
//! * [notifications](struct.Notification.html)
//! * [*delete*](struct.NotificationDeleteCall.html), [*get*](struct.NotificationGetCall.html), [*list*](struct.NotificationListCall.html), [*patch*](struct.NotificationPatchCall.html) and [*update*](struct.NotificationUpdateCall.html)
//! * orgunits
//! * [*delete*](struct.OrgunitDeleteCall.html), [*get*](struct.OrgunitGetCall.html), [*insert*](struct.OrgunitInsertCall.html), [*list*](struct.OrgunitListCall.html), [*patch*](struct.OrgunitPatchCall.html) and [*update*](struct.OrgunitUpdateCall.html)
//! * [schemas](struct.Schema.html)
//! * [*delete*](struct.SchemaDeleteCall.html), [*get*](struct.SchemaGetCall.html), [*insert*](struct.SchemaInsertCall.html), [*list*](struct.SchemaListCall.html), [*patch*](struct.SchemaPatchCall.html) and [*update*](struct.SchemaUpdateCall.html)
//! * [tokens](struct.Token.html)
//! * [*delete*](struct.TokenDeleteCall.html), [*get*](struct.TokenGetCall.html) and [*list*](struct.TokenListCall.html)
//! * [users](struct.User.html)
//! * [*aliases delete*](struct.UserAliaseDeleteCall.html), [*aliases insert*](struct.UserAliaseInsertCall.html), [*aliases list*](struct.UserAliaseListCall.html), [*aliases watch*](struct.UserAliaseWatchCall.html), [*delete*](struct.UserDeleteCall.html), [*get*](struct.UserGetCall.html), [*insert*](struct.UserInsertCall.html), [*list*](struct.UserListCall.html), [*make admin*](struct.UserMakeAdminCall.html), [*patch*](struct.UserPatchCall.html), [*photos delete*](struct.UserPhotoDeleteCall.html), [*photos get*](struct.UserPhotoGetCall.html), [*photos patch*](struct.UserPhotoPatchCall.html), [*photos update*](struct.UserPhotoUpdateCall.html), [*undelete*](struct.UserUndeleteCall.html), [*update*](struct.UserUpdateCall.html) and [*watch*](struct.UserWatchCall.html)
//! * [verification codes](struct.VerificationCode.html)
//! * [*generate*](struct.VerificationCodeGenerateCall.html), [*invalidate*](struct.VerificationCodeInvalidateCall.html) and [*list*](struct.VerificationCodeListCall.html)
//!
//!
//! Subscription supported by ...
//!
//! * [*list users*](struct.UserListCall.html)
//! * [*aliases list users*](struct.UserAliaseListCall.html)
//! * [*watch users*](struct.UserWatchCall.html)
//! * [*aliases watch users*](struct.UserAliaseWatchCall.html)
//! * [*aliases list groups*](struct.GroupAliaseListCall.html)
//!
//!
//!
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html).
//!
//! # Structure of this Library
//!
//! The API is structured into the following primary items:
//!
//! * **[Hub](struct.Directory.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.users().photos_patch(...).doit()
//! let r = hub.users().aliases_delete(...).doit()
//! let r = hub.users().undelete(...).doit()
//! let r = hub.users().photos_get(...).doit()
//! let r = hub.users().update(...).doit()
//! let r = hub.users().aliases_watch(...).doit()
//! let r = hub.users().insert(...).doit()
//! let r = hub.users().photos_delete(...).doit()
//! let r = hub.users().patch(...).doit()
//! let r = hub.users().photos_update(...).doit()
//! let r = hub.users().watch(...).doit()
//! let r = hub.users().get(...).doit()
//! let r = hub.users().aliases_insert(...).doit()
//! let r = hub.users().make_admin(...).doit()
//! let r = hub.users().aliases_list(...).doit()
//! let r = hub.users().list(...).doit()
//! let r = hub.users().delete(...).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-admin1_directory = "*"
//! ```
//!
//! ## A complete example
//!
//! ```test_harness,no_run
//! extern crate hyper;
//! extern crate yup_oauth2 as oauth2;
//! extern crate google_admin1_directory as admin1_directory;
//! use admin1_directory::Channel;
//! use admin1_directory::{Result, Error};
//! # #[test] fn egal() {
//! use std::default::Default;
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
//! use admin1_directory::Directory;
//!
//! // 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::new(),
//! <MemoryStorage as Default>::default(), None);
//! let mut hub = Directory::new(hyper::Client::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: Channel = Default::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.users().watch(&req)
//! .view_type("labore")
//! .sort_order("sea")
//! .show_deleted("nonumy")
//! .query("dolores")
//! .projection("gubergren")
//! .page_token("sadipscing")
//! .order_by("aliquyam")
//! .max_results(-66)
//! .event("no")
//! .domain("justo")
//! .customer("justo")
//! .custom_field_mask("et")
//! .doit();
//!
//! match result {
//! Err(e) => match e {
//! Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
//! Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
//! Error::MissingToken => println!("OAuth2: Missing Token"),
//! Error::Cancelled => println!("Operation canceled by user"),
//! Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
//! Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
//! Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
//! Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
//! },
//! Ok(_) => println!("Success (value doesn't print)"),
//! }
//! # }
//! ```
//! ## 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](../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 borrowed
//!
//! 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
//!
//!
#![feature(std_misc)]
// 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)]
// Required for serde annotations
#![feature(custom_derive, custom_attribute, plugin, slice_patterns)]
#![plugin(serde_macros)]
#[macro_use]
extern crate hyper;
extern crate serde;
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;
use std::io;
use std::fs;
use std::thread::sleep_ms;
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError};
// ##############
// UTILITIES ###
// ############
/// Identifies the an OAuth2 authorization scope.
/// A scope is needed when requesting an
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
#[derive(PartialEq, Eq, Hash)]
pub enum Scope {
/// View and manage user aliases on your domain
DirectoryUserAlia,
/// View your mobile devices' metadata
DirectoryDeviceMobileReadonly,
/// View and manage notifications received on your domain
DirectoryNotification,
/// View groups on your domain
DirectoryGroupReadonly,
/// View and manage the provisioning of user schemas on your domain
DirectoryUserschema,
/// View your Chrome OS devices' metadata
DirectoryDeviceChromeoReadonly,
/// View group subscriptions on your domain
DirectoryGroupMemberReadonly,
/// Manage data access permissions for users on your domain
DirectoryUserSecurity,
/// View organization units on your domain
DirectoryOrgunitReadonly,
/// View and manage group subscriptions on your domain
DirectoryGroupMember,
/// View and manage your mobile devices' metadata
DirectoryDeviceMobile,
/// View and manage the provisioning of users on your domain
DirectoryUser,
/// Manage your mobile devices by performing administrative tasks
DirectoryDeviceMobileAction,
/// View users on your domain
DirectoryUserReadonly,
/// View and manage your Chrome OS devices' metadata
DirectoryDeviceChromeo,
/// View user aliases on your domain
DirectoryUserAliaReadonly,
/// View and manage the provisioning of groups on your domain
DirectoryGroup,
/// View user schemas on your domain
DirectoryUserschemaReadonly,
/// View and manage organization units on your domain
DirectoryOrgunit,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::DirectoryUserAlia => "https://www.googleapis.com/auth/admin.directory.user.alias",
Scope::DirectoryDeviceMobileReadonly => "https://www.googleapis.com/auth/admin.directory.device.mobile.readonly",
Scope::DirectoryNotification => "https://www.googleapis.com/auth/admin.directory.notifications",
Scope::DirectoryGroupReadonly => "https://www.googleapis.com/auth/admin.directory.group.readonly",
Scope::DirectoryUserschema => "https://www.googleapis.com/auth/admin.directory.userschema",
Scope::DirectoryDeviceChromeoReadonly => "https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly",
Scope::DirectoryGroupMemberReadonly => "https://www.googleapis.com/auth/admin.directory.group.member.readonly",
Scope::DirectoryUserSecurity => "https://www.googleapis.com/auth/admin.directory.user.security",
Scope::DirectoryOrgunitReadonly => "https://www.googleapis.com/auth/admin.directory.orgunit.readonly",
Scope::DirectoryGroupMember => "https://www.googleapis.com/auth/admin.directory.group.member",
Scope::DirectoryDeviceMobile => "https://www.googleapis.com/auth/admin.directory.device.mobile",
Scope::DirectoryUser => "https://www.googleapis.com/auth/admin.directory.user",
Scope::DirectoryDeviceMobileAction => "https://www.googleapis.com/auth/admin.directory.device.mobile.action",
Scope::DirectoryUserReadonly => "https://www.googleapis.com/auth/admin.directory.user.readonly",
Scope::DirectoryDeviceChromeo => "https://www.googleapis.com/auth/admin.directory.device.chromeos",
Scope::DirectoryUserAliaReadonly => "https://www.googleapis.com/auth/admin.directory.user.alias.readonly",
Scope::DirectoryGroup => "https://www.googleapis.com/auth/admin.directory.group",
Scope::DirectoryUserschemaReadonly => "https://www.googleapis.com/auth/admin.directory.userschema.readonly",
Scope::DirectoryOrgunit => "https://www.googleapis.com/auth/admin.directory.orgunit",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::DirectoryDeviceMobileReadonly
}
}
// ########
// HUB ###
// ######
/// Central instance to access all Directory related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Channel;
/// use admin1_directory::{Result, Error};
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// // 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::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::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: Channel = Default::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.users().watch(&req)
/// .view_type("et")
/// .sort_order("diam")
/// .show_deleted("ipsum")
/// .query("Lorem")
/// .projection("et")
/// .page_token("duo")
/// .order_by("aliquyam")
/// .max_results(-9)
/// .event("Lorem")
/// .domain("eos")
/// .customer("erat")
/// .custom_field_mask("sadipscing")
/// .doit();
///
/// match result {
/// Err(e) => match e {
/// Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
/// Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
/// Error::MissingToken => println!("OAuth2: Missing Token"),
/// Error::Cancelled => println!("Operation canceled by user"),
/// Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
/// Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
/// Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
/// Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
/// },
/// Ok(_) => println!("Success (value doesn't print)"),
/// }
/// # }
/// ```
pub struct Directory<C, A> {
client: RefCell<C>,
auth: RefCell<A>,
_user_agent: String,
}
impl<'a, C, A> Hub for Directory<C, A> {}
impl<'a, C, A> Directory<C, A>
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
pub fn new(client: C, authenticator: A) -> Directory<C, A> {
Directory {
client: RefCell::new(client),
auth: RefCell::new(authenticator),
_user_agent: "google-api-rust-client/0.1.5".to_string(),
}
}
pub fn asps(&'a self) -> AspMethods<'a, C, A> {
AspMethods { hub: &self }
}
pub fn channels(&'a self) -> ChannelMethods<'a, C, A> {
ChannelMethods { hub: &self }
}
pub fn chromeosdevices(&'a self) -> ChromeosdeviceMethods<'a, C, A> {
ChromeosdeviceMethods { hub: &self }
}
pub fn groups(&'a self) -> GroupMethods<'a, C, A> {
GroupMethods { hub: &self }
}
pub fn members(&'a self) -> MemberMethods<'a, C, A> {
MemberMethods { hub: &self }
}
pub fn mobiledevices(&'a self) -> MobiledeviceMethods<'a, C, A> {
MobiledeviceMethods { hub: &self }
}
pub fn notifications(&'a self) -> NotificationMethods<'a, C, A> {
NotificationMethods { hub: &self }
}
pub fn orgunits(&'a self) -> OrgunitMethods<'a, C, A> {
OrgunitMethods { hub: &self }
}
pub fn schemas(&'a self) -> SchemaMethods<'a, C, A> {
SchemaMethods { hub: &self }
}
pub fn tokens(&'a self) -> TokenMethods<'a, C, A> {
TokenMethods { hub: &self }
}
pub fn users(&'a self) -> UserMethods<'a, C, A> {
UserMethods { hub: &self }
}
pub fn verification_codes(&'a self) -> VerificationCodeMethods<'a, C, A> {
VerificationCodeMethods { hub: &self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/0.1.5`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
let prev = self._user_agent.clone();
self._user_agent = agent_name;
prev
}
}
// ############
// SCHEMAS ###
// ##########
/// JSON template for name of a user in Directory API.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct UserName {
/// Full Name
#[serde(rename="fullName")]
pub full_name: String,
/// First Name
#[serde(rename="givenName")]
pub given_name: String,
/// Last Name
#[serde(rename="familyName")]
pub family_name: String,
}
impl Part for UserName {}
/// JSON template for Group resource in Directory API.
///
/// # 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*).
///
/// * [get groups](struct.GroupGetCall.html) (response)
/// * [aliases insert groups](struct.GroupAliaseInsertCall.html) (none)
/// * [delete groups](struct.GroupDeleteCall.html) (none)
/// * [aliases delete groups](struct.GroupAliaseDeleteCall.html) (none)
/// * [patch groups](struct.GroupPatchCall.html) (request|response)
/// * [list groups](struct.GroupListCall.html) (none)
/// * [aliases list groups](struct.GroupAliaseListCall.html) (none)
/// * [update groups](struct.GroupUpdateCall.html) (request|response)
/// * [insert groups](struct.GroupInsertCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Group {
/// List of non editable aliases (Read-only)
#[serde(rename="nonEditableAliases")]
pub non_editable_aliases: Option<Vec<String>>,
/// Kind of resource this is.
pub kind: Option<String>,
/// Description of the group
pub description: Option<String>,
/// Is the group created by admin (Read-only) *
#[serde(rename="adminCreated")]
pub admin_created: Option<bool>,
/// Group direct members count
#[serde(rename="directMembersCount")]
pub direct_members_count: Option<i64>,
/// Email of Group
pub email: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// List of aliases (Read-only)
pub aliases: Option<Vec<String>>,
/// Unique identifier of Group (Read-only)
pub id: Option<String>,
/// Group name
pub name: Option<String>,
}
impl RequestValue for Group {}
impl Resource for Group {}
impl ResponseResult for Group {}
/// Template for a notification resource.
///
/// # 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*).
///
/// * [delete notifications](struct.NotificationDeleteCall.html) (none)
/// * [update notifications](struct.NotificationUpdateCall.html) (request|response)
/// * [patch notifications](struct.NotificationPatchCall.html) (request|response)
/// * [get notifications](struct.NotificationGetCall.html) (response)
/// * [list notifications](struct.NotificationListCall.html) (none)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Notification {
/// Body of the notification (Read-only)
pub body: Option<String>,
/// The type of the resource.
pub kind: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// Time at which notification was sent (Read-only)
#[serde(rename="sendTime")]
pub send_time: Option<String>,
/// no description provided
#[serde(rename="notificationId")]
pub notification_id: Option<String>,
/// Address from which the notification is received (Read-only)
#[serde(rename="fromAddress")]
pub from_address: Option<String>,
/// Boolean indicating whether the notification is unread or not.
#[serde(rename="isUnread")]
pub is_unread: Option<bool>,
/// Subject of the notification (Read-only)
pub subject: Option<String>,
}
impl RequestValue for Notification {}
impl Resource for Notification {}
impl ResponseResult for Notification {}
/// JSON template for FieldSpec resource for Schemas in Directory API.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct SchemaFieldSpec {
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// Read ACLs on the field specifying who can view values of this field. Valid values are "ALL_DOMAIN_USERS" and "ADMINS_AND_SELF".
#[serde(rename="readAccessType")]
pub read_access_type: String,
/// Type of the field.
#[serde(rename="fieldType")]
pub field_type: String,
/// Boolean specifying whether the field is indexed or not.
pub indexed: bool,
/// Name of the field.
#[serde(rename="fieldName")]
pub field_name: String,
/// Indexing spec for a numeric field. By default, only exact match queries will be supported for numeric fields. Setting the numericIndexingSpec allows range queries to be supported.
#[serde(rename="numericIndexingSpec")]
pub numeric_indexing_spec: SchemaFieldSpecNumericIndexingSpec,
/// Unique identifier of Field (Read-only)
#[serde(rename="fieldId")]
pub field_id: String,
/// Boolean specifying whether this is a multi-valued field or not.
#[serde(rename="multiValued")]
pub multi_valued: bool,
}
impl Part for SchemaFieldSpec {}
/// JSON template for Member resource in Directory API.
///
/// # 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*).
///
/// * [patch members](struct.MemberPatchCall.html) (request|response)
/// * [list members](struct.MemberListCall.html) (none)
/// * [insert members](struct.MemberInsertCall.html) (request|response)
/// * [get members](struct.MemberGetCall.html) (response)
/// * [delete members](struct.MemberDeleteCall.html) (none)
/// * [update members](struct.MemberUpdateCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Member {
/// Kind of resource this is.
pub kind: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// Role of member
pub role: Option<String>,
/// Type of member (Immutable)
#[serde(rename="type")]
pub type_: Option<String>,
/// Email of member (Read-only)
pub email: Option<String>,
/// Unique identifier of customer member (Read-only) Unique identifier of group (Read-only) Unique identifier of member (Read-only)
pub id: Option<String>,
}
impl RequestValue for Member {}
impl Resource for Member {}
impl ResponseResult for Member {}
/// JSON response template for List Organization Units operation in Directory API.
///
/// # 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 orgunits](struct.OrgunitListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct OrgUnits {
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// List of user objects.
#[serde(rename="organizationUnits")]
pub organization_units: Vec<OrgUnit>,
}
impl ResponseResult for OrgUnits {}
/// JSON template for token resource in Directory API.
///
/// # 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 tokens](struct.TokenListCall.html) (none)
/// * [delete tokens](struct.TokenDeleteCall.html) (none)
/// * [get tokens](struct.TokenGetCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Token {
/// A list of authorization scopes the application is granted.
pub scopes: Vec<String>,
/// The type of the API resource. This is always admin#directory#token.
pub kind: String,
/// The Client ID of the application the token is issued to.
#[serde(rename="clientId")]
pub client_id: String,
/// Whether the token is issued to an installed application. The value is true if the application is installed to a desktop or mobile device.
#[serde(rename="nativeApp")]
pub native_app: bool,
/// The displayable name of the application the token is issued to.
#[serde(rename="displayText")]
pub display_text: String,
/// ETag of the resource.
pub etag: String,
/// Whether the application is registered with Google. The value is true if the application has an anonymous Client ID.
pub anonymous: bool,
/// The unique ID of the user that issued the token.
#[serde(rename="userKey")]
pub user_key: String,
}
impl Resource for Token {}
impl ResponseResult for Token {}
/// There is no detailed description.
///
/// # 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 asps](struct.AspListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Asps {
/// A list of ASP resources.
pub items: Vec<Asp>,
/// The type of the API resource. This is always admin#directory#aspList.
pub kind: String,
/// ETag of the resource.
pub etag: String,
}
impl ResponseResult for Asps {}
/// An notification channel used to watch for resource changes.
///
/// # 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*).
///
/// * [watch users](struct.UserWatchCall.html) (request|response)
/// * [stop channels](struct.ChannelStopCall.html) (request)
/// * [aliases watch users](struct.UserAliaseWatchCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Channel {
/// A version-specific identifier for the watched resource.
#[serde(rename="resourceUri")]
pub resource_uri: Option<String>,
/// Identifies this as a notification channel used to watch for changes to a resource. Value: the fixed string "api#channel".
pub kind: Option<String>,
/// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
#[serde(rename="resourceId")]
pub resource_id: Option<String>,
/// A UUID or similar unique string that identifies this channel.
pub id: Option<String>,
/// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
pub token: Option<String>,
/// Additional parameters controlling delivery channel behavior. Optional.
pub params: Option<HashMap<String, String>>,
/// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
pub expiration: Option<String>,
/// The address where notifications are delivered for this channel.
pub address: Option<String>,
/// The type of delivery mechanism used for this channel.
#[serde(rename="type")]
pub type_: Option<String>,
/// A Boolean value to indicate whether payload is wanted. Optional.
pub payload: Option<bool>,
}
impl RequestValue for Channel {}
impl Resource for Channel {}
impl ResponseResult for Channel {}
/// JSON template for Schema resource in Directory API.
///
/// # 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*).
///
/// * [get schemas](struct.SchemaGetCall.html) (response)
/// * [insert schemas](struct.SchemaInsertCall.html) (request|response)
/// * [patch schemas](struct.SchemaPatchCall.html) (request|response)
/// * [delete schemas](struct.SchemaDeleteCall.html) (none)
/// * [list schemas](struct.SchemaListCall.html) (none)
/// * [update schemas](struct.SchemaUpdateCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Schema {
/// Fields of Schema
pub fields: Option<Vec<SchemaFieldSpec>>,
/// Kind of resource this is.
pub kind: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// Unique identifier of Schema (Read-only)
#[serde(rename="schemaId")]
pub schema_id: Option<String>,
/// Schema name
#[serde(rename="schemaName")]
pub schema_name: Option<String>,
}
impl RequestValue for Schema {}
impl Resource for Schema {}
impl ResponseResult for Schema {}
/// The template that returns individual ASP (Access Code) data.
///
/// # 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 asps](struct.AspListCall.html) (none)
/// * [delete asps](struct.AspDeleteCall.html) (none)
/// * [get asps](struct.AspGetCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Asp {
/// The type of the API resource. This is always admin#directory#asp.
pub kind: String,
/// ETag of the ASP.
pub etag: String,
/// The name of the application that the user, represented by their userId, entered when the ASP was created.
pub name: String,
/// The unique ID of the ASP.
#[serde(rename="codeId")]
pub code_id: i32,
/// The time when the ASP was last used. Expressed in Unix time format.
#[serde(rename="lastTimeUsed")]
pub last_time_used: String,
/// The unique ID of the user who issued the ASP.
#[serde(rename="userKey")]
pub user_key: String,
/// The time when the ASP was created. Expressed in Unix time format.
#[serde(rename="creationTime")]
pub creation_time: String,
}
impl Resource for Asp {}
impl ResponseResult for Asp {}
/// JSON response template for List tokens operation in Directory API.
///
/// # 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 tokens](struct.TokenListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Tokens {
/// A list of Token resources.
pub items: Vec<Token>,
/// The type of the API resource. This is always admin#directory#tokenList.
pub kind: String,
/// ETag of the resource.
pub etag: String,
}
impl ResponseResult for Tokens {}
/// Template for notifications list response.
///
/// # 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 notifications](struct.NotificationListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Notifications {
/// Token for fetching the next page of notifications.
#[serde(rename="nextPageToken")]
pub next_page_token: String,
/// List of notifications in this page.
pub items: Vec<Notification>,
/// The type of the resource.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// Number of unread notification for the domain.
#[serde(rename="unreadNotificationsCount")]
pub unread_notifications_count: i32,
}
impl ResponseResult for Notifications {}
/// JSON template for Chrome Os Device resource in Directory API.
///
/// # 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*).
///
/// * [get chromeosdevices](struct.ChromeosdeviceGetCall.html) (response)
/// * [update chromeosdevices](struct.ChromeosdeviceUpdateCall.html) (request|response)
/// * [patch chromeosdevices](struct.ChromeosdevicePatchCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ChromeOsDevice {
/// List of recent device users, in descending order by last login time (Read-only)
#[serde(rename="recentUsers")]
pub recent_users: Option<Vec<ChromeOsDeviceRecentUsers>>,
/// Chromebook Mac Address on wifi network interface (Read-only)
#[serde(rename="macAddress")]
pub mac_address: Option<String>,
/// Chromebook serial number (Read-only)
#[serde(rename="serialNumber")]
pub serial_number: Option<String>,
/// Date and time the device was last synchronized with the policy settings in the Google Apps administrator control panel (Read-only)
#[serde(rename="lastSync")]
pub last_sync: Option<String>,
/// Chromebook order number (Read-only)
#[serde(rename="orderNumber")]
pub order_number: Option<String>,
/// Mobile Equipment identifier for the 3G mobile card in the Chromebook (Read-only)
pub meid: Option<String>,
/// Address or location of the device as noted by the administrator
#[serde(rename="annotatedLocation")]
pub annotated_location: Option<String>,
/// User of the device
#[serde(rename="annotatedUser")]
pub annotated_user: Option<String>,
/// Chromebook platform version (Read-only)
#[serde(rename="platformVersion")]
pub platform_version: Option<String>,
/// List of active time ranges (Read-only)
#[serde(rename="activeTimeRanges")]
pub active_time_ranges: Option<Vec<ChromeOsDeviceActiveTimeRanges>>,
/// Unique identifier of Chrome OS Device (Read-only)
#[serde(rename="deviceId")]
pub device_id: Option<String>,
/// Chromebook Mac Address on ethernet network interface (Read-only)
#[serde(rename="ethernetMacAddress")]
pub ethernet_mac_address: Option<String>,
/// Chromebook Os Version (Read-only)
#[serde(rename="osVersion")]
pub os_version: Option<String>,
/// Chromebook firmware version (Read-only)
#[serde(rename="firmwareVersion")]
pub firmware_version: Option<String>,
/// Date and time the device was last enrolled (Read-only)
#[serde(rename="lastEnrollmentTime")]
pub last_enrollment_time: Option<String>,
/// Kind of resource this is.
pub kind: Option<String>,
/// Notes added by the administrator
pub notes: Option<String>,
/// Will Chromebook auto renew after support end date (Read-only)
#[serde(rename="willAutoRenew")]
pub will_auto_renew: Option<bool>,
/// Chromebook boot mode (Read-only)
#[serde(rename="bootMode")]
pub boot_mode: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// status of the device (Read-only)
pub status: Option<String>,
/// OrgUnit of the device
#[serde(rename="orgUnitPath")]
pub org_unit_path: Option<String>,
/// Chromebook Model (Read-only)
pub model: Option<String>,
/// Final date the device will be supported (Read-only)
#[serde(rename="supportEndDate")]
pub support_end_date: Option<String>,
}
impl RequestValue for ChromeOsDevice {}
impl Resource for ChromeOsDevice {}
impl ResponseResult for ChromeOsDevice {}
/// JSON template for User object in Directory API.
///
/// # 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*).
///
/// * [photos patch users](struct.UserPhotoPatchCall.html) (none)
/// * [aliases delete users](struct.UserAliaseDeleteCall.html) (none)
/// * [undelete users](struct.UserUndeleteCall.html) (none)
/// * [photos get users](struct.UserPhotoGetCall.html) (none)
/// * [update users](struct.UserUpdateCall.html) (request|response)
/// * [aliases watch users](struct.UserAliaseWatchCall.html) (none)
/// * [insert users](struct.UserInsertCall.html) (request|response)
/// * [photos delete users](struct.UserPhotoDeleteCall.html) (none)
/// * [patch users](struct.UserPatchCall.html) (request|response)
/// * [photos update users](struct.UserPhotoUpdateCall.html) (none)
/// * [watch users](struct.UserWatchCall.html) (none)
/// * [get users](struct.UserGetCall.html) (response)
/// * [aliases insert users](struct.UserAliaseInsertCall.html) (none)
/// * [make admin users](struct.UserMakeAdminCall.html) (none)
/// * [aliases list users](struct.UserAliaseListCall.html) (none)
/// * [list users](struct.UserListCall.html) (none)
/// * [delete users](struct.UserDeleteCall.html) (none)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct User {
/// no description provided
pub addresses: Option<String>,
/// no description provided
pub phones: Option<String>,
/// Boolean indicating if the user is delegated admin (Read-only)
#[serde(rename="isDelegatedAdmin")]
pub is_delegated_admin: Option<bool>,
/// Indicates if user is suspended
pub suspended: Option<bool>,
/// Unique identifier of User (Read-only)
pub id: Option<String>,
/// List of aliases (Read-only)
pub aliases: Option<Vec<String>>,
/// List of non editable aliases (Read-only)
#[serde(rename="nonEditableAliases")]
pub non_editable_aliases: Option<Vec<String>>,
/// Custom fields of the user.
#[serde(rename="customSchemas")]
pub custom_schemas: Option<HashMap<String, UserCustomProperties>>,
/// no description provided
#[serde(rename="deletionTime")]
pub deletion_time: Option<String>,
/// Suspension reason if user is suspended (Read-only)
#[serde(rename="suspensionReason")]
pub suspension_reason: Option<String>,
/// Photo Url of the user (Read-only)
#[serde(rename="thumbnailPhotoUrl")]
pub thumbnail_photo_url: Option<String>,
/// Boolean indicating if the user is admin (Read-only)
#[serde(rename="isAdmin")]
pub is_admin: Option<bool>,
/// no description provided
pub relations: Option<String>,
/// Boolean indicating if user is included in Global Address List
#[serde(rename="includeInGlobalAddressList")]
pub include_in_global_address_list: Option<bool>,
/// ETag of the resource.
pub etag: Option<String>,
/// User's last login time. (Read-only)
#[serde(rename="lastLoginTime")]
pub last_login_time: Option<String>,
/// OrgUnit of User
#[serde(rename="orgUnitPath")]
pub org_unit_path: Option<String>,
/// Indicates if user has agreed to terms (Read-only)
#[serde(rename="agreedToTerms")]
pub agreed_to_terms: Option<bool>,
/// no description provided
#[serde(rename="externalIds")]
pub external_ids: Option<String>,
/// Boolean indicating if ip is whitelisted
#[serde(rename="ipWhitelisted")]
pub ip_whitelisted: Option<bool>,
/// Kind of resource this is.
pub kind: Option<String>,
/// Is mailbox setup (Read-only)
#[serde(rename="isMailboxSetup")]
pub is_mailbox_setup: Option<bool>,
/// User's password
pub password: Option<String>,
/// no description provided
pub emails: Option<String>,
/// no description provided
pub organizations: Option<String>,
/// username of User
#[serde(rename="primaryEmail")]
pub primary_email: Option<String>,
/// Hash function name for password. Supported are MD5, SHA-1 and crypt
#[serde(rename="hashFunction")]
pub hash_function: Option<String>,
/// User's name
pub name: Option<UserName>,
/// no description provided
pub notes: Option<String>,
/// User's Google account creation time. (Read-only)
#[serde(rename="creationTime")]
pub creation_time: Option<String>,
/// no description provided
pub websites: Option<String>,
/// Boolean indicating if the user should change password in next login
#[serde(rename="changePasswordAtNextLogin")]
pub change_password_at_next_login: Option<bool>,
/// no description provided
pub ims: Option<String>,
/// CustomerId of User (Read-only)
#[serde(rename="customerId")]
pub customer_id: Option<String>,
}
impl RequestValue for User {}
impl Resource for User {}
impl ResponseResult for User {}
/// JSON response template for List Groups operation in Directory API.
///
/// # 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 groups](struct.GroupListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Groups {
/// Token used to access next page of this result.
#[serde(rename="nextPageToken")]
pub next_page_token: String,
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// List of group objects.
pub groups: Vec<Group>,
}
impl ResponseResult for Groups {}
/// List of recent device users, in descending order by last login time (Read-only)
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ChromeOsDeviceRecentUsers {
/// The type of the user
#[serde(rename="type")]
pub type_: String,
/// Email address of the user. Present only if the user type is managed
pub email: String,
}
impl NestedType for ChromeOsDeviceRecentUsers {}
impl Part for ChromeOsDeviceRecentUsers {}
/// List of applications installed on Mobile Device
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct MobileDeviceApplications {
/// Version code of application
#[serde(rename="versionCode")]
pub version_code: i32,
/// Package name of application
#[serde(rename="packageName")]
pub package_name: String,
/// Display name of application
#[serde(rename="displayName")]
pub display_name: String,
/// Version name of application
#[serde(rename="versionName")]
pub version_name: String,
/// List of Permissions for application
pub permission: Vec<String>,
}
impl NestedType for MobileDeviceApplications {}
impl Part for MobileDeviceApplications {}
/// JSON template for a set of custom properties (i.e. all fields in a particular schema)
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct UserCustomProperties(HashMap<String, String>);
impl Part for UserCustomProperties {}
/// JSON response template for List Members operation in Directory API.
///
/// # 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 members](struct.MemberListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Members {
/// Token used to access next page of this result.
#[serde(rename="nextPageToken")]
pub next_page_token: String,
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// List of member objects.
pub members: Vec<Member>,
}
impl ResponseResult for Members {}
/// JSON request template to undelete a user in Directory API.
///
/// # 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*).
///
/// * [undelete users](struct.UserUndeleteCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize)]
pub struct UserUndelete {
/// OrgUnit of User
#[serde(rename="orgUnitPath")]
pub org_unit_path: Option<String>,
}
impl RequestValue for UserUndelete {}
/// JSON response template for List verification codes operation in Directory API.
///
/// # 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 verification codes](struct.VerificationCodeListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct VerificationCodes {
/// A list of verification code resources.
pub items: Vec<VerificationCode>,
/// The type of the resource. This is always admin#directory#verificationCodesList.
pub kind: String,
/// ETag of the resource.
pub etag: String,
}
impl ResponseResult for VerificationCodes {}
/// JSON template for Alias object in Directory API.
///
/// # 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*).
///
/// * [aliases insert users](struct.UserAliaseInsertCall.html) (request|response)
/// * [aliases insert groups](struct.GroupAliaseInsertCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Alias {
/// A alias email
pub alias: Option<String>,
/// Kind of resource this is.
pub kind: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// Group's primary email (Read-only) User's primary email (Read-only)
#[serde(rename="primaryEmail")]
pub primary_email: Option<String>,
/// Unique id of the group (Read-only) Unique id of the user (Read-only)
pub id: Option<String>,
}
impl RequestValue for Alias {}
impl ResponseResult for Alias {}
/// JSON response template for List Mobile Devices operation in Directory API.
///
/// # 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 mobiledevices](struct.MobiledeviceListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct MobileDevices {
/// Token used to access next page of this result.
#[serde(rename="nextPageToken")]
pub next_page_token: String,
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// List of Mobile Device objects.
pub mobiledevices: Vec<MobileDevice>,
}
impl ResponseResult for MobileDevices {}
/// List of active time ranges (Read-only)
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ChromeOsDeviceActiveTimeRanges {
/// Date of usage
pub date: String,
/// Duration in milliseconds
#[serde(rename="activeTime")]
pub active_time: i32,
}
impl NestedType for ChromeOsDeviceActiveTimeRanges {}
impl Part for ChromeOsDeviceActiveTimeRanges {}
/// JSON template for Photo object in Directory API.
///
/// # 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*).
///
/// * [photos update users](struct.UserPhotoUpdateCall.html) (request|response)
/// * [photos patch users](struct.UserPhotoPatchCall.html) (request|response)
/// * [photos get users](struct.UserPhotoGetCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct UserPhoto {
/// Mime Type of the photo
#[serde(rename="mimeType")]
pub mime_type: Option<String>,
/// Kind of resource this is.
pub kind: Option<String>,
/// Base64 encoded photo data
#[serde(rename="photoData")]
pub photo_data: Option<String>,
/// Height in pixels of the photo
pub height: Option<i32>,
/// Width in pixels of the photo
pub width: Option<i32>,
/// ETag of the resource.
pub etag: Option<String>,
/// Primary email of User (Read-only)
#[serde(rename="primaryEmail")]
pub primary_email: Option<String>,
/// Unique identifier of User (Read-only)
pub id: Option<String>,
}
impl RequestValue for UserPhoto {}
impl ResponseResult for UserPhoto {}
/// JSON request template for firing commands on Mobile Device in Directory Devices API.
///
/// # 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*).
///
/// * [action mobiledevices](struct.MobiledeviceActionCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize)]
pub struct MobileDeviceAction {
/// Action to be taken on the Mobile Device
pub action: Option<String>,
}
impl RequestValue for MobileDeviceAction {}
/// JSON request template for setting/revoking admin status of a user in Directory API.
///
/// # 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*).
///
/// * [make admin users](struct.UserMakeAdminCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize)]
pub struct UserMakeAdmin {
/// Boolean indicating new admin status of the user
pub status: Option<bool>,
}
impl RequestValue for UserMakeAdmin {}
/// JSON response template for List Users operation in Apps Directory API.
///
/// # 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 users](struct.UserListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Users {
/// Token used to access next page of this result.
#[serde(rename="nextPageToken")]
pub next_page_token: String,
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// Event that triggered this response (only used in case of Push Response)
pub trigger_event: String,
/// List of user objects.
pub users: Vec<User>,
}
impl ResponseResult for Users {}
/// JSON template for Mobile Device resource in Directory API.
///
/// # 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*).
///
/// * [get mobiledevices](struct.MobiledeviceGetCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct MobileDevice {
/// Mobile Device Kernel version (Read-only)
#[serde(rename="kernelVersion")]
pub kernel_version: String,
/// Date and time the device was last synchronized with the policy settings in the Google Apps administrator control panel (Read-only)
#[serde(rename="lastSync")]
pub last_sync: String,
/// Mobile Device compromised status (Read-only)
#[serde(rename="deviceCompromisedStatus")]
pub device_compromised_status: String,
/// Unique identifier of Mobile Device (Read-only)
#[serde(rename="resourceId")]
pub resource_id: String,
/// Mobile Device MEID number (Read-only)
pub meid: String,
/// The default locale used on the Mobile Device (Read-only)
#[serde(rename="defaultLanguage")]
pub default_language: String,
/// Mobile Device Build number (Read-only)
#[serde(rename="buildNumber")]
pub build_number: String,
/// List of applications installed on Mobile Device
pub applications: Vec<MobileDeviceApplications>,
/// Mobile Device serial number (Read-only)
#[serde(rename="deviceId")]
pub device_id: String,
/// Mobile Device IMEI number (Read-only)
pub imei: String,
/// Mobile Device user agent
#[serde(rename="userAgent")]
pub user_agent: String,
/// Mobile Device Baseband version (Read-only)
#[serde(rename="basebandVersion")]
pub baseband_version: String,
/// Kind of resource this is.
pub kind: String,
/// List of owner user's names (Read-only)
pub name: Vec<String>,
/// Date and time the device was first synchronized with the policy settings in the Google Apps administrator control panel (Read-only)
#[serde(rename="firstSync")]
pub first_sync: String,
/// Name of the mobile operating system
pub os: String,
/// Mobile Device SSN or Serial Number (Read-only)
#[serde(rename="serialNumber")]
pub serial_number: String,
/// Mobile Device Hardware Id (Read-only)
#[serde(rename="hardwareId")]
pub hardware_id: String,
/// Mobile Device mobile or network operator (if available) (Read-only)
#[serde(rename="networkOperator")]
pub network_operator: String,
/// ETag of the resource.
pub etag: String,
/// Status of the device (Read-only)
pub status: String,
/// Boolean indicating if this account is on owner/primary profile or not (Read-only)
#[serde(rename="managedAccountIsOnOwnerProfile")]
pub managed_account_is_on_owner_profile: bool,
/// Name of the model of the device
pub model: String,
/// The type of device (Read-only)
#[serde(rename="type")]
pub type_: String,
/// List of owner user's email addresses (Read-only)
pub email: Vec<String>,
/// Mobile Device WiFi MAC address (Read-only)
#[serde(rename="wifiMacAddress")]
pub wifi_mac_address: String,
}
impl Resource for MobileDevice {}
impl ResponseResult for MobileDevice {}
/// JSON response template for List Chrome OS Devices operation in Directory API.
///
/// # 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 chromeosdevices](struct.ChromeosdeviceListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct ChromeOsDevices {
/// Token used to access next page of this result.
#[serde(rename="nextPageToken")]
pub next_page_token: String,
/// List of Chrome OS Device objects.
pub chromeosdevices: Vec<ChromeOsDevice>,
/// ETag of the resource.
pub etag: String,
/// Kind of resource this is.
pub kind: String,
}
impl ResponseResult for ChromeOsDevices {}
/// JSON template for Org Unit resource in Directory API.
///
/// # 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*).
///
/// * [patch orgunits](struct.OrgunitPatchCall.html) (request|response)
/// * [get orgunits](struct.OrgunitGetCall.html) (response)
/// * [update orgunits](struct.OrgunitUpdateCall.html) (request|response)
/// * [insert orgunits](struct.OrgunitInsertCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrgUnit {
/// Kind of resource this is.
pub kind: Option<String>,
/// Path of parent OrgUnit
#[serde(rename="parentOrgUnitPath")]
pub parent_org_unit_path: Option<String>,
/// Name of OrgUnit
pub name: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// Id of OrgUnit
#[serde(rename="orgUnitId")]
pub org_unit_id: Option<String>,
/// Id of parent OrgUnit
#[serde(rename="parentOrgUnitId")]
pub parent_org_unit_id: Option<String>,
/// Should block inheritance
#[serde(rename="blockInheritance")]
pub block_inheritance: Option<bool>,
/// Path of OrgUnit
#[serde(rename="orgUnitPath")]
pub org_unit_path: Option<String>,
/// Description of OrgUnit
pub description: Option<String>,
}
impl RequestValue for OrgUnit {}
impl Resource for OrgUnit {}
impl ResponseResult for OrgUnit {}
/// JSON template for verification codes in Directory API.
///
/// # 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*).
///
/// * [invalidate verification codes](struct.VerificationCodeInvalidateCall.html) (none)
/// * [list verification codes](struct.VerificationCodeListCall.html) (none)
/// * [generate verification codes](struct.VerificationCodeGenerateCall.html) (none)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct VerificationCode {
/// The type of the resource. This is always admin#directory#verificationCode.
pub kind: Option<String>,
/// ETag of the resource.
pub etag: Option<String>,
/// The obfuscated unique ID of the user.
#[serde(rename="userId")]
pub user_id: Option<String>,
/// A current verification code for the user. Invalidated or used verification codes are not returned as part of the result.
#[serde(rename="verificationCode")]
pub verification_code: Option<String>,
}
impl Resource for VerificationCode {}
/// Indexing spec for a numeric field. By default, only exact match queries will be supported for numeric fields. Setting the numericIndexingSpec allows range queries to be supported.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct SchemaFieldSpecNumericIndexingSpec {
/// Maximum value of this field. This is meant to be indicative rather than enforced. Values outside this range will still be indexed, but search may not be as performant.
#[serde(rename="maxValue")]
pub max_value: f64,
/// Minimum value of this field. This is meant to be indicative rather than enforced. Values outside this range will still be indexed, but search may not be as performant.
#[serde(rename="minValue")]
pub min_value: f64,
}
impl NestedType for SchemaFieldSpecNumericIndexingSpec {}
impl Part for SchemaFieldSpecNumericIndexingSpec {}
/// JSON response template for List Schema operation in Directory API.
///
/// # 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 schemas](struct.SchemaListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Schemas {
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// List of UserSchema objects.
pub schemas: Vec<Schema>,
}
impl ResponseResult for Schemas {}
/// JSON response template to list aliases in Directory API.
///
/// # 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*).
///
/// * [aliases list users](struct.UserAliaseListCall.html) (response)
/// * [aliases list groups](struct.GroupAliaseListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Aliases {
/// Kind of resource this is.
pub kind: String,
/// ETag of the resource.
pub etag: String,
/// List of alias objects.
pub aliases: Vec<Alias>,
}
impl ResponseResult for Aliases {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *token* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.tokens();
/// # }
/// ```
pub struct TokenMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for TokenMethods<'a, C, A> {}
impl<'a, C, A> TokenMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Get information about an access token issued by a user.
///
/// # Arguments
///
/// * `userKey` - Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
/// * `clientId` - The Client ID of the application the token is issued to.
pub fn get(&self, user_key: &str, client_id: &str) -> TokenGetCall<'a, C, A> {
TokenGetCall {
hub: self.hub,
_user_key: user_key.to_string(),
_client_id: client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns the set of tokens specified user has issued to 3rd party applications.
///
/// # Arguments
///
/// * `userKey` - Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn list(&self, user_key: &str) -> TokenListCall<'a, C, A> {
TokenListCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Delete all access tokens issued by a user for an application.
///
/// # Arguments
///
/// * `userKey` - Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
/// * `clientId` - The Client ID of the application the token is issued to.
pub fn delete(&self, user_key: &str, client_id: &str) -> TokenDeleteCall<'a, C, A> {
TokenDeleteCall {
hub: self.hub,
_user_key: user_key.to_string(),
_client_id: client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *channel* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `stop(...)`
/// // to build up your call.
/// let rb = hub.channels();
/// # }
/// ```
pub struct ChannelMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for ChannelMethods<'a, C, A> {}
impl<'a, C, A> ChannelMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Stop watching resources through this channel
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn stop(&self, request: &Channel) -> ChannelStopCall<'a, C, A> {
ChannelStopCall {
hub: self.hub,
_request: request.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *orgunit* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.orgunits();
/// # }
/// ```
pub struct OrgunitMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for OrgunitMethods<'a, C, A> {}
impl<'a, C, A> OrgunitMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Add Organization Unit
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
pub fn insert(&self, request: &OrgUnit, customer_id: &str) -> OrgunitInsertCall<'a, C, A> {
OrgunitInsertCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve all Organization Units
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
pub fn list(&self, customer_id: &str) -> OrgunitListCall<'a, C, A> {
OrgunitListCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_type_: Default::default(),
_org_unit_path: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve Organization Unit
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
/// * `orgUnitPath` - Full path of the organization unit or its Id
pub fn get(&self, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitGetCall<'a, C, A> {
OrgunitGetCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_org_unit_path: org_unit_path.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update Organization Unit
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
/// * `orgUnitPath` - Full path of the organization unit or its Id
pub fn update(&self, request: &OrgUnit, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitUpdateCall<'a, C, A> {
OrgunitUpdateCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_org_unit_path: org_unit_path.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Remove Organization Unit
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
/// * `orgUnitPath` - Full path of the organization unit or its Id
pub fn delete(&self, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitDeleteCall<'a, C, A> {
OrgunitDeleteCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_org_unit_path: org_unit_path.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update Organization Unit. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
/// * `orgUnitPath` - Full path of the organization unit or its Id
pub fn patch(&self, request: &OrgUnit, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitPatchCall<'a, C, A> {
OrgunitPatchCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_org_unit_path: org_unit_path.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *user* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `aliases_delete(...)`, `aliases_insert(...)`, `aliases_list(...)`, `aliases_watch(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `make_admin(...)`, `patch(...)`, `photos_delete(...)`, `photos_get(...)`, `photos_patch(...)`, `photos_update(...)`, `undelete(...)`, `update(...)` and `watch(...)`
/// // to build up your call.
/// let rb = hub.users();
/// # }
/// ```
pub struct UserMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for UserMethods<'a, C, A> {}
impl<'a, C, A> UserMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// create user.
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn insert(&self, request: &User) -> UserInsertCall<'a, C, A> {
UserInsertCall {
hub: self.hub,
_request: request.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Remove photos for the user
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
pub fn photos_delete(&self, user_key: &str) -> UserPhotoDeleteCall<'a, C, A> {
UserPhotoDeleteCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Undelete a deleted user
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - The immutable id of the user
pub fn undelete(&self, request: &UserUndelete, user_key: &str) -> UserUndeleteCall<'a, C, A> {
UserUndeleteCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// change admin status of a user
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - Email or immutable Id of the user as admin
pub fn make_admin(&self, request: &UserMakeAdmin, user_key: &str) -> UserMakeAdminCall<'a, C, A> {
UserMakeAdminCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// update user. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - Email or immutable Id of the user. If Id, it should match with id of user object
pub fn patch(&self, request: &User, user_key: &str) -> UserPatchCall<'a, C, A> {
UserPatchCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Watch for changes in users list
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn watch(&self, request: &Channel) -> UserWatchCall<'a, C, A> {
UserWatchCall {
hub: self.hub,
_request: request.clone(),
_view_type: Default::default(),
_sort_order: Default::default(),
_show_deleted: Default::default(),
_query: Default::default(),
_projection: Default::default(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_event: Default::default(),
_domain: Default::default(),
_customer: Default::default(),
_custom_field_mask: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Delete user
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
pub fn delete(&self, user_key: &str) -> UserDeleteCall<'a, C, A> {
UserDeleteCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Add a photo for the user
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - Email or immutable Id of the user
pub fn photos_update(&self, request: &UserPhoto, user_key: &str) -> UserPhotoUpdateCall<'a, C, A> {
UserPhotoUpdateCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// retrieve user
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
pub fn get(&self, user_key: &str) -> UserGetCall<'a, C, A> {
UserGetCall {
hub: self.hub,
_user_key: user_key.to_string(),
_view_type: Default::default(),
_projection: Default::default(),
_custom_field_mask: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Add a alias for the user
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - Email or immutable Id of the user
pub fn aliases_insert(&self, request: &Alias, user_key: &str) -> UserAliaseInsertCall<'a, C, A> {
UserAliaseInsertCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve either deleted users or all users in a domain (paginated)
pub fn list(&self) -> UserListCall<'a, C, A> {
UserListCall {
hub: self.hub,
_view_type: Default::default(),
_sort_order: Default::default(),
_show_deleted: Default::default(),
_query: Default::default(),
_projection: Default::default(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_event: Default::default(),
_domain: Default::default(),
_customer: Default::default(),
_custom_field_mask: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Remove a alias for the user
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
/// * `alias` - The alias to be removed
pub fn aliases_delete(&self, user_key: &str, alias: &str) -> UserAliaseDeleteCall<'a, C, A> {
UserAliaseDeleteCall {
hub: self.hub,
_user_key: user_key.to_string(),
_alias: alias.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// update user
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - Email or immutable Id of the user. If Id, it should match with id of user object
pub fn update(&self, request: &User, user_key: &str) -> UserUpdateCall<'a, C, A> {
UserUpdateCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Watch for changes in user aliases list
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - Email or immutable Id of the user
pub fn aliases_watch(&self, request: &Channel, user_key: &str) -> UserAliaseWatchCall<'a, C, A> {
UserAliaseWatchCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_event: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List all aliases for a user
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
pub fn aliases_list(&self, user_key: &str) -> UserAliaseListCall<'a, C, A> {
UserAliaseListCall {
hub: self.hub,
_user_key: user_key.to_string(),
_event: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve photo of a user
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
pub fn photos_get(&self, user_key: &str) -> UserPhotoGetCall<'a, C, A> {
UserPhotoGetCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Add a photo for the user. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `userKey` - Email or immutable Id of the user
pub fn photos_patch(&self, request: &UserPhoto, user_key: &str) -> UserPhotoPatchCall<'a, C, A> {
UserPhotoPatchCall {
hub: self.hub,
_request: request.clone(),
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *mobiledevice* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `action(...)`, `delete(...)`, `get(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.mobiledevices();
/// # }
/// ```
pub struct MobiledeviceMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for MobiledeviceMethods<'a, C, A> {}
impl<'a, C, A> MobiledeviceMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Delete Mobile Device
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
/// * `resourceId` - Immutable id of Mobile Device
pub fn delete(&self, customer_id: &str, resource_id: &str) -> MobiledeviceDeleteCall<'a, C, A> {
MobiledeviceDeleteCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_resource_id: resource_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve Mobile Device
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
/// * `resourceId` - Immutable id of Mobile Device
pub fn get(&self, customer_id: &str, resource_id: &str) -> MobiledeviceGetCall<'a, C, A> {
MobiledeviceGetCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_resource_id: resource_id.to_string(),
_projection: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve all Mobile Devices of a customer (paginated)
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
pub fn list(&self, customer_id: &str) -> MobiledeviceListCall<'a, C, A> {
MobiledeviceListCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_sort_order: Default::default(),
_query: Default::default(),
_projection: Default::default(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Take action on Mobile Device
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
/// * `resourceId` - Immutable id of Mobile Device
pub fn action(&self, request: &MobileDeviceAction, customer_id: &str, resource_id: &str) -> MobiledeviceActionCall<'a, C, A> {
MobiledeviceActionCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_resource_id: resource_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *member* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.members();
/// # }
/// ```
pub struct MemberMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for MemberMethods<'a, C, A> {}
impl<'a, C, A> MemberMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Update membership of a user in the specified group.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object
/// * `memberKey` - Email or immutable Id of the user. If Id, it should match with id of member object
pub fn update(&self, request: &Member, group_key: &str, member_key: &str) -> MemberUpdateCall<'a, C, A> {
MemberUpdateCall {
hub: self.hub,
_request: request.clone(),
_group_key: group_key.to_string(),
_member_key: member_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve Group Member
///
/// # Arguments
///
/// * `groupKey` - Email or immutable Id of the group
/// * `memberKey` - Email or immutable Id of the member
pub fn get(&self, group_key: &str, member_key: &str) -> MemberGetCall<'a, C, A> {
MemberGetCall {
hub: self.hub,
_group_key: group_key.to_string(),
_member_key: member_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Add user to the specified group.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `groupKey` - Email or immutable Id of the group
pub fn insert(&self, request: &Member, group_key: &str) -> MemberInsertCall<'a, C, A> {
MemberInsertCall {
hub: self.hub,
_request: request.clone(),
_group_key: group_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update membership of a user in the specified group. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object
/// * `memberKey` - Email or immutable Id of the user. If Id, it should match with id of member object
pub fn patch(&self, request: &Member, group_key: &str, member_key: &str) -> MemberPatchCall<'a, C, A> {
MemberPatchCall {
hub: self.hub,
_request: request.clone(),
_group_key: group_key.to_string(),
_member_key: member_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Remove membership.
///
/// # Arguments
///
/// * `groupKey` - Email or immutable Id of the group
/// * `memberKey` - Email or immutable Id of the member
pub fn delete(&self, group_key: &str, member_key: &str) -> MemberDeleteCall<'a, C, A> {
MemberDeleteCall {
hub: self.hub,
_group_key: group_key.to_string(),
_member_key: member_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve all members in a group (paginated)
///
/// # Arguments
///
/// * `groupKey` - Email or immutable Id of the group
pub fn list(&self, group_key: &str) -> MemberListCall<'a, C, A> {
MemberListCall {
hub: self.hub,
_group_key: group_key.to_string(),
_roles: Default::default(),
_page_token: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *notification* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.notifications();
/// # }
/// ```
pub struct NotificationMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for NotificationMethods<'a, C, A> {}
impl<'a, C, A> NotificationMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Retrieves a list of notifications.
///
/// # Arguments
///
/// * `customer` - The unique ID for the customer's Google account.
pub fn list(&self, customer: &str) -> NotificationListCall<'a, C, A> {
NotificationListCall {
hub: self.hub,
_customer: customer.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_language: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes a notification
///
/// # Arguments
///
/// * `customer` - The unique ID for the customer's Google account. The customerId is also returned as part of the Users resource.
/// * `notificationId` - The unique ID of the notification.
pub fn delete(&self, customer: &str, notification_id: &str) -> NotificationDeleteCall<'a, C, A> {
NotificationDeleteCall {
hub: self.hub,
_customer: customer.to_string(),
_notification_id: notification_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a notification. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customer` - The unique ID for the customer's Google account.
/// * `notificationId` - The unique ID of the notification.
pub fn patch(&self, request: &Notification, customer: &str, notification_id: &str) -> NotificationPatchCall<'a, C, A> {
NotificationPatchCall {
hub: self.hub,
_request: request.clone(),
_customer: customer.to_string(),
_notification_id: notification_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a notification.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customer` - The unique ID for the customer's Google account.
/// * `notificationId` - The unique ID of the notification.
pub fn update(&self, request: &Notification, customer: &str, notification_id: &str) -> NotificationUpdateCall<'a, C, A> {
NotificationUpdateCall {
hub: self.hub,
_request: request.clone(),
_customer: customer.to_string(),
_notification_id: notification_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves a notification.
///
/// # Arguments
///
/// * `customer` - The unique ID for the customer's Google account. The customerId is also returned as part of the Users resource.
/// * `notificationId` - The unique ID of the notification.
pub fn get(&self, customer: &str, notification_id: &str) -> NotificationGetCall<'a, C, A> {
NotificationGetCall {
hub: self.hub,
_customer: customer.to_string(),
_notification_id: notification_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *chromeosdevice* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.chromeosdevices();
/// # }
/// ```
pub struct ChromeosdeviceMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for ChromeosdeviceMethods<'a, C, A> {}
impl<'a, C, A> ChromeosdeviceMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Retrieve all Chrome OS Devices of a customer (paginated)
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
pub fn list(&self, customer_id: &str) -> ChromeosdeviceListCall<'a, C, A> {
ChromeosdeviceListCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_sort_order: Default::default(),
_query: Default::default(),
_projection: Default::default(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update Chrome OS Device. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
/// * `deviceId` - Immutable id of Chrome OS Device
pub fn patch(&self, request: &ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdevicePatchCall<'a, C, A> {
ChromeosdevicePatchCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_device_id: device_id.to_string(),
_projection: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve Chrome OS Device
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
/// * `deviceId` - Immutable id of Chrome OS Device
pub fn get(&self, customer_id: &str, device_id: &str) -> ChromeosdeviceGetCall<'a, C, A> {
ChromeosdeviceGetCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_device_id: device_id.to_string(),
_projection: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update Chrome OS Device
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
/// * `deviceId` - Immutable id of Chrome OS Device
pub fn update(&self, request: &ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
ChromeosdeviceUpdateCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_device_id: device_id.to_string(),
_projection: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *verificationCode* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `generate(...)`, `invalidate(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.verification_codes();
/// # }
/// ```
pub struct VerificationCodeMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for VerificationCodeMethods<'a, C, A> {}
impl<'a, C, A> VerificationCodeMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Generate new backup verification codes for the user.
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
pub fn generate(&self, user_key: &str) -> VerificationCodeGenerateCall<'a, C, A> {
VerificationCodeGenerateCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Invalidate the current backup verification codes for the user.
///
/// # Arguments
///
/// * `userKey` - Email or immutable Id of the user
pub fn invalidate(&self, user_key: &str) -> VerificationCodeInvalidateCall<'a, C, A> {
VerificationCodeInvalidateCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns the current set of valid backup verification codes for the specified user.
///
/// # Arguments
///
/// * `userKey` - Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn list(&self, user_key: &str) -> VerificationCodeListCall<'a, C, A> {
VerificationCodeListCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *group* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `aliases_delete(...)`, `aliases_insert(...)`, `aliases_list(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.groups();
/// # }
/// ```
pub struct GroupMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for GroupMethods<'a, C, A> {}
impl<'a, C, A> GroupMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Retrieve Group
///
/// # Arguments
///
/// * `groupKey` - Email or immutable Id of the group
pub fn get(&self, group_key: &str) -> GroupGetCall<'a, C, A> {
GroupGetCall {
hub: self.hub,
_group_key: group_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve all groups in a domain (paginated)
pub fn list(&self) -> GroupListCall<'a, C, A> {
GroupListCall {
hub: self.hub,
_user_key: Default::default(),
_page_token: Default::default(),
_max_results: Default::default(),
_domain: Default::default(),
_customer: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List all aliases for a group
///
/// # Arguments
///
/// * `groupKey` - Email or immutable Id of the group
pub fn aliases_list(&self, group_key: &str) -> GroupAliaseListCall<'a, C, A> {
GroupAliaseListCall {
hub: self.hub,
_group_key: group_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update Group. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object
pub fn patch(&self, request: &Group, group_key: &str) -> GroupPatchCall<'a, C, A> {
GroupPatchCall {
hub: self.hub,
_request: request.clone(),
_group_key: group_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update Group
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `groupKey` - Email or immutable Id of the group. If Id, it should match with id of group object
pub fn update(&self, request: &Group, group_key: &str) -> GroupUpdateCall<'a, C, A> {
GroupUpdateCall {
hub: self.hub,
_request: request.clone(),
_group_key: group_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Delete Group
///
/// # Arguments
///
/// * `groupKey` - Email or immutable Id of the group
pub fn delete(&self, group_key: &str) -> GroupDeleteCall<'a, C, A> {
GroupDeleteCall {
hub: self.hub,
_group_key: group_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Add a alias for the group
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `groupKey` - Email or immutable Id of the group
pub fn aliases_insert(&self, request: &Alias, group_key: &str) -> GroupAliaseInsertCall<'a, C, A> {
GroupAliaseInsertCall {
hub: self.hub,
_request: request.clone(),
_group_key: group_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Remove a alias for the group
///
/// # Arguments
///
/// * `groupKey` - Email or immutable Id of the group
/// * `alias` - The alias to be removed
pub fn aliases_delete(&self, group_key: &str, alias: &str) -> GroupAliaseDeleteCall<'a, C, A> {
GroupAliaseDeleteCall {
hub: self.hub,
_group_key: group_key.to_string(),
_alias: alias.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Create Group
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn insert(&self, request: &Group) -> GroupInsertCall<'a, C, A> {
GroupInsertCall {
hub: self.hub,
_request: request.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *asp* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.asps();
/// # }
/// ```
pub struct AspMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for AspMethods<'a, C, A> {}
impl<'a, C, A> AspMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Delete an ASP issued by a user.
///
/// # Arguments
///
/// * `userKey` - Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
/// * `codeId` - The unique ID of the ASP to be deleted.
pub fn delete(&self, user_key: &str, code_id: i32) -> AspDeleteCall<'a, C, A> {
AspDeleteCall {
hub: self.hub,
_user_key: user_key.to_string(),
_code_id: code_id,
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List the ASPs issued by a user.
///
/// # Arguments
///
/// * `userKey` - Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn list(&self, user_key: &str) -> AspListCall<'a, C, A> {
AspListCall {
hub: self.hub,
_user_key: user_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get information about an ASP issued by a user.
///
/// # Arguments
///
/// * `userKey` - Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
/// * `codeId` - The unique ID of the ASP.
pub fn get(&self, user_key: &str, code_id: i32) -> AspGetCall<'a, C, A> {
AspGetCall {
hub: self.hub,
_user_key: user_key.to_string(),
_code_id: code_id,
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *schema* resources.
/// It is not used directly, but through the `Directory` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_admin1_directory as admin1_directory;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use admin1_directory::Directory;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = Directory::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.schemas();
/// # }
/// ```
pub struct SchemaMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
}
impl<'a, C, A> MethodsBuilder for SchemaMethods<'a, C, A> {}
impl<'a, C, A> SchemaMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Retrieve all schemas for a customer
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
pub fn list(&self, customer_id: &str) -> SchemaListCall<'a, C, A> {
SchemaListCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieve schema
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
/// * `schemaKey` - Name or immutable Id of the schema
pub fn get(&self, customer_id: &str, schema_key: &str) -> SchemaGetCall<'a, C, A> {
SchemaGetCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_schema_key: schema_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update schema. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
/// * `schemaKey` - Name or immutable Id of the schema.
pub fn patch(&self, request: &Schema, customer_id: &str, schema_key: &str) -> SchemaPatchCall<'a, C, A> {
SchemaPatchCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_schema_key: schema_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Create schema.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
pub fn insert(&self, request: &Schema, customer_id: &str) -> SchemaInsertCall<'a, C, A> {
SchemaInsertCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Delete schema
///
/// # Arguments
///
/// * `customerId` - Immutable id of the Google Apps account
/// * `schemaKey` - Name or immutable Id of the schema
pub fn delete(&self, customer_id: &str, schema_key: &str) -> SchemaDeleteCall<'a, C, A> {
SchemaDeleteCall {
hub: self.hub,
_customer_id: customer_id.to_string(),
_schema_key: schema_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update schema
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `customerId` - Immutable id of the Google Apps account
/// * `schemaKey` - Name or immutable Id of the schema.
pub fn update(&self, request: &Schema, customer_id: &str, schema_key: &str) -> SchemaUpdateCall<'a, C, A> {
SchemaUpdateCall {
hub: self.hub,
_request: request.clone(),
_customer_id: customer_id.to_string(),
_schema_key: schema_key.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
/// Get information about an access token issued by a user.
///
/// A builder for the *get* method supported by a *token* resource.
/// It is not used directly, but through a `TokenMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.tokens().get("userKey", "clientId")
/// .doit();
/// # }
/// ```
pub struct TokenGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for TokenGetCall<'a, C, A> {}
impl<'a, C, A> TokenGetCall<'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, Token)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.tokens.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
params.push(("clientId", self._client_id.to_string()));
for &field in ["alt", "userKey", "clientId"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/tokens/{clientId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey"), ("{clientId}", "clientId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["userKey", "clientId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn user_key(mut self, new_value: &str) -> TokenGetCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *client 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.
///
/// The Client ID of the application the token is issued to.
pub fn client_id(mut self, new_value: &str) -> TokenGetCall<'a, C, A> {
self._client_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> TokenGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> TokenGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> TokenGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Returns the set of tokens specified user has issued to 3rd party applications.
///
/// A builder for the *list* method supported by a *token* resource.
/// It is not used directly, but through a `TokenMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.tokens().list("userKey")
/// .doit();
/// # }
/// ```
pub struct TokenListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for TokenListCall<'a, C, A> {}
impl<'a, C, A> TokenListCall<'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, Tokens)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.tokens.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/tokens".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn user_key(mut self, new_value: &str) -> TokenListCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> TokenListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> TokenListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> TokenListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Delete all access tokens issued by a user for an application.
///
/// A builder for the *delete* method supported by a *token* resource.
/// It is not used directly, but through a `TokenMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.tokens().delete("userKey", "clientId")
/// .doit();
/// # }
/// ```
pub struct TokenDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for TokenDeleteCall<'a, C, A> {}
impl<'a, C, A> TokenDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.tokens.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
params.push(("clientId", self._client_id.to_string()));
for &field in ["userKey", "clientId"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/tokens/{clientId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey"), ("{clientId}", "clientId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["userKey", "clientId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn user_key(mut self, new_value: &str) -> TokenDeleteCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *client 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.
///
/// The Client ID of the application the token is issued to.
pub fn client_id(mut self, new_value: &str) -> TokenDeleteCall<'a, C, A> {
self._client_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> TokenDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> TokenDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> TokenDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Stop watching resources through this channel
///
/// A builder for the *stop* method supported by a *channel* resource.
/// It is not used directly, but through a `ChannelMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Channel;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Channel = Default::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.channels().stop(&req)
/// .doit();
/// # }
/// ```
pub struct ChannelStopCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Channel,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for ChannelStopCall<'a, C, A> {}
impl<'a, C, A> ChannelStopCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "admin.channels.stop",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
for &field in [].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1//admin/directory_v1/channels/stop".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
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: &Channel) -> ChannelStopCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ChannelStopCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ChannelStopCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Add Organization Unit
///
/// A builder for the *insert* method supported by a *orgunit* resource.
/// It is not used directly, but through a `OrgunitMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::OrgUnit;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: OrgUnit = Default::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.orgunits().insert(&req, "customerId")
/// .doit();
/// # }
/// ```
pub struct OrgunitInsertCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: OrgUnit,
_customer_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrgunitInsertCall<'a, C, A> {}
impl<'a, C, A> OrgunitInsertCall<'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, OrgUnit)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.orgunits.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
for &field in ["alt", "customerId"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/orgunits".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["customerId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &OrgUnit) -> OrgunitInsertCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> OrgunitInsertCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrgunitInsertCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrgunitInsertCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> OrgunitInsertCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve all Organization Units
///
/// A builder for the *list* method supported by a *orgunit* resource.
/// It is not used directly, but through a `OrgunitMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.orgunits().list("customerId")
/// .type_("dolore")
/// .org_unit_path("invidunt")
/// .doit();
/// # }
/// ```
pub struct OrgunitListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_type_: Option<String>,
_org_unit_path: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrgunitListCall<'a, C, A> {}
impl<'a, C, A> OrgunitListCall<'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, OrgUnits)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.orgunits.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
if let Some(value) = self._type_ {
params.push(("type", value.to_string()));
}
if let Some(value) = self._org_unit_path {
params.push(("orgUnitPath", value.to_string()));
}
for &field in ["alt", "customerId", "type", "orgUnitPath"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/orgunits".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["customerId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> OrgunitListCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *type* query property to the given value.
///
///
/// Whether to return all sub-organizations or just immediate children
pub fn type_(mut self, new_value: &str) -> OrgunitListCall<'a, C, A> {
self._type_ = Some(new_value.to_string());
self
}
/// Sets the *org unit path* query property to the given value.
///
///
/// the URL-encoded organization unit's path or its Id
pub fn org_unit_path(mut self, new_value: &str) -> OrgunitListCall<'a, C, A> {
self._org_unit_path = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrgunitListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrgunitListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> OrgunitListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve Organization Unit
///
/// A builder for the *get* method supported by a *orgunit* resource.
/// It is not used directly, but through a `OrgunitMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.orgunits().get("customerId", "orgUnitPath")
/// .doit();
/// # }
/// ```
pub struct OrgunitGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_org_unit_path: Vec<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrgunitGetCall<'a, C, A> {}
impl<'a, C, A> OrgunitGetCall<'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, OrgUnit)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.orgunits.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
if self._org_unit_path.len() > 0 {
let mut s = String::new();
for f in self._org_unit_path.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("orgUnitPath", s));
}
for &field in ["alt", "customerId", "orgUnitPath"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/orgunits{/orgUnitPath*}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "orgUnitPath"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> OrgunitGetCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Append the given value to the *org unit path* path property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Full path of the organization unit or its Id
pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitGetCall<'a, C, A> {
self._org_unit_path.push(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrgunitGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrgunitGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> OrgunitGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update Organization Unit
///
/// A builder for the *update* method supported by a *orgunit* resource.
/// It is not used directly, but through a `OrgunitMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::OrgUnit;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: OrgUnit = Default::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.orgunits().update(&req, "customerId", "orgUnitPath")
/// .doit();
/// # }
/// ```
pub struct OrgunitUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: OrgUnit,
_customer_id: String,
_org_unit_path: Vec<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrgunitUpdateCall<'a, C, A> {}
impl<'a, C, A> OrgunitUpdateCall<'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, OrgUnit)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.orgunits.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
if self._org_unit_path.len() > 0 {
let mut s = String::new();
for f in self._org_unit_path.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("orgUnitPath", s));
}
for &field in ["alt", "customerId", "orgUnitPath"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/orgunits{/orgUnitPath*}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "orgUnitPath"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &OrgUnit) -> OrgunitUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> OrgunitUpdateCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Append the given value to the *org unit path* path property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Full path of the organization unit or its Id
pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitUpdateCall<'a, C, A> {
self._org_unit_path.push(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrgunitUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrgunitUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> OrgunitUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Remove Organization Unit
///
/// A builder for the *delete* method supported by a *orgunit* resource.
/// It is not used directly, but through a `OrgunitMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.orgunits().delete("customerId", "orgUnitPath")
/// .doit();
/// # }
/// ```
pub struct OrgunitDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_org_unit_path: Vec<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrgunitDeleteCall<'a, C, A> {}
impl<'a, C, A> OrgunitDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.orgunits.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
if self._org_unit_path.len() > 0 {
let mut s = String::new();
for f in self._org_unit_path.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("orgUnitPath", s));
}
for &field in ["customerId", "orgUnitPath"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/orgunits{/orgUnitPath*}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "orgUnitPath"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> OrgunitDeleteCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Append the given value to the *org unit path* path property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Full path of the organization unit or its Id
pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitDeleteCall<'a, C, A> {
self._org_unit_path.push(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrgunitDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrgunitDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> OrgunitDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update Organization Unit. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *orgunit* resource.
/// It is not used directly, but through a `OrgunitMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::OrgUnit;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: OrgUnit = Default::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.orgunits().patch(&req, "customerId", "orgUnitPath")
/// .doit();
/// # }
/// ```
pub struct OrgunitPatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: OrgUnit,
_customer_id: String,
_org_unit_path: Vec<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrgunitPatchCall<'a, C, A> {}
impl<'a, C, A> OrgunitPatchCall<'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, OrgUnit)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.orgunits.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
if self._org_unit_path.len() > 0 {
let mut s = String::new();
for f in self._org_unit_path.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("orgUnitPath", s));
}
for &field in ["alt", "customerId", "orgUnitPath"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/orgunits{/orgUnitPath*}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "orgUnitPath"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &OrgUnit) -> OrgunitPatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> OrgunitPatchCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Append the given value to the *org unit path* path property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Full path of the organization unit or its Id
pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitPatchCall<'a, C, A> {
self._org_unit_path.push(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrgunitPatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrgunitPatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> OrgunitPatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// create user.
///
/// A builder for the *insert* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::User;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: User = Default::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.users().insert(&req)
/// .doit();
/// # }
/// ```
pub struct UserInsertCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: User,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserInsertCall<'a, C, A> {}
impl<'a, C, A> UserInsertCall<'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, User)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
for &field in ["alt"].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 = "https://www.googleapis.com/admin/directory/v1/users".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &User) -> UserInsertCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserInsertCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserInsertCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserInsertCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Remove photos for the user
///
/// A builder for the *photos.delete* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.users().photos_delete("userKey")
/// .doit();
/// # }
/// ```
pub struct UserPhotoDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserPhotoDeleteCall<'a, C, A> {}
impl<'a, C, A> UserPhotoDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.photos.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["userKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/photos/thumbnail".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserPhotoDeleteCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserPhotoDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserPhotoDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserPhotoDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Undelete a deleted user
///
/// A builder for the *undelete* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::UserUndelete;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: UserUndelete = Default::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.users().undelete(&req, "userKey")
/// .doit();
/// # }
/// ```
pub struct UserUndeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: UserUndelete,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserUndeleteCall<'a, C, A> {}
impl<'a, C, A> UserUndeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.undelete",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["userKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/undelete".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
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: &UserUndelete) -> UserUndeleteCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// The immutable id of the user
pub fn user_key(mut self, new_value: &str) -> UserUndeleteCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserUndeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserUndeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserUndeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// change admin status of a user
///
/// A builder for the *makeAdmin* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::UserMakeAdmin;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: UserMakeAdmin = Default::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.users().make_admin(&req, "userKey")
/// .doit();
/// # }
/// ```
pub struct UserMakeAdminCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: UserMakeAdmin,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserMakeAdminCall<'a, C, A> {}
impl<'a, C, A> UserMakeAdminCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.makeAdmin",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["userKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/makeAdmin".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
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: &UserMakeAdmin) -> UserMakeAdminCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user as admin
pub fn user_key(mut self, new_value: &str) -> UserMakeAdminCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserMakeAdminCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserMakeAdminCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserMakeAdminCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// update user. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::User;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: User = Default::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.users().patch(&req, "userKey")
/// .doit();
/// # }
/// ```
pub struct UserPatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: User,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserPatchCall<'a, C, A> {}
impl<'a, C, A> UserPatchCall<'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, User)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &User) -> UserPatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user. If Id, it should match with id of user object
pub fn user_key(mut self, new_value: &str) -> UserPatchCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserPatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserPatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserPatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Watch for changes in users list
///
/// A builder for the *watch* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Channel;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Channel = Default::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.users().watch(&req)
/// .view_type("consetetur")
/// .sort_order("ut")
/// .show_deleted("ea")
/// .query("sed")
/// .projection("dolor")
/// .page_token("dolor")
/// .order_by("dolor")
/// .max_results(-23)
/// .event("consetetur")
/// .domain("amet.")
/// .customer("voluptua.")
/// .custom_field_mask("Lorem")
/// .doit();
/// # }
/// ```
pub struct UserWatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Channel,
_view_type: Option<String>,
_sort_order: Option<String>,
_show_deleted: Option<String>,
_query: Option<String>,
_projection: Option<String>,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<i32>,
_event: Option<String>,
_domain: Option<String>,
_customer: Option<String>,
_custom_field_mask: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserWatchCall<'a, C, A> {}
impl<'a, C, A> UserWatchCall<'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, Channel)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.watch",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((15 + self._additional_params.len()));
if let Some(value) = self._view_type {
params.push(("viewType", value.to_string()));
}
if let Some(value) = self._sort_order {
params.push(("sortOrder", value.to_string()));
}
if let Some(value) = self._show_deleted {
params.push(("showDeleted", value.to_string()));
}
if let Some(value) = self._query {
params.push(("query", value.to_string()));
}
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._order_by {
params.push(("orderBy", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._event {
params.push(("event", value.to_string()));
}
if let Some(value) = self._domain {
params.push(("domain", value.to_string()));
}
if let Some(value) = self._customer {
params.push(("customer", value.to_string()));
}
if let Some(value) = self._custom_field_mask {
params.push(("customFieldMask", value.to_string()));
}
for &field in ["alt", "viewType", "sortOrder", "showDeleted", "query", "projection", "pageToken", "orderBy", "maxResults", "event", "domain", "customer", "customFieldMask"].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 = "https://www.googleapis.com/admin/directory/v1/users/watch".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Channel) -> UserWatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *view type* query property to the given value.
///
///
/// Whether to fetch the ADMIN_VIEW or DOMAIN_PUBLIC view of the user.
pub fn view_type(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._view_type = Some(new_value.to_string());
self
}
/// Sets the *sort order* query property to the given value.
///
///
/// Whether to return results in ascending or descending order.
pub fn sort_order(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._sort_order = Some(new_value.to_string());
self
}
/// Sets the *show deleted* query property to the given value.
///
///
/// If set to true retrieves the list of deleted users. Default is false
pub fn show_deleted(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._show_deleted = Some(new_value.to_string());
self
}
/// Sets the *query* query property to the given value.
///
///
/// Query string search. Should be of the form "". Complete documentation is at https://developers.google.com/admin-sdk/directory/v1/guides/search-users
pub fn query(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._query = Some(new_value.to_string());
self
}
/// Sets the *projection* query property to the given value.
///
///
/// What subset of fields to fetch for this user.
pub fn projection(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *page token* query property to the given value.
///
///
/// Token to specify next page in the list
pub fn page_token(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *order by* query property to the given value.
///
///
/// Column to use for sorting results
pub fn order_by(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._order_by = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// Maximum number of results to return. Default is 100. Max allowed is 500
pub fn max_results(mut self, new_value: i32) -> UserWatchCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *event* query property to the given value.
///
///
/// Event on which subscription is intended (if subscribing)
pub fn event(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._event = Some(new_value.to_string());
self
}
/// Sets the *domain* query property to the given value.
///
///
/// Name of the domain. Fill this field to get users from only this domain. To return all users in a multi-domain fill customer field instead.
pub fn domain(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._domain = Some(new_value.to_string());
self
}
/// Sets the *customer* query property to the given value.
///
///
/// Immutable id of the Google Apps account. In case of multi-domain, to fetch all users for a customer, fill this field instead of domain.
pub fn customer(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._customer = Some(new_value.to_string());
self
}
/// Sets the *custom field mask* query property to the given value.
///
///
/// Comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom.
pub fn custom_field_mask(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
self._custom_field_mask = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserWatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserWatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserWatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Delete user
///
/// A builder for the *delete* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.users().delete("userKey")
/// .doit();
/// # }
/// ```
pub struct UserDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserDeleteCall<'a, C, A> {}
impl<'a, C, A> UserDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["userKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserDeleteCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Add a photo for the user
///
/// A builder for the *photos.update* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::UserPhoto;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: UserPhoto = Default::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.users().photos_update(&req, "userKey")
/// .doit();
/// # }
/// ```
pub struct UserPhotoUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: UserPhoto,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserPhotoUpdateCall<'a, C, A> {}
impl<'a, C, A> UserPhotoUpdateCall<'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, UserPhoto)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.photos.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/photos/thumbnail".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &UserPhoto) -> UserPhotoUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserPhotoUpdateCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserPhotoUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserPhotoUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserPhotoUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// retrieve user
///
/// A builder for the *get* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.users().get("userKey")
/// .view_type("vero")
/// .projection("diam")
/// .custom_field_mask("rebum.")
/// .doit();
/// # }
/// ```
pub struct UserGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_view_type: Option<String>,
_projection: Option<String>,
_custom_field_mask: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserGetCall<'a, C, A> {}
impl<'a, C, A> UserGetCall<'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, User)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
if let Some(value) = self._view_type {
params.push(("viewType", value.to_string()));
}
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
if let Some(value) = self._custom_field_mask {
params.push(("customFieldMask", value.to_string()));
}
for &field in ["alt", "userKey", "viewType", "projection", "customFieldMask"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *view type* query property to the given value.
///
///
/// Whether to fetch the ADMIN_VIEW or DOMAIN_PUBLIC view of the user.
pub fn view_type(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
self._view_type = Some(new_value.to_string());
self
}
/// Sets the *projection* query property to the given value.
///
///
/// What subset of fields to fetch for this user.
pub fn projection(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *custom field mask* query property to the given value.
///
///
/// Comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom.
pub fn custom_field_mask(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
self._custom_field_mask = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Add a alias for the user
///
/// A builder for the *aliases.insert* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Alias;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Alias = Default::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.users().aliases_insert(&req, "userKey")
/// .doit();
/// # }
/// ```
pub struct UserAliaseInsertCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Alias,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserAliaseInsertCall<'a, C, A> {}
impl<'a, C, A> UserAliaseInsertCall<'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, Alias)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.aliases.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/aliases".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Alias) -> UserAliaseInsertCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserAliaseInsertCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserAliaseInsertCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserAliaseInsertCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserAliaseInsertCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve either deleted users or all users in a domain (paginated)
///
/// A builder for the *list* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.users().list()
/// .view_type("sadipscing")
/// .sort_order("vero")
/// .show_deleted("sadipscing")
/// .query("invidunt")
/// .projection("consetetur")
/// .page_token("dolore")
/// .order_by("duo")
/// .max_results(-82)
/// .event("Lorem")
/// .domain("et")
/// .customer("clita")
/// .custom_field_mask("consetetur")
/// .doit();
/// # }
/// ```
pub struct UserListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_view_type: Option<String>,
_sort_order: Option<String>,
_show_deleted: Option<String>,
_query: Option<String>,
_projection: Option<String>,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<i32>,
_event: Option<String>,
_domain: Option<String>,
_customer: Option<String>,
_custom_field_mask: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserListCall<'a, C, A> {}
impl<'a, C, A> UserListCall<'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, Users)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((14 + self._additional_params.len()));
if let Some(value) = self._view_type {
params.push(("viewType", value.to_string()));
}
if let Some(value) = self._sort_order {
params.push(("sortOrder", value.to_string()));
}
if let Some(value) = self._show_deleted {
params.push(("showDeleted", value.to_string()));
}
if let Some(value) = self._query {
params.push(("query", value.to_string()));
}
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._order_by {
params.push(("orderBy", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._event {
params.push(("event", value.to_string()));
}
if let Some(value) = self._domain {
params.push(("domain", value.to_string()));
}
if let Some(value) = self._customer {
params.push(("customer", value.to_string()));
}
if let Some(value) = self._custom_field_mask {
params.push(("customFieldMask", value.to_string()));
}
for &field in ["alt", "viewType", "sortOrder", "showDeleted", "query", "projection", "pageToken", "orderBy", "maxResults", "event", "domain", "customer", "customFieldMask"].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 = "https://www.googleapis.com/admin/directory/v1/users".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *view type* query property to the given value.
///
///
/// Whether to fetch the ADMIN_VIEW or DOMAIN_PUBLIC view of the user.
pub fn view_type(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._view_type = Some(new_value.to_string());
self
}
/// Sets the *sort order* query property to the given value.
///
///
/// Whether to return results in ascending or descending order.
pub fn sort_order(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._sort_order = Some(new_value.to_string());
self
}
/// Sets the *show deleted* query property to the given value.
///
///
/// If set to true retrieves the list of deleted users. Default is false
pub fn show_deleted(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._show_deleted = Some(new_value.to_string());
self
}
/// Sets the *query* query property to the given value.
///
///
/// Query string search. Should be of the form "". Complete documentation is at https://developers.google.com/admin-sdk/directory/v1/guides/search-users
pub fn query(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._query = Some(new_value.to_string());
self
}
/// Sets the *projection* query property to the given value.
///
///
/// What subset of fields to fetch for this user.
pub fn projection(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *page token* query property to the given value.
///
///
/// Token to specify next page in the list
pub fn page_token(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *order by* query property to the given value.
///
///
/// Column to use for sorting results
pub fn order_by(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._order_by = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// Maximum number of results to return. Default is 100. Max allowed is 500
pub fn max_results(mut self, new_value: i32) -> UserListCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *event* query property to the given value.
///
///
/// Event on which subscription is intended (if subscribing)
pub fn event(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._event = Some(new_value.to_string());
self
}
/// Sets the *domain* query property to the given value.
///
///
/// Name of the domain. Fill this field to get users from only this domain. To return all users in a multi-domain fill customer field instead.
pub fn domain(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._domain = Some(new_value.to_string());
self
}
/// Sets the *customer* query property to the given value.
///
///
/// Immutable id of the Google Apps account. In case of multi-domain, to fetch all users for a customer, fill this field instead of domain.
pub fn customer(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._customer = Some(new_value.to_string());
self
}
/// Sets the *custom field mask* query property to the given value.
///
///
/// Comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom.
pub fn custom_field_mask(mut self, new_value: &str) -> UserListCall<'a, C, A> {
self._custom_field_mask = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Remove a alias for the user
///
/// A builder for the *aliases.delete* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.users().aliases_delete("userKey", "alias")
/// .doit();
/// # }
/// ```
pub struct UserAliaseDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_alias: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserAliaseDeleteCall<'a, C, A> {}
impl<'a, C, A> UserAliaseDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.aliases.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
params.push(("alias", self._alias.to_string()));
for &field in ["userKey", "alias"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/aliases/{alias}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey"), ("{alias}", "alias")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["userKey", "alias"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserAliaseDeleteCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *alias* 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.
///
/// The alias to be removed
pub fn alias(mut self, new_value: &str) -> UserAliaseDeleteCall<'a, C, A> {
self._alias = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserAliaseDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserAliaseDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserAliaseDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// update user
///
/// A builder for the *update* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::User;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: User = Default::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.users().update(&req, "userKey")
/// .doit();
/// # }
/// ```
pub struct UserUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: User,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserUpdateCall<'a, C, A> {}
impl<'a, C, A> UserUpdateCall<'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, User)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &User) -> UserUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user. If Id, it should match with id of user object
pub fn user_key(mut self, new_value: &str) -> UserUpdateCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Watch for changes in user aliases list
///
/// A builder for the *aliases.watch* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Channel;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Channel = Default::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.users().aliases_watch(&req, "userKey")
/// .event("takimata")
/// .doit();
/// # }
/// ```
pub struct UserAliaseWatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Channel,
_user_key: String,
_event: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserAliaseWatchCall<'a, C, A> {}
impl<'a, C, A> UserAliaseWatchCall<'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, Channel)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.aliases.watch",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
if let Some(value) = self._event {
params.push(("event", value.to_string()));
}
for &field in ["alt", "userKey", "event"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/aliases/watch".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Channel) -> UserAliaseWatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserAliaseWatchCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *event* query property to the given value.
///
///
/// Event on which subscription is intended (if subscribing)
pub fn event(mut self, new_value: &str) -> UserAliaseWatchCall<'a, C, A> {
self._event = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserAliaseWatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserAliaseWatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserAliaseWatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// List all aliases for a user
///
/// A builder for the *aliases.list* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.users().aliases_list("userKey")
/// .event("labore")
/// .doit();
/// # }
/// ```
pub struct UserAliaseListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_event: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserAliaseListCall<'a, C, A> {}
impl<'a, C, A> UserAliaseListCall<'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, Aliases)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.aliases.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
if let Some(value) = self._event {
params.push(("event", value.to_string()));
}
for &field in ["alt", "userKey", "event"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/aliases".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserAliaseListCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *event* query property to the given value.
///
///
/// Event on which subscription is intended (if subscribing)
pub fn event(mut self, new_value: &str) -> UserAliaseListCall<'a, C, A> {
self._event = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserAliaseListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserAliaseListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserAliaseListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve photo of a user
///
/// A builder for the *photos.get* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.users().photos_get("userKey")
/// .doit();
/// # }
/// ```
pub struct UserPhotoGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserPhotoGetCall<'a, C, A> {}
impl<'a, C, A> UserPhotoGetCall<'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, UserPhoto)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.photos.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/photos/thumbnail".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserPhotoGetCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserPhotoGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserPhotoGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserPhotoGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Add a photo for the user. This method supports patch semantics.
///
/// A builder for the *photos.patch* method supported by a *user* resource.
/// It is not used directly, but through a `UserMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::UserPhoto;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: UserPhoto = Default::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.users().photos_patch(&req, "userKey")
/// .doit();
/// # }
/// ```
pub struct UserPhotoPatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: UserPhoto,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for UserPhotoPatchCall<'a, C, A> {}
impl<'a, C, A> UserPhotoPatchCall<'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, UserPhoto)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.users.photos.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/photos/thumbnail".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &UserPhoto) -> UserPhotoPatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> UserPhotoPatchCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserPhotoPatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> UserPhotoPatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> UserPhotoPatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Delete Mobile Device
///
/// A builder for the *delete* method supported by a *mobiledevice* resource.
/// It is not used directly, but through a `MobiledeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.mobiledevices().delete("customerId", "resourceId")
/// .doit();
/// # }
/// ```
pub struct MobiledeviceDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_resource_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MobiledeviceDeleteCall<'a, C, A> {}
impl<'a, C, A> MobiledeviceDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.mobiledevices.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("resourceId", self._resource_id.to_string()));
for &field in ["customerId", "resourceId"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/mobile/{resourceId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{resourceId}", "resourceId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "resourceId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> MobiledeviceDeleteCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *resource 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.
///
/// Immutable id of Mobile Device
pub fn resource_id(mut self, new_value: &str) -> MobiledeviceDeleteCall<'a, C, A> {
self._resource_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MobiledeviceDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MobiledeviceDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve Mobile Device
///
/// A builder for the *get* method supported by a *mobiledevice* resource.
/// It is not used directly, but through a `MobiledeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.mobiledevices().get("customerId", "resourceId")
/// .projection("sed")
/// .doit();
/// # }
/// ```
pub struct MobiledeviceGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_resource_id: String,
_projection: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MobiledeviceGetCall<'a, C, A> {}
impl<'a, C, A> MobiledeviceGetCall<'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, MobileDevice)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.mobiledevices.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("resourceId", self._resource_id.to_string()));
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
for &field in ["alt", "customerId", "resourceId", "projection"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/mobile/{resourceId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{resourceId}", "resourceId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "resourceId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> MobiledeviceGetCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *resource 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.
///
/// Immutable id of Mobile Device
pub fn resource_id(mut self, new_value: &str) -> MobiledeviceGetCall<'a, C, A> {
self._resource_id = new_value.to_string();
self
}
/// Sets the *projection* query property to the given value.
///
///
/// Restrict information returned to a set of selected fields.
pub fn projection(mut self, new_value: &str) -> MobiledeviceGetCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MobiledeviceGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MobiledeviceGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve all Mobile Devices of a customer (paginated)
///
/// A builder for the *list* method supported by a *mobiledevice* resource.
/// It is not used directly, but through a `MobiledeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.mobiledevices().list("customerId")
/// .sort_order("sit")
/// .query("eirmod")
/// .projection("consetetur")
/// .page_token("labore")
/// .order_by("sed")
/// .max_results(-16)
/// .doit();
/// # }
/// ```
pub struct MobiledeviceListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_sort_order: Option<String>,
_query: Option<String>,
_projection: Option<String>,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<i32>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MobiledeviceListCall<'a, C, A> {}
impl<'a, C, A> MobiledeviceListCall<'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, MobileDevices)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.mobiledevices.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
if let Some(value) = self._sort_order {
params.push(("sortOrder", value.to_string()));
}
if let Some(value) = self._query {
params.push(("query", value.to_string()));
}
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._order_by {
params.push(("orderBy", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
for &field in ["alt", "customerId", "sortOrder", "query", "projection", "pageToken", "orderBy", "maxResults"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/mobile".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["customerId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *sort order* query property to the given value.
///
///
/// Whether to return results in ascending or descending order. Only of use when orderBy is also used
pub fn sort_order(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
self._sort_order = Some(new_value.to_string());
self
}
/// Sets the *query* query property to the given value.
///
///
/// Search string in the format given at http://support.google.com/a/bin/answer.py?hl=en&answer=1408863#search
pub fn query(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
self._query = Some(new_value.to_string());
self
}
/// Sets the *projection* query property to the given value.
///
///
/// Restrict information returned to a set of selected fields.
pub fn projection(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *page token* query property to the given value.
///
///
/// Token to specify next page in the list
pub fn page_token(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *order by* query property to the given value.
///
///
/// Column to use for sorting results
pub fn order_by(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
self._order_by = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// Maximum number of results to return. Default is 100
pub fn max_results(mut self, new_value: i32) -> MobiledeviceListCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MobiledeviceListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MobiledeviceListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Take action on Mobile Device
///
/// A builder for the *action* method supported by a *mobiledevice* resource.
/// It is not used directly, but through a `MobiledeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::MobileDeviceAction;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: MobileDeviceAction = Default::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.mobiledevices().action(&req, "customerId", "resourceId")
/// .doit();
/// # }
/// ```
pub struct MobiledeviceActionCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: MobileDeviceAction,
_customer_id: String,
_resource_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MobiledeviceActionCall<'a, C, A> {}
impl<'a, C, A> MobiledeviceActionCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.mobiledevices.action",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("resourceId", self._resource_id.to_string()));
for &field in ["customerId", "resourceId"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/mobile/{resourceId}/action".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{resourceId}", "resourceId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "resourceId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
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: &MobileDeviceAction) -> MobiledeviceActionCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> MobiledeviceActionCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *resource 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.
///
/// Immutable id of Mobile Device
pub fn resource_id(mut self, new_value: &str) -> MobiledeviceActionCall<'a, C, A> {
self._resource_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MobiledeviceActionCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceActionCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MobiledeviceActionCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update membership of a user in the specified group.
///
/// A builder for the *update* method supported by a *member* resource.
/// It is not used directly, but through a `MemberMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Member;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Member = Default::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.members().update(&req, "groupKey", "memberKey")
/// .doit();
/// # }
/// ```
pub struct MemberUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Member,
_group_key: String,
_member_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MemberUpdateCall<'a, C, A> {}
impl<'a, C, A> MemberUpdateCall<'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, Member)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.members.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
params.push(("memberKey", self._member_key.to_string()));
for &field in ["alt", "groupKey", "memberKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/members/{memberKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["groupKey", "memberKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Member) -> MemberUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group. If Id, it should match with id of group object
pub fn group_key(mut self, new_value: &str) -> MemberUpdateCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *member key* 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.
///
/// Email or immutable Id of the user. If Id, it should match with id of member object
pub fn member_key(mut self, new_value: &str) -> MemberUpdateCall<'a, C, A> {
self._member_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MemberUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MemberUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MemberUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve Group Member
///
/// A builder for the *get* method supported by a *member* resource.
/// It is not used directly, but through a `MemberMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.members().get("groupKey", "memberKey")
/// .doit();
/// # }
/// ```
pub struct MemberGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_group_key: String,
_member_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MemberGetCall<'a, C, A> {}
impl<'a, C, A> MemberGetCall<'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, Member)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.members.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
params.push(("memberKey", self._member_key.to_string()));
for &field in ["alt", "groupKey", "memberKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/members/{memberKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["groupKey", "memberKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> MemberGetCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *member key* 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.
///
/// Email or immutable Id of the member
pub fn member_key(mut self, new_value: &str) -> MemberGetCall<'a, C, A> {
self._member_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MemberGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MemberGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MemberGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Add user to the specified group.
///
/// A builder for the *insert* method supported by a *member* resource.
/// It is not used directly, but through a `MemberMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Member;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Member = Default::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.members().insert(&req, "groupKey")
/// .doit();
/// # }
/// ```
pub struct MemberInsertCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Member,
_group_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MemberInsertCall<'a, C, A> {}
impl<'a, C, A> MemberInsertCall<'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, Member)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.members.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
for &field in ["alt", "groupKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/members".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Member) -> MemberInsertCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> MemberInsertCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MemberInsertCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MemberInsertCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MemberInsertCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update membership of a user in the specified group. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *member* resource.
/// It is not used directly, but through a `MemberMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Member;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Member = Default::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.members().patch(&req, "groupKey", "memberKey")
/// .doit();
/// # }
/// ```
pub struct MemberPatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Member,
_group_key: String,
_member_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MemberPatchCall<'a, C, A> {}
impl<'a, C, A> MemberPatchCall<'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, Member)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.members.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
params.push(("memberKey", self._member_key.to_string()));
for &field in ["alt", "groupKey", "memberKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/members/{memberKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["groupKey", "memberKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Member) -> MemberPatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group. If Id, it should match with id of group object
pub fn group_key(mut self, new_value: &str) -> MemberPatchCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *member key* 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.
///
/// Email or immutable Id of the user. If Id, it should match with id of member object
pub fn member_key(mut self, new_value: &str) -> MemberPatchCall<'a, C, A> {
self._member_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MemberPatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MemberPatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MemberPatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Remove membership.
///
/// A builder for the *delete* method supported by a *member* resource.
/// It is not used directly, but through a `MemberMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.members().delete("groupKey", "memberKey")
/// .doit();
/// # }
/// ```
pub struct MemberDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_group_key: String,
_member_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MemberDeleteCall<'a, C, A> {}
impl<'a, C, A> MemberDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.members.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
params.push(("memberKey", self._member_key.to_string()));
for &field in ["groupKey", "memberKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/members/{memberKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["groupKey", "memberKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> MemberDeleteCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *member key* 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.
///
/// Email or immutable Id of the member
pub fn member_key(mut self, new_value: &str) -> MemberDeleteCall<'a, C, A> {
self._member_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MemberDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MemberDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MemberDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve all members in a group (paginated)
///
/// A builder for the *list* method supported by a *member* resource.
/// It is not used directly, but through a `MemberMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.members().list("groupKey")
/// .roles("justo")
/// .page_token("est")
/// .max_results(-46)
/// .doit();
/// # }
/// ```
pub struct MemberListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_group_key: String,
_roles: Option<String>,
_page_token: Option<String>,
_max_results: Option<i32>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for MemberListCall<'a, C, A> {}
impl<'a, C, A> MemberListCall<'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, Members)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.members.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
if let Some(value) = self._roles {
params.push(("roles", value.to_string()));
}
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
for &field in ["alt", "groupKey", "roles", "pageToken", "maxResults"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/members".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> MemberListCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *roles* query property to the given value.
///
///
/// Comma separated role values to filter list results on.
pub fn roles(mut self, new_value: &str) -> MemberListCall<'a, C, A> {
self._roles = Some(new_value.to_string());
self
}
/// Sets the *page token* query property to the given value.
///
///
/// Token to specify next page in the list
pub fn page_token(mut self, new_value: &str) -> MemberListCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// Maximum number of results to return. Default is 200
pub fn max_results(mut self, new_value: i32) -> MemberListCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> MemberListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> MemberListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> MemberListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieves a list of notifications.
///
/// A builder for the *list* method supported by a *notification* resource.
/// It is not used directly, but through a `NotificationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.notifications().list("customer")
/// .page_token("clita")
/// .max_results(22)
/// .language("justo")
/// .doit();
/// # }
/// ```
pub struct NotificationListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_language: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for NotificationListCall<'a, C, A> {}
impl<'a, C, A> NotificationListCall<'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, Notifications)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.notifications.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
params.push(("customer", self._customer.to_string()));
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._language {
params.push(("language", value.to_string()));
}
for &field in ["alt", "customer", "pageToken", "maxResults", "language"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customer}/notifications".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customer}", "customer")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["customer"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer* 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.
///
/// The unique ID for the customer's Google account.
pub fn customer(mut self, new_value: &str) -> NotificationListCall<'a, C, A> {
self._customer = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
/// The token to specify the page of results to retrieve.
pub fn page_token(mut self, new_value: &str) -> NotificationListCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// Maximum number of notifications to return per page. The default is 100.
pub fn max_results(mut self, new_value: u32) -> NotificationListCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *language* query property to the given value.
///
///
/// The ISO 639-1 code of the language notifications are returned in. The default is English (en).
pub fn language(mut self, new_value: &str) -> NotificationListCall<'a, C, A> {
self._language = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> NotificationListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> NotificationListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> NotificationListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Deletes a notification
///
/// A builder for the *delete* method supported by a *notification* resource.
/// It is not used directly, but through a `NotificationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.notifications().delete("customer", "notificationId")
/// .doit();
/// # }
/// ```
pub struct NotificationDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer: String,
_notification_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for NotificationDeleteCall<'a, C, A> {}
impl<'a, C, A> NotificationDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.notifications.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("customer", self._customer.to_string()));
params.push(("notificationId", self._notification_id.to_string()));
for &field in ["customer", "notificationId"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/customer/{customer}/notifications/{notificationId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customer", "notificationId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer* 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.
///
/// The unique ID for the customer's Google account. The customerId is also returned as part of the Users resource.
pub fn customer(mut self, new_value: &str) -> NotificationDeleteCall<'a, C, A> {
self._customer = new_value.to_string();
self
}
/// Sets the *notification 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.
///
/// The unique ID of the notification.
pub fn notification_id(mut self, new_value: &str) -> NotificationDeleteCall<'a, C, A> {
self._notification_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> NotificationDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> NotificationDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> NotificationDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Updates a notification. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *notification* resource.
/// It is not used directly, but through a `NotificationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Notification;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Notification = Default::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.notifications().patch(&req, "customer", "notificationId")
/// .doit();
/// # }
/// ```
pub struct NotificationPatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Notification,
_customer: String,
_notification_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for NotificationPatchCall<'a, C, A> {}
impl<'a, C, A> NotificationPatchCall<'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, Notification)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.notifications.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customer", self._customer.to_string()));
params.push(("notificationId", self._notification_id.to_string()));
for &field in ["alt", "customer", "notificationId"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customer}/notifications/{notificationId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customer", "notificationId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Notification) -> NotificationPatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer* 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.
///
/// The unique ID for the customer's Google account.
pub fn customer(mut self, new_value: &str) -> NotificationPatchCall<'a, C, A> {
self._customer = new_value.to_string();
self
}
/// Sets the *notification 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.
///
/// The unique ID of the notification.
pub fn notification_id(mut self, new_value: &str) -> NotificationPatchCall<'a, C, A> {
self._notification_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> NotificationPatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> NotificationPatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> NotificationPatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Updates a notification.
///
/// A builder for the *update* method supported by a *notification* resource.
/// It is not used directly, but through a `NotificationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Notification;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Notification = Default::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.notifications().update(&req, "customer", "notificationId")
/// .doit();
/// # }
/// ```
pub struct NotificationUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Notification,
_customer: String,
_notification_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for NotificationUpdateCall<'a, C, A> {}
impl<'a, C, A> NotificationUpdateCall<'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, Notification)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.notifications.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customer", self._customer.to_string()));
params.push(("notificationId", self._notification_id.to_string()));
for &field in ["alt", "customer", "notificationId"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customer}/notifications/{notificationId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customer", "notificationId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Notification) -> NotificationUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer* 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.
///
/// The unique ID for the customer's Google account.
pub fn customer(mut self, new_value: &str) -> NotificationUpdateCall<'a, C, A> {
self._customer = new_value.to_string();
self
}
/// Sets the *notification 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.
///
/// The unique ID of the notification.
pub fn notification_id(mut self, new_value: &str) -> NotificationUpdateCall<'a, C, A> {
self._notification_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> NotificationUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> NotificationUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> NotificationUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieves a notification.
///
/// A builder for the *get* method supported by a *notification* resource.
/// It is not used directly, but through a `NotificationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.notifications().get("customer", "notificationId")
/// .doit();
/// # }
/// ```
pub struct NotificationGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer: String,
_notification_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for NotificationGetCall<'a, C, A> {}
impl<'a, C, A> NotificationGetCall<'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, Notification)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.notifications.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("customer", self._customer.to_string()));
params.push(("notificationId", self._notification_id.to_string()));
for &field in ["alt", "customer", "notificationId"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customer}/notifications/{notificationId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customer", "notificationId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer* 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.
///
/// The unique ID for the customer's Google account. The customerId is also returned as part of the Users resource.
pub fn customer(mut self, new_value: &str) -> NotificationGetCall<'a, C, A> {
self._customer = new_value.to_string();
self
}
/// Sets the *notification 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.
///
/// The unique ID of the notification.
pub fn notification_id(mut self, new_value: &str) -> NotificationGetCall<'a, C, A> {
self._notification_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> NotificationGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> NotificationGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> NotificationGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve all Chrome OS Devices of a customer (paginated)
///
/// A builder for the *list* method supported by a *chromeosdevice* resource.
/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.chromeosdevices().list("customerId")
/// .sort_order("aliquyam")
/// .query("ea")
/// .projection("ea")
/// .page_token("et")
/// .order_by("dolor")
/// .max_results(-41)
/// .doit();
/// # }
/// ```
pub struct ChromeosdeviceListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_sort_order: Option<String>,
_query: Option<String>,
_projection: Option<String>,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<i32>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for ChromeosdeviceListCall<'a, C, A> {}
impl<'a, C, A> ChromeosdeviceListCall<'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, ChromeOsDevices)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.chromeosdevices.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
if let Some(value) = self._sort_order {
params.push(("sortOrder", value.to_string()));
}
if let Some(value) = self._query {
params.push(("query", value.to_string()));
}
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._order_by {
params.push(("orderBy", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
for &field in ["alt", "customerId", "sortOrder", "query", "projection", "pageToken", "orderBy", "maxResults"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/chromeos".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["customerId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *sort order* query property to the given value.
///
///
/// Whether to return results in ascending or descending order. Only of use when orderBy is also used
pub fn sort_order(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
self._sort_order = Some(new_value.to_string());
self
}
/// Sets the *query* query property to the given value.
///
///
/// Search string in the format given at http://support.google.com/chromeos/a/bin/answer.py?hl=en&answer=1698333
pub fn query(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
self._query = Some(new_value.to_string());
self
}
/// Sets the *projection* query property to the given value.
///
///
/// Restrict information returned to a set of selected fields.
pub fn projection(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *page token* query property to the given value.
///
///
/// Token to specify next page in the list
pub fn page_token(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *order by* query property to the given value.
///
///
/// Column to use for sorting results
pub fn order_by(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
self._order_by = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// Maximum number of results to return. Default is 100
pub fn max_results(mut self, new_value: i32) -> ChromeosdeviceListCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ChromeosdeviceListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ChromeosdeviceListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update Chrome OS Device. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *chromeosdevice* resource.
/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::ChromeOsDevice;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: ChromeOsDevice = Default::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.chromeosdevices().patch(&req, "customerId", "deviceId")
/// .projection("rebum.")
/// .doit();
/// # }
/// ```
pub struct ChromeosdevicePatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: ChromeOsDevice,
_customer_id: String,
_device_id: String,
_projection: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for ChromeosdevicePatchCall<'a, C, A> {}
impl<'a, C, A> ChromeosdevicePatchCall<'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, ChromeOsDevice)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.chromeosdevices.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("deviceId", self._device_id.to_string()));
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
for &field in ["alt", "customerId", "deviceId", "projection"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/chromeos/{deviceId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{deviceId}", "deviceId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "deviceId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &ChromeOsDevice) -> ChromeosdevicePatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> ChromeosdevicePatchCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// 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.
///
/// Immutable id of Chrome OS Device
pub fn device_id(mut self, new_value: &str) -> ChromeosdevicePatchCall<'a, C, A> {
self._device_id = new_value.to_string();
self
}
/// Sets the *projection* query property to the given value.
///
///
/// Restrict information returned to a set of selected fields.
pub fn projection(mut self, new_value: &str) -> ChromeosdevicePatchCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ChromeosdevicePatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ChromeosdevicePatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ChromeosdevicePatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve Chrome OS Device
///
/// A builder for the *get* method supported by a *chromeosdevice* resource.
/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.chromeosdevices().get("customerId", "deviceId")
/// .projection("invidunt")
/// .doit();
/// # }
/// ```
pub struct ChromeosdeviceGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_device_id: String,
_projection: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for ChromeosdeviceGetCall<'a, C, A> {}
impl<'a, C, A> ChromeosdeviceGetCall<'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, ChromeOsDevice)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.chromeosdevices.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("deviceId", self._device_id.to_string()));
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
for &field in ["alt", "customerId", "deviceId", "projection"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/chromeos/{deviceId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{deviceId}", "deviceId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "deviceId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceGetCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// 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.
///
/// Immutable id of Chrome OS Device
pub fn device_id(mut self, new_value: &str) -> ChromeosdeviceGetCall<'a, C, A> {
self._device_id = new_value.to_string();
self
}
/// Sets the *projection* query property to the given value.
///
///
/// Restrict information returned to a set of selected fields.
pub fn projection(mut self, new_value: &str) -> ChromeosdeviceGetCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ChromeosdeviceGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ChromeosdeviceGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update Chrome OS Device
///
/// A builder for the *update* method supported by a *chromeosdevice* resource.
/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::ChromeOsDevice;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: ChromeOsDevice = Default::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.chromeosdevices().update(&req, "customerId", "deviceId")
/// .projection("consetetur")
/// .doit();
/// # }
/// ```
pub struct ChromeosdeviceUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: ChromeOsDevice,
_customer_id: String,
_device_id: String,
_projection: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for ChromeosdeviceUpdateCall<'a, C, A> {}
impl<'a, C, A> ChromeosdeviceUpdateCall<'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, ChromeOsDevice)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.chromeosdevices.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("deviceId", self._device_id.to_string()));
if let Some(value) = self._projection {
params.push(("projection", value.to_string()));
}
for &field in ["alt", "customerId", "deviceId", "projection"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/devices/chromeos/{deviceId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{deviceId}", "deviceId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "deviceId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &ChromeOsDevice) -> ChromeosdeviceUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// 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.
///
/// Immutable id of Chrome OS Device
pub fn device_id(mut self, new_value: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
self._device_id = new_value.to_string();
self
}
/// Sets the *projection* query property to the given value.
///
///
/// Restrict information returned to a set of selected fields.
pub fn projection(mut self, new_value: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
self._projection = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ChromeosdeviceUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ChromeosdeviceUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Generate new backup verification codes for the user.
///
/// A builder for the *generate* method supported by a *verificationCode* resource.
/// It is not used directly, but through a `VerificationCodeMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.verification_codes().generate("userKey")
/// .doit();
/// # }
/// ```
pub struct VerificationCodeGenerateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for VerificationCodeGenerateCall<'a, C, A> {}
impl<'a, C, A> VerificationCodeGenerateCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.verificationCodes.generate",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["userKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/verificationCodes/generate".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> VerificationCodeGenerateCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> VerificationCodeGenerateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> VerificationCodeGenerateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> VerificationCodeGenerateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Invalidate the current backup verification codes for the user.
///
/// A builder for the *invalidate* method supported by a *verificationCode* resource.
/// It is not used directly, but through a `VerificationCodeMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.verification_codes().invalidate("userKey")
/// .doit();
/// # }
/// ```
pub struct VerificationCodeInvalidateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for VerificationCodeInvalidateCall<'a, C, A> {}
impl<'a, C, A> VerificationCodeInvalidateCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.verificationCodes.invalidate",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["userKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/verificationCodes/invalidate".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Email or immutable Id of the user
pub fn user_key(mut self, new_value: &str) -> VerificationCodeInvalidateCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> VerificationCodeInvalidateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> VerificationCodeInvalidateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> VerificationCodeInvalidateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Returns the current set of valid backup verification codes for the specified user.
///
/// A builder for the *list* method supported by a *verificationCode* resource.
/// It is not used directly, but through a `VerificationCodeMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.verification_codes().list("userKey")
/// .doit();
/// # }
/// ```
pub struct VerificationCodeListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for VerificationCodeListCall<'a, C, A> {}
impl<'a, C, A> VerificationCodeListCall<'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, VerificationCodes)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.verificationCodes.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/verificationCodes".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn user_key(mut self, new_value: &str) -> VerificationCodeListCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> VerificationCodeListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> VerificationCodeListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> VerificationCodeListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve Group
///
/// A builder for the *get* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.groups().get("groupKey")
/// .doit();
/// # }
/// ```
pub struct GroupGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_group_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupGetCall<'a, C, A> {}
impl<'a, C, A> GroupGetCall<'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, Group)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
for &field in ["alt", "groupKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> GroupGetCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve all groups in a domain (paginated)
///
/// A builder for the *list* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.groups().list()
/// .user_key("elitr")
/// .page_token("nonumy")
/// .max_results(-15)
/// .domain("Lorem")
/// .customer("Lorem")
/// .doit();
/// # }
/// ```
pub struct GroupListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: Option<String>,
_page_token: Option<String>,
_max_results: Option<i32>,
_domain: Option<String>,
_customer: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupListCall<'a, C, A> {}
impl<'a, C, A> GroupListCall<'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, Groups)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
if let Some(value) = self._user_key {
params.push(("userKey", value.to_string()));
}
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._domain {
params.push(("domain", value.to_string()));
}
if let Some(value) = self._customer {
params.push(("customer", value.to_string()));
}
for &field in ["alt", "userKey", "pageToken", "maxResults", "domain", "customer"].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 = "https://www.googleapis.com/admin/directory/v1/groups".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* query property to the given value.
///
///
/// Email or immutable Id of the user if only those groups are to be listed, the given user is a member of. If Id, it should match with id of user object
pub fn user_key(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
self._user_key = Some(new_value.to_string());
self
}
/// Sets the *page token* query property to the given value.
///
///
/// Token to specify next page in the list
pub fn page_token(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// Maximum number of results to return. Default is 200
pub fn max_results(mut self, new_value: i32) -> GroupListCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *domain* query property to the given value.
///
///
/// Name of the domain. Fill this field to get groups from only this domain. To return all groups in a multi-domain fill customer field instead.
pub fn domain(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
self._domain = Some(new_value.to_string());
self
}
/// Sets the *customer* query property to the given value.
///
///
/// Immutable id of the Google Apps account. In case of multi-domain, to fetch all groups for a customer, fill this field instead of domain.
pub fn customer(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
self._customer = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// List all aliases for a group
///
/// A builder for the *aliases.list* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.groups().aliases_list("groupKey")
/// .doit();
/// # }
/// ```
pub struct GroupAliaseListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_group_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupAliaseListCall<'a, C, A> {}
impl<'a, C, A> GroupAliaseListCall<'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, Aliases)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.aliases.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
for &field in ["alt", "groupKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/aliases".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> GroupAliaseListCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupAliaseListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupAliaseListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupAliaseListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update Group. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Group;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Group = Default::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.groups().patch(&req, "groupKey")
/// .doit();
/// # }
/// ```
pub struct GroupPatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Group,
_group_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupPatchCall<'a, C, A> {}
impl<'a, C, A> GroupPatchCall<'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, Group)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
for &field in ["alt", "groupKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Group) -> GroupPatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group. If Id, it should match with id of group object
pub fn group_key(mut self, new_value: &str) -> GroupPatchCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupPatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupPatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupPatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update Group
///
/// A builder for the *update* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Group;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Group = Default::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.groups().update(&req, "groupKey")
/// .doit();
/// # }
/// ```
pub struct GroupUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Group,
_group_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupUpdateCall<'a, C, A> {}
impl<'a, C, A> GroupUpdateCall<'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, Group)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
for &field in ["alt", "groupKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Group) -> GroupUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group. If Id, it should match with id of group object
pub fn group_key(mut self, new_value: &str) -> GroupUpdateCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Delete Group
///
/// A builder for the *delete* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.groups().delete("groupKey")
/// .doit();
/// # }
/// ```
pub struct GroupDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_group_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupDeleteCall<'a, C, A> {}
impl<'a, C, A> GroupDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
for &field in ["groupKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> GroupDeleteCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Add a alias for the group
///
/// A builder for the *aliases.insert* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Alias;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Alias = Default::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.groups().aliases_insert(&req, "groupKey")
/// .doit();
/// # }
/// ```
pub struct GroupAliaseInsertCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Alias,
_group_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupAliaseInsertCall<'a, C, A> {}
impl<'a, C, A> GroupAliaseInsertCall<'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, Alias)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.aliases.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
for &field in ["alt", "groupKey"].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 = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/aliases".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Alias) -> GroupAliaseInsertCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> GroupAliaseInsertCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupAliaseInsertCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupAliaseInsertCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupAliaseInsertCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Remove a alias for the group
///
/// A builder for the *aliases.delete* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.groups().aliases_delete("groupKey", "alias")
/// .doit();
/// # }
/// ```
pub struct GroupAliaseDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_group_key: String,
_alias: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupAliaseDeleteCall<'a, C, A> {}
impl<'a, C, A> GroupAliaseDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.aliases.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("groupKey", self._group_key.to_string()));
params.push(("alias", self._alias.to_string()));
for &field in ["groupKey", "alias"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/groups/{groupKey}/aliases/{alias}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{alias}", "alias")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["groupKey", "alias"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *group key* 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.
///
/// Email or immutable Id of the group
pub fn group_key(mut self, new_value: &str) -> GroupAliaseDeleteCall<'a, C, A> {
self._group_key = new_value.to_string();
self
}
/// Sets the *alias* 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.
///
/// The alias to be removed
pub fn alias(mut self, new_value: &str) -> GroupAliaseDeleteCall<'a, C, A> {
self._alias = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupAliaseDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupAliaseDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupAliaseDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Create Group
///
/// A builder for the *insert* method supported by a *group* resource.
/// It is not used directly, but through a `GroupMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Group;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Group = Default::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.groups().insert(&req)
/// .doit();
/// # }
/// ```
pub struct GroupInsertCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Group,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for GroupInsertCall<'a, C, A> {}
impl<'a, C, A> GroupInsertCall<'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, Group)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.groups.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
for &field in ["alt"].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 = "https://www.googleapis.com/admin/directory/v1/groups".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Group) -> GroupInsertCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> GroupInsertCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> GroupInsertCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> GroupInsertCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Delete an ASP issued by a user.
///
/// A builder for the *delete* method supported by a *asp* resource.
/// It is not used directly, but through a `AspMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.asps().delete("userKey", -36)
/// .doit();
/// # }
/// ```
pub struct AspDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_code_id: i32,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for AspDeleteCall<'a, C, A> {}
impl<'a, C, A> AspDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.asps.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
params.push(("codeId", self._code_id.to_string()));
for &field in ["userKey", "codeId"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/asps/{codeId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey"), ("{codeId}", "codeId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["userKey", "codeId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn user_key(mut self, new_value: &str) -> AspDeleteCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *code 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.
///
/// The unique ID of the ASP to be deleted.
pub fn code_id(mut self, new_value: i32) -> AspDeleteCall<'a, C, A> {
self._code_id = new_value;
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AspDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AspDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AspDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// List the ASPs issued by a user.
///
/// A builder for the *list* method supported by a *asp* resource.
/// It is not used directly, but through a `AspMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.asps().list("userKey")
/// .doit();
/// # }
/// ```
pub struct AspListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for AspListCall<'a, C, A> {}
impl<'a, C, A> AspListCall<'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, Asps)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.asps.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
for &field in ["alt", "userKey"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/asps".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["userKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn user_key(mut self, new_value: &str) -> AspListCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AspListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AspListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AspListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Get information about an ASP issued by a user.
///
/// A builder for the *get* method supported by a *asp* resource.
/// It is not used directly, but through a `AspMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.asps().get("userKey", -27)
/// .doit();
/// # }
/// ```
pub struct AspGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_user_key: String,
_code_id: i32,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for AspGetCall<'a, C, A> {}
impl<'a, C, A> AspGetCall<'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, Asp)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.asps.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("userKey", self._user_key.to_string()));
params.push(("codeId", self._code_id.to_string()));
for &field in ["alt", "userKey", "codeId"].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 = "https://www.googleapis.com/admin/directory/v1/users/{userKey}/asps/{codeId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{userKey}", "userKey"), ("{codeId}", "codeId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["userKey", "codeId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *user key* 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.
///
/// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
pub fn user_key(mut self, new_value: &str) -> AspGetCall<'a, C, A> {
self._user_key = new_value.to_string();
self
}
/// Sets the *code 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.
///
/// The unique ID of the ASP.
pub fn code_id(mut self, new_value: i32) -> AspGetCall<'a, C, A> {
self._code_id = new_value;
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AspGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AspGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AspGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve all schemas for a customer
///
/// A builder for the *list* method supported by a *schema* resource.
/// It is not used directly, but through a `SchemaMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.schemas().list("customerId")
/// .doit();
/// # }
/// ```
pub struct SchemaListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for SchemaListCall<'a, C, A> {}
impl<'a, C, A> SchemaListCall<'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, Schemas)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.schemas.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
for &field in ["alt", "customerId"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/schemas".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["customerId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> SchemaListCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SchemaListCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> SchemaListCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> SchemaListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieve schema
///
/// A builder for the *get* method supported by a *schema* resource.
/// It is not used directly, but through a `SchemaMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.schemas().get("customerId", "schemaKey")
/// .doit();
/// # }
/// ```
pub struct SchemaGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_schema_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for SchemaGetCall<'a, C, A> {}
impl<'a, C, A> SchemaGetCall<'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, Schema)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.schemas.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("schemaKey", self._schema_key.to_string()));
for &field in ["alt", "customerId", "schemaKey"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "schemaKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> SchemaGetCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *schema key* 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.
///
/// Name or immutable Id of the schema
pub fn schema_key(mut self, new_value: &str) -> SchemaGetCall<'a, C, A> {
self._schema_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SchemaGetCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> SchemaGetCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> SchemaGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update schema. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *schema* resource.
/// It is not used directly, but through a `SchemaMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Schema;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Schema = Default::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.schemas().patch(&req, "customerId", "schemaKey")
/// .doit();
/// # }
/// ```
pub struct SchemaPatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Schema,
_customer_id: String,
_schema_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for SchemaPatchCall<'a, C, A> {}
impl<'a, C, A> SchemaPatchCall<'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, Schema)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.schemas.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("schemaKey", self._schema_key.to_string()));
for &field in ["alt", "customerId", "schemaKey"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "schemaKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Schema) -> SchemaPatchCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> SchemaPatchCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *schema key* 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.
///
/// Name or immutable Id of the schema.
pub fn schema_key(mut self, new_value: &str) -> SchemaPatchCall<'a, C, A> {
self._schema_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SchemaPatchCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> SchemaPatchCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> SchemaPatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Create schema.
///
/// A builder for the *insert* method supported by a *schema* resource.
/// It is not used directly, but through a `SchemaMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Schema;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Schema = Default::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.schemas().insert(&req, "customerId")
/// .doit();
/// # }
/// ```
pub struct SchemaInsertCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Schema,
_customer_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for SchemaInsertCall<'a, C, A> {}
impl<'a, C, A> SchemaInsertCall<'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, Schema)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.schemas.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
for &field in ["alt", "customerId"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/schemas".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["customerId"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Schema) -> SchemaInsertCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> SchemaInsertCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SchemaInsertCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> SchemaInsertCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> SchemaInsertCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Delete schema
///
/// A builder for the *delete* method supported by a *schema* resource.
/// It is not used directly, but through a `SchemaMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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.schemas().delete("customerId", "schemaKey")
/// .doit();
/// # }
/// ```
pub struct SchemaDeleteCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_customer_id: String,
_schema_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for SchemaDeleteCall<'a, C, A> {}
impl<'a, C, A> SchemaDeleteCall<'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> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.schemas.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("schemaKey", self._schema_key.to_string()));
for &field in ["customerId", "schemaKey"].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()));
}
let mut url = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "schemaKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> SchemaDeleteCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *schema key* 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.
///
/// Name or immutable Id of the schema
pub fn schema_key(mut self, new_value: &str) -> SchemaDeleteCall<'a, C, A> {
self._schema_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SchemaDeleteCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> SchemaDeleteCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> SchemaDeleteCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update schema
///
/// A builder for the *update* method supported by a *schema* resource.
/// It is not used directly, but through a `SchemaMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_admin1_directory as admin1_directory;
/// use admin1_directory::Schema;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use admin1_directory::Directory;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = Directory::new(hyper::Client::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: Schema = Default::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.schemas().update(&req, "customerId", "schemaKey")
/// .doit();
/// # }
/// ```
pub struct SchemaUpdateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a Directory<C, A>,
_request: Schema,
_customer_id: String,
_schema_key: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for SchemaUpdateCall<'a, C, A> {}
impl<'a, C, A> SchemaUpdateCall<'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, Schema)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "directory.schemas.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("customerId", self._customer_id.to_string()));
params.push(("schemaKey", self._schema_key.to_string()));
for &field in ["alt", "customerId", "schemaKey"].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 = "https://www.googleapis.com/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["customerId", "schemaKey"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
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::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.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_ms(d.num_milliseconds() as u32);
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()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
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(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: &Schema) -> SchemaUpdateCall<'a, C, A> {
self._request = new_value.clone();
self
}
/// Sets the *customer 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.
///
/// Immutable id of the Google Apps account
pub fn customer_id(mut self, new_value: &str) -> SchemaUpdateCall<'a, C, A> {
self._customer_id = new_value.to_string();
self
}
/// Sets the *schema key* 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.
///
/// Name or immutable Id of the schema.
pub fn schema_key(mut self, new_value: &str) -> SchemaUpdateCall<'a, C, A> {
self._schema_key = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// 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.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SchemaUpdateCall<'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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> SchemaUpdateCall<'a, C, A>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> SchemaUpdateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}