google_admin1_directory/
lib.rs

1// DO NOT EDIT !
2// This file was generated automatically from 'src/mako/api/lib.rs.mako'
3// DO NOT EDIT !
4
5//! This documentation was generated from *directory* crate version *1.0.13+20200204*, where *20200204* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.13*.
6//! 
7//! Everything else about the *directory* *v1_directory* API can be found at the
8//! [official documentation site](https://developers.google.com/admin-sdk/directory/).
9//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_directory).
10//! # Features
11//! 
12//! Handle the following *Resources* with ease from the central [hub](struct.Directory.html) ... 
13//! 
14//! * [asps](struct.Asp.html)
15//!  * [*delete*](struct.AspDeleteCall.html), [*get*](struct.AspGetCall.html) and [*list*](struct.AspListCall.html)
16//! * [channels](struct.Channel.html)
17//!  * [*stop*](struct.ChannelStopCall.html)
18//! * chromeosdevices
19//!  * [*action*](struct.ChromeosdeviceActionCall.html), [*get*](struct.ChromeosdeviceGetCall.html), [*list*](struct.ChromeosdeviceListCall.html), [*move devices to ou*](struct.ChromeosdeviceMoveDevicesToOuCall.html), [*patch*](struct.ChromeosdevicePatchCall.html) and [*update*](struct.ChromeosdeviceUpdateCall.html)
20//! * [customers](struct.Customer.html)
21//!  * [*get*](struct.CustomerGetCall.html), [*patch*](struct.CustomerPatchCall.html) and [*update*](struct.CustomerUpdateCall.html)
22//! * domain aliases
23//!  * [*delete*](struct.DomainAliaseDeleteCall.html), [*get*](struct.DomainAliaseGetCall.html), [*insert*](struct.DomainAliaseInsertCall.html) and [*list*](struct.DomainAliaseListCall.html)
24//! * domains
25//!  * [*delete*](struct.DomainDeleteCall.html), [*get*](struct.DomainGetCall.html), [*insert*](struct.DomainInsertCall.html) and [*list*](struct.DomainListCall.html)
26//! * [groups](struct.Group.html)
27//!  * [*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)
28//! * [members](struct.Member.html)
29//!  * [*delete*](struct.MemberDeleteCall.html), [*get*](struct.MemberGetCall.html), [*has member*](struct.MemberHasMemberCall.html), [*insert*](struct.MemberInsertCall.html), [*list*](struct.MemberListCall.html), [*patch*](struct.MemberPatchCall.html) and [*update*](struct.MemberUpdateCall.html)
30//! * mobiledevices
31//!  * [*action*](struct.MobiledeviceActionCall.html), [*delete*](struct.MobiledeviceDeleteCall.html), [*get*](struct.MobiledeviceGetCall.html) and [*list*](struct.MobiledeviceListCall.html)
32//! * [notifications](struct.Notification.html)
33//!  * [*delete*](struct.NotificationDeleteCall.html), [*get*](struct.NotificationGetCall.html), [*list*](struct.NotificationListCall.html), [*patch*](struct.NotificationPatchCall.html) and [*update*](struct.NotificationUpdateCall.html)
34//! * orgunits
35//!  * [*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)
36//! * [privileges](struct.Privilege.html)
37//!  * [*list*](struct.PrivilegeListCall.html)
38//! * resources
39//!  * [*buildings delete*](struct.ResourceBuildingDeleteCall.html), [*buildings get*](struct.ResourceBuildingGetCall.html), [*buildings insert*](struct.ResourceBuildingInsertCall.html), [*buildings list*](struct.ResourceBuildingListCall.html), [*buildings patch*](struct.ResourceBuildingPatchCall.html), [*buildings update*](struct.ResourceBuildingUpdateCall.html), [*calendars delete*](struct.ResourceCalendarDeleteCall.html), [*calendars get*](struct.ResourceCalendarGetCall.html), [*calendars insert*](struct.ResourceCalendarInsertCall.html), [*calendars list*](struct.ResourceCalendarListCall.html), [*calendars patch*](struct.ResourceCalendarPatchCall.html), [*calendars update*](struct.ResourceCalendarUpdateCall.html), [*features delete*](struct.ResourceFeatureDeleteCall.html), [*features get*](struct.ResourceFeatureGetCall.html), [*features insert*](struct.ResourceFeatureInsertCall.html), [*features list*](struct.ResourceFeatureListCall.html), [*features patch*](struct.ResourceFeaturePatchCall.html), [*features rename*](struct.ResourceFeatureRenameCall.html) and [*features update*](struct.ResourceFeatureUpdateCall.html)
40//! * [role assignments](struct.RoleAssignment.html)
41//!  * [*delete*](struct.RoleAssignmentDeleteCall.html), [*get*](struct.RoleAssignmentGetCall.html), [*insert*](struct.RoleAssignmentInsertCall.html) and [*list*](struct.RoleAssignmentListCall.html)
42//! * [roles](struct.Role.html)
43//!  * [*delete*](struct.RoleDeleteCall.html), [*get*](struct.RoleGetCall.html), [*insert*](struct.RoleInsertCall.html), [*list*](struct.RoleListCall.html), [*patch*](struct.RolePatchCall.html) and [*update*](struct.RoleUpdateCall.html)
44//! * [schemas](struct.Schema.html)
45//!  * [*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)
46//! * [tokens](struct.Token.html)
47//!  * [*delete*](struct.TokenDeleteCall.html), [*get*](struct.TokenGetCall.html) and [*list*](struct.TokenListCall.html)
48//! * [users](struct.User.html)
49//!  * [*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)
50//! * [verification codes](struct.VerificationCode.html)
51//!  * [*generate*](struct.VerificationCodeGenerateCall.html), [*invalidate*](struct.VerificationCodeInvalidateCall.html) and [*list*](struct.VerificationCodeListCall.html)
52//! 
53//! 
54//! Subscription supported by ...
55//! 
56//! * [*list users*](struct.UserListCall.html)
57//! * [*watch users*](struct.UserWatchCall.html)
58//! * [*aliases watch users*](struct.UserAliaseWatchCall.html)
59//! * [*aliases list users*](struct.UserAliaseListCall.html)
60//! * [*aliases list groups*](struct.GroupAliaseListCall.html)
61//! 
62//! 
63//! 
64//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs).
65//! 
66//! # Structure of this Library
67//! 
68//! The API is structured into the following primary items:
69//! 
70//! * **[Hub](struct.Directory.html)**
71//!     * a central object to maintain state and allow accessing all *Activities*
72//!     * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
73//!       allow access to individual [*Call Builders*](trait.CallBuilder.html)
74//! * **[Resources](trait.Resource.html)**
75//!     * primary types that you can apply *Activities* to
76//!     * a collection of properties and *Parts*
77//!     * **[Parts](trait.Part.html)**
78//!         * a collection of properties
79//!         * never directly used in *Activities*
80//! * **[Activities](trait.CallBuilder.html)**
81//!     * operations to apply to *Resources*
82//! 
83//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
84//! 
85//! Generally speaking, you can invoke *Activities* like this:
86//! 
87//! ```Rust,ignore
88//! let r = hub.resource().activity(...).doit()
89//! ```
90//! 
91//! Or specifically ...
92//! 
93//! ```ignore
94//! let r = hub.users().photos_patch(...).doit()
95//! let r = hub.users().aliases_delete(...).doit()
96//! let r = hub.users().undelete(...).doit()
97//! let r = hub.users().photos_get(...).doit()
98//! let r = hub.users().update(...).doit()
99//! let r = hub.users().aliases_watch(...).doit()
100//! let r = hub.users().insert(...).doit()
101//! let r = hub.users().photos_delete(...).doit()
102//! let r = hub.users().patch(...).doit()
103//! let r = hub.users().photos_update(...).doit()
104//! let r = hub.users().watch(...).doit()
105//! let r = hub.users().get(...).doit()
106//! let r = hub.users().aliases_insert(...).doit()
107//! let r = hub.users().make_admin(...).doit()
108//! let r = hub.users().aliases_list(...).doit()
109//! let r = hub.users().list(...).doit()
110//! let r = hub.users().delete(...).doit()
111//! ```
112//! 
113//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` 
114//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be 
115//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
116//! The `doit()` method performs the actual communication with the server and returns the respective result.
117//! 
118//! # Usage
119//! 
120//! ## Setting up your Project
121//! 
122//! To use this library, you would put the following lines into your `Cargo.toml` file:
123//! 
124//! ```toml
125//! [dependencies]
126//! google-admin1_directory = "*"
127//! # This project intentionally uses an old version of Hyper. See
128//! # https://github.com/Byron/google-apis-rs/issues/173 for more
129//! # information.
130//! hyper = "^0.10"
131//! hyper-rustls = "^0.6"
132//! serde = "^1.0"
133//! serde_json = "^1.0"
134//! yup-oauth2 = "^1.0"
135//! ```
136//! 
137//! ## A complete example
138//! 
139//! ```test_harness,no_run
140//! extern crate hyper;
141//! extern crate hyper_rustls;
142//! extern crate yup_oauth2 as oauth2;
143//! extern crate google_admin1_directory as admin1_directory;
144//! use admin1_directory::Channel;
145//! use admin1_directory::{Result, Error};
146//! # #[test] fn egal() {
147//! use std::default::Default;
148//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
149//! use admin1_directory::Directory;
150//! 
151//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and 
152//! // `client_secret`, among other things.
153//! let secret: ApplicationSecret = Default::default();
154//! // Instantiate the authenticator. It will choose a suitable authentication flow for you, 
155//! // unless you replace  `None` with the desired Flow.
156//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about 
157//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
158//! // retrieve them from storage.
159//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
160//!                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
161//!                               <MemoryStorage as Default>::default(), None);
162//! let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
163//! // As the method needs a request, you would usually fill it with the desired information
164//! // into the respective structure. Some of the parts shown here might not be applicable !
165//! // Values shown here are possibly random and not representative !
166//! let mut req = Channel::default();
167//! 
168//! // You can configure optional parameters by calling the respective setters at will, and
169//! // execute the final call using `doit()`.
170//! // Values shown here are possibly random and not representative !
171//! let result = hub.users().watch(req)
172//!              .view_type("labore")
173//!              .sort_order("sea")
174//!              .show_deleted("nonumy")
175//!              .query("dolores")
176//!              .projection("gubergren")
177//!              .page_token("sadipscing")
178//!              .order_by("aliquyam")
179//!              .max_results(-66)
180//!              .event("no")
181//!              .domain("justo")
182//!              .customer("justo")
183//!              .custom_field_mask("et")
184//!              .doit();
185//! 
186//! match result {
187//!     Err(e) => match e {
188//!         // The Error enum provides details about what exactly happened.
189//!         // You can also just use its `Debug`, `Display` or `Error` traits
190//!          Error::HttpError(_)
191//!         |Error::MissingAPIKey
192//!         |Error::MissingToken(_)
193//!         |Error::Cancelled
194//!         |Error::UploadSizeLimitExceeded(_, _)
195//!         |Error::Failure(_)
196//!         |Error::BadRequest(_)
197//!         |Error::FieldClash(_)
198//!         |Error::JsonDecodeError(_, _) => println!("{}", e),
199//!     },
200//!     Ok(res) => println!("Success: {:?}", res),
201//! }
202//! # }
203//! ```
204//! ## Handling Errors
205//! 
206//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of 
207//! the doit() methods, or handed as possibly intermediate results to either the 
208//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
209//! 
210//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This 
211//! makes the system potentially resilient to all kinds of errors.
212//! 
213//! ## Uploads and Downloads
214//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
215//! read by you to obtain the media.
216//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
217//! 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
218//! this call: `.param("alt", "media")`.
219//! 
220//! Methods supporting uploads can do so using up to 2 different protocols: 
221//! *simple* and *resumable*. The distinctiveness of each is represented by customized 
222//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
223//! 
224//! ## Customization and Callbacks
225//! 
226//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the 
227//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call. 
228//! Respective methods will be called to provide progress information, as well as determine whether the system should 
229//! retry on failure.
230//! 
231//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
232//! 
233//! ## Optional Parts in Server-Requests
234//! 
235//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and 
236//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses 
237//! are valid.
238//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to 
239//! the server to indicate either the set parts of the request or the desired parts in the response.
240//! 
241//! ## Builder Arguments
242//! 
243//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
244//! These will always take a single argument, for which the following statements are true.
245//! 
246//! * [PODs][wiki-pod] are handed by copy
247//! * strings are passed as `&str`
248//! * [request values](trait.RequestValue.html) are moved
249//! 
250//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
251//! 
252//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
253//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
254//! [google-go-api]: https://github.com/google/google-api-go-client
255//! 
256//! 
257
258// Unused attributes happen thanks to defined, but unused structures
259// We don't warn about this, as depending on the API, some data structures or facilities are never used.
260// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
261// unused imports in fully featured APIs. Same with unused_mut ... .
262#![allow(unused_imports, unused_mut, dead_code)]
263
264// DO NOT EDIT !
265// This file was generated automatically from 'src/mako/api/lib.rs.mako'
266// DO NOT EDIT !
267
268#[macro_use]
269extern crate serde_derive;
270
271extern crate hyper;
272extern crate serde;
273extern crate serde_json;
274extern crate yup_oauth2 as oauth2;
275extern crate mime;
276extern crate url;
277
278mod cmn;
279
280use std::collections::HashMap;
281use std::cell::RefCell;
282use std::borrow::BorrowMut;
283use std::default::Default;
284use std::collections::BTreeMap;
285use serde_json as json;
286use std::io;
287use std::fs;
288use std::mem;
289use std::thread::sleep;
290use std::time::Duration;
291
292pub use cmn::*;
293
294
295// ##############
296// UTILITIES ###
297// ############
298
299/// Identifies the an OAuth2 authorization scope.
300/// A scope is needed when requesting an
301/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
302#[derive(PartialEq, Eq, Hash)]
303pub enum Scope {
304    /// View and manage the provisioning of users on your domain
305    DirectoryUser,
306
307    /// View calendar resources on your domain
308    DirectoryResourceCalendarReadonly,
309
310    /// Manage data access permissions for users on your domain
311    DirectoryUserSecurity,
312
313    /// View and manage your data across Google Cloud Platform services
314    CloudPlatform,
315
316    /// View groups on your domain
317    DirectoryGroupReadonly,
318
319    /// View and manage customer related information
320    DirectoryCustomer,
321
322    /// View and manage the provisioning of domains for your customers
323    DirectoryDomain,
324
325    /// View your Chrome OS devices' metadata
326    DirectoryDeviceChromeoReadonly,
327
328    /// View and manage the provisioning of calendar resources on your domain
329    DirectoryResourceCalendar,
330
331    /// View group subscriptions on your domain
332    DirectoryGroupMemberReadonly,
333
334    /// View your mobile devices' metadata
335    DirectoryDeviceMobileReadonly,
336
337    /// View organization units on your domain
338    DirectoryOrgunitReadonly,
339
340    /// View and manage group subscriptions on your domain
341    DirectoryGroupMember,
342
343    /// View and manage your mobile devices' metadata
344    DirectoryDeviceMobile,
345
346    /// View and manage user aliases on your domain
347    DirectoryUserAlia,
348
349    /// View and manage the provisioning of user schemas on your domain
350    DirectoryUserschema,
351
352    /// View customer related information
353    DirectoryCustomerReadonly,
354
355    /// View domains related to your customers
356    DirectoryDomainReadonly,
357
358    /// Manage your mobile devices by performing administrative tasks
359    DirectoryDeviceMobileAction,
360
361    /// View users on your domain
362    DirectoryUserReadonly,
363
364    /// View and manage notifications received on your domain
365    DirectoryNotification,
366
367    /// View and manage your Chrome OS devices' metadata
368    DirectoryDeviceChromeo,
369
370    /// View user aliases on your domain
371    DirectoryUserAliaReadonly,
372
373    /// View and manage the provisioning of groups on your domain
374    DirectoryGroup,
375
376    /// View user schemas on your domain
377    DirectoryUserschemaReadonly,
378
379    /// Manage delegated admin roles for your domain
380    DirectoryRolemanagement,
381
382    /// View and manage organization units on your domain
383    DirectoryOrgunit,
384
385    /// View delegated admin roles for your domain
386    DirectoryRolemanagementReadonly,
387}
388
389impl AsRef<str> for Scope {
390    fn as_ref(&self) -> &str {
391        match *self {
392            Scope::DirectoryUser => "https://www.googleapis.com/auth/admin.directory.user",
393            Scope::DirectoryResourceCalendarReadonly => "https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly",
394            Scope::DirectoryUserSecurity => "https://www.googleapis.com/auth/admin.directory.user.security",
395            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
396            Scope::DirectoryGroupReadonly => "https://www.googleapis.com/auth/admin.directory.group.readonly",
397            Scope::DirectoryCustomer => "https://www.googleapis.com/auth/admin.directory.customer",
398            Scope::DirectoryDomain => "https://www.googleapis.com/auth/admin.directory.domain",
399            Scope::DirectoryDeviceChromeoReadonly => "https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly",
400            Scope::DirectoryResourceCalendar => "https://www.googleapis.com/auth/admin.directory.resource.calendar",
401            Scope::DirectoryGroupMemberReadonly => "https://www.googleapis.com/auth/admin.directory.group.member.readonly",
402            Scope::DirectoryDeviceMobileReadonly => "https://www.googleapis.com/auth/admin.directory.device.mobile.readonly",
403            Scope::DirectoryOrgunitReadonly => "https://www.googleapis.com/auth/admin.directory.orgunit.readonly",
404            Scope::DirectoryGroupMember => "https://www.googleapis.com/auth/admin.directory.group.member",
405            Scope::DirectoryDeviceMobile => "https://www.googleapis.com/auth/admin.directory.device.mobile",
406            Scope::DirectoryUserAlia => "https://www.googleapis.com/auth/admin.directory.user.alias",
407            Scope::DirectoryUserschema => "https://www.googleapis.com/auth/admin.directory.userschema",
408            Scope::DirectoryCustomerReadonly => "https://www.googleapis.com/auth/admin.directory.customer.readonly",
409            Scope::DirectoryDomainReadonly => "https://www.googleapis.com/auth/admin.directory.domain.readonly",
410            Scope::DirectoryDeviceMobileAction => "https://www.googleapis.com/auth/admin.directory.device.mobile.action",
411            Scope::DirectoryUserReadonly => "https://www.googleapis.com/auth/admin.directory.user.readonly",
412            Scope::DirectoryNotification => "https://www.googleapis.com/auth/admin.directory.notifications",
413            Scope::DirectoryDeviceChromeo => "https://www.googleapis.com/auth/admin.directory.device.chromeos",
414            Scope::DirectoryUserAliaReadonly => "https://www.googleapis.com/auth/admin.directory.user.alias.readonly",
415            Scope::DirectoryGroup => "https://www.googleapis.com/auth/admin.directory.group",
416            Scope::DirectoryUserschemaReadonly => "https://www.googleapis.com/auth/admin.directory.userschema.readonly",
417            Scope::DirectoryRolemanagement => "https://www.googleapis.com/auth/admin.directory.rolemanagement",
418            Scope::DirectoryOrgunit => "https://www.googleapis.com/auth/admin.directory.orgunit",
419            Scope::DirectoryRolemanagementReadonly => "https://www.googleapis.com/auth/admin.directory.rolemanagement.readonly",
420        }
421    }
422}
423
424impl Default for Scope {
425    fn default() -> Scope {
426        Scope::DirectoryResourceCalendarReadonly
427    }
428}
429
430
431
432// ########
433// HUB ###
434// ######
435
436/// Central instance to access all Directory related resource activities
437///
438/// # Examples
439///
440/// Instantiate a new hub
441///
442/// ```test_harness,no_run
443/// extern crate hyper;
444/// extern crate hyper_rustls;
445/// extern crate yup_oauth2 as oauth2;
446/// extern crate google_admin1_directory as admin1_directory;
447/// use admin1_directory::Channel;
448/// use admin1_directory::{Result, Error};
449/// # #[test] fn egal() {
450/// use std::default::Default;
451/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
452/// use admin1_directory::Directory;
453/// 
454/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and 
455/// // `client_secret`, among other things.
456/// let secret: ApplicationSecret = Default::default();
457/// // Instantiate the authenticator. It will choose a suitable authentication flow for you, 
458/// // unless you replace  `None` with the desired Flow.
459/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about 
460/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
461/// // retrieve them from storage.
462/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
463///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
464///                               <MemoryStorage as Default>::default(), None);
465/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
466/// // As the method needs a request, you would usually fill it with the desired information
467/// // into the respective structure. Some of the parts shown here might not be applicable !
468/// // Values shown here are possibly random and not representative !
469/// let mut req = Channel::default();
470/// 
471/// // You can configure optional parameters by calling the respective setters at will, and
472/// // execute the final call using `doit()`.
473/// // Values shown here are possibly random and not representative !
474/// let result = hub.users().watch(req)
475///              .view_type("et")
476///              .sort_order("diam")
477///              .show_deleted("ipsum")
478///              .query("Lorem")
479///              .projection("et")
480///              .page_token("duo")
481///              .order_by("aliquyam")
482///              .max_results(-9)
483///              .event("Lorem")
484///              .domain("eos")
485///              .customer("erat")
486///              .custom_field_mask("sadipscing")
487///              .doit();
488/// 
489/// match result {
490///     Err(e) => match e {
491///         // The Error enum provides details about what exactly happened.
492///         // You can also just use its `Debug`, `Display` or `Error` traits
493///          Error::HttpError(_)
494///         |Error::MissingAPIKey
495///         |Error::MissingToken(_)
496///         |Error::Cancelled
497///         |Error::UploadSizeLimitExceeded(_, _)
498///         |Error::Failure(_)
499///         |Error::BadRequest(_)
500///         |Error::FieldClash(_)
501///         |Error::JsonDecodeError(_, _) => println!("{}", e),
502///     },
503///     Ok(res) => println!("Success: {:?}", res),
504/// }
505/// # }
506/// ```
507pub struct Directory<C, A> {
508    client: RefCell<C>,
509    auth: RefCell<A>,
510    _user_agent: String,
511    _base_url: String,
512    _root_url: String,
513}
514
515impl<'a, C, A> Hub for Directory<C, A> {}
516
517impl<'a, C, A> Directory<C, A>
518    where  C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
519
520    pub fn new(client: C, authenticator: A) -> Directory<C, A> {
521        Directory {
522            client: RefCell::new(client),
523            auth: RefCell::new(authenticator),
524            _user_agent: "google-api-rust-client/1.0.13".to_string(),
525            _base_url: "https://www.googleapis.com/admin/directory/v1/".to_string(),
526            _root_url: "https://www.googleapis.com/".to_string(),
527        }
528    }
529
530    pub fn asps(&'a self) -> AspMethods<'a, C, A> {
531        AspMethods { hub: &self }
532    }
533    pub fn channels(&'a self) -> ChannelMethods<'a, C, A> {
534        ChannelMethods { hub: &self }
535    }
536    pub fn chromeosdevices(&'a self) -> ChromeosdeviceMethods<'a, C, A> {
537        ChromeosdeviceMethods { hub: &self }
538    }
539    pub fn customers(&'a self) -> CustomerMethods<'a, C, A> {
540        CustomerMethods { hub: &self }
541    }
542    pub fn domain_aliases(&'a self) -> DomainAliaseMethods<'a, C, A> {
543        DomainAliaseMethods { hub: &self }
544    }
545    pub fn domains(&'a self) -> DomainMethods<'a, C, A> {
546        DomainMethods { hub: &self }
547    }
548    pub fn groups(&'a self) -> GroupMethods<'a, C, A> {
549        GroupMethods { hub: &self }
550    }
551    pub fn members(&'a self) -> MemberMethods<'a, C, A> {
552        MemberMethods { hub: &self }
553    }
554    pub fn mobiledevices(&'a self) -> MobiledeviceMethods<'a, C, A> {
555        MobiledeviceMethods { hub: &self }
556    }
557    pub fn notifications(&'a self) -> NotificationMethods<'a, C, A> {
558        NotificationMethods { hub: &self }
559    }
560    pub fn orgunits(&'a self) -> OrgunitMethods<'a, C, A> {
561        OrgunitMethods { hub: &self }
562    }
563    pub fn privileges(&'a self) -> PrivilegeMethods<'a, C, A> {
564        PrivilegeMethods { hub: &self }
565    }
566    pub fn resources(&'a self) -> ResourceMethods<'a, C, A> {
567        ResourceMethods { hub: &self }
568    }
569    pub fn role_assignments(&'a self) -> RoleAssignmentMethods<'a, C, A> {
570        RoleAssignmentMethods { hub: &self }
571    }
572    pub fn roles(&'a self) -> RoleMethods<'a, C, A> {
573        RoleMethods { hub: &self }
574    }
575    pub fn schemas(&'a self) -> SchemaMethods<'a, C, A> {
576        SchemaMethods { hub: &self }
577    }
578    pub fn tokens(&'a self) -> TokenMethods<'a, C, A> {
579        TokenMethods { hub: &self }
580    }
581    pub fn users(&'a self) -> UserMethods<'a, C, A> {
582        UserMethods { hub: &self }
583    }
584    pub fn verification_codes(&'a self) -> VerificationCodeMethods<'a, C, A> {
585        VerificationCodeMethods { hub: &self }
586    }
587
588    /// Set the user-agent header field to use in all requests to the server.
589    /// It defaults to `google-api-rust-client/1.0.13`.
590    ///
591    /// Returns the previously set user-agent.
592    pub fn user_agent(&mut self, agent_name: String) -> String {
593        mem::replace(&mut self._user_agent, agent_name)
594    }
595
596    /// Set the base url to use in all requests to the server.
597    /// It defaults to `https://www.googleapis.com/admin/directory/v1/`.
598    ///
599    /// Returns the previously set base url.
600    pub fn base_url(&mut self, new_base_url: String) -> String {
601        mem::replace(&mut self._base_url, new_base_url)
602    }
603
604    /// Set the root url to use in all requests to the server.
605    /// It defaults to `https://www.googleapis.com/`.
606    ///
607    /// Returns the previously set root url.
608    pub fn root_url(&mut self, new_root_url: String) -> String {
609        mem::replace(&mut self._root_url, new_root_url)
610    }
611}
612
613
614// ############
615// SCHEMAS ###
616// ##########
617/// JSON template for name of a user in Directory API.
618/// 
619/// This type is not used in any activity, and only used as *part* of another schema.
620/// 
621#[derive(Default, Clone, Debug, Serialize, Deserialize)]
622pub struct UserName {
623    /// Full Name
624    #[serde(rename="fullName")]
625    pub full_name: Option<String>,
626    /// First Name
627    #[serde(rename="givenName")]
628    pub given_name: Option<String>,
629    /// Last Name
630    #[serde(rename="familyName")]
631    pub family_name: Option<String>,
632}
633
634impl Part for UserName {}
635
636
637/// JSON template for Group resource in Directory API.
638/// 
639/// # Activities
640/// 
641/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
642/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
643/// 
644/// * [get groups](struct.GroupGetCall.html) (response)
645/// * [aliases insert groups](struct.GroupAliaseInsertCall.html) (none)
646/// * [delete groups](struct.GroupDeleteCall.html) (none)
647/// * [aliases delete groups](struct.GroupAliaseDeleteCall.html) (none)
648/// * [patch groups](struct.GroupPatchCall.html) (request|response)
649/// * [list groups](struct.GroupListCall.html) (none)
650/// * [aliases list groups](struct.GroupAliaseListCall.html) (none)
651/// * [update groups](struct.GroupUpdateCall.html) (request|response)
652/// * [insert groups](struct.GroupInsertCall.html) (request|response)
653/// 
654#[derive(Default, Clone, Debug, Serialize, Deserialize)]
655pub struct Group {
656    /// List of non editable aliases (Read-only)
657    #[serde(rename="nonEditableAliases")]
658    pub non_editable_aliases: Option<Vec<String>>,
659    /// Kind of resource this is.
660    pub kind: Option<String>,
661    /// Description of the group
662    pub description: Option<String>,
663    /// Is the group created by admin (Read-only) *
664    #[serde(rename="adminCreated")]
665    pub admin_created: Option<bool>,
666    /// Group direct members count
667    #[serde(rename="directMembersCount")]
668    pub direct_members_count: Option<String>,
669    /// Email of Group
670    pub email: Option<String>,
671    /// ETag of the resource.
672    pub etag: Option<String>,
673    /// List of aliases (Read-only)
674    pub aliases: Option<Vec<String>>,
675    /// Unique identifier of Group (Read-only)
676    pub id: Option<String>,
677    /// Group name
678    pub name: Option<String>,
679}
680
681impl RequestValue for Group {}
682impl Resource for Group {}
683impl ResponseResult for Group {}
684
685
686/// Template for a notification resource.
687/// 
688/// # Activities
689/// 
690/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
691/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
692/// 
693/// * [delete notifications](struct.NotificationDeleteCall.html) (none)
694/// * [update notifications](struct.NotificationUpdateCall.html) (request|response)
695/// * [patch notifications](struct.NotificationPatchCall.html) (request|response)
696/// * [get notifications](struct.NotificationGetCall.html) (response)
697/// * [list notifications](struct.NotificationListCall.html) (none)
698/// 
699#[derive(Default, Clone, Debug, Serialize, Deserialize)]
700pub struct Notification {
701    /// Body of the notification (Read-only)
702    pub body: Option<String>,
703    /// The type of the resource.
704    pub kind: Option<String>,
705    /// ETag of the resource.
706    pub etag: Option<String>,
707    /// Time at which notification was sent (Read-only)
708    #[serde(rename="sendTime")]
709    pub send_time: Option<String>,
710    /// no description provided
711    #[serde(rename="notificationId")]
712    pub notification_id: Option<String>,
713    /// Address from which the notification is received (Read-only)
714    #[serde(rename="fromAddress")]
715    pub from_address: Option<String>,
716    /// Boolean indicating whether the notification is unread or not.
717    #[serde(rename="isUnread")]
718    pub is_unread: Option<bool>,
719    /// Subject of the notification (Read-only)
720    pub subject: Option<String>,
721}
722
723impl RequestValue for Notification {}
724impl Resource for Notification {}
725impl ResponseResult for Notification {}
726
727
728/// JSON response template for List privileges operation in Directory API.
729/// 
730/// # Activities
731/// 
732/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
733/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
734/// 
735/// * [list privileges](struct.PrivilegeListCall.html) (response)
736/// 
737#[derive(Default, Clone, Debug, Serialize, Deserialize)]
738pub struct Privileges {
739    /// A list of Privilege resources.
740    pub items: Option<Vec<Privilege>>,
741    /// The type of the API resource. This is always admin#directory#privileges.
742    pub kind: Option<String>,
743    /// ETag of the resource.
744    pub etag: Option<String>,
745}
746
747impl ResponseResult for Privileges {}
748
749
750/// JSON template for Member resource in Directory API.
751/// 
752/// # Activities
753/// 
754/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
755/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
756/// 
757/// * [patch members](struct.MemberPatchCall.html) (request|response)
758/// * [list members](struct.MemberListCall.html) (none)
759/// * [insert members](struct.MemberInsertCall.html) (request|response)
760/// * [get members](struct.MemberGetCall.html) (response)
761/// * [has member members](struct.MemberHasMemberCall.html) (none)
762/// * [delete members](struct.MemberDeleteCall.html) (none)
763/// * [update members](struct.MemberUpdateCall.html) (request|response)
764/// 
765#[derive(Default, Clone, Debug, Serialize, Deserialize)]
766pub struct Member {
767    /// Status of member (Immutable)
768    pub status: Option<String>,
769    /// Kind of resource this is.
770    pub kind: Option<String>,
771    /// Delivery settings of member
772    pub delivery_settings: Option<String>,
773    /// Email of member (Read-only)
774    pub email: Option<String>,
775    /// ETag of the resource.
776    pub etag: Option<String>,
777    /// Role of member
778    pub role: Option<String>,
779    /// Type of member (Immutable)
780    #[serde(rename="type")]
781    pub type_: Option<String>,
782    /// The unique ID of the group member. A member id can be used as a member request URI's memberKey. Unique identifier of group (Read-only) Unique identifier of member (Read-only)
783    pub id: Option<String>,
784}
785
786impl RequestValue for Member {}
787impl Resource for Member {}
788impl ResponseResult for Member {}
789
790
791/// JSON response template for List Schema operation in Directory API.
792/// 
793/// # Activities
794/// 
795/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
796/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
797/// 
798/// * [list schemas](struct.SchemaListCall.html) (response)
799/// 
800#[derive(Default, Clone, Debug, Serialize, Deserialize)]
801pub struct Schemas {
802    /// Kind of resource this is.
803    pub kind: Option<String>,
804    /// ETag of the resource.
805    pub etag: Option<String>,
806    /// List of UserSchema objects.
807    pub schemas: Option<Vec<Schema>>,
808}
809
810impl ResponseResult for Schemas {}
811
812
813/// JSON template for role resource in Directory API.
814/// 
815/// # Activities
816/// 
817/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
818/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
819/// 
820/// * [update roles](struct.RoleUpdateCall.html) (request|response)
821/// * [insert roles](struct.RoleInsertCall.html) (request|response)
822/// * [get roles](struct.RoleGetCall.html) (response)
823/// * [patch roles](struct.RolePatchCall.html) (request|response)
824/// * [list roles](struct.RoleListCall.html) (none)
825/// * [delete roles](struct.RoleDeleteCall.html) (none)
826/// 
827#[derive(Default, Clone, Debug, Serialize, Deserialize)]
828pub struct Role {
829    /// The type of the API resource. This is always admin#directory#role.
830    pub kind: Option<String>,
831    /// ID of the role.
832    #[serde(rename="roleId")]
833    pub role_id: Option<String>,
834    /// A short description of the role.
835    #[serde(rename="roleDescription")]
836    pub role_description: Option<String>,
837    /// ETag of the resource.
838    pub etag: Option<String>,
839    /// Returns true if the role is a super admin role.
840    #[serde(rename="isSuperAdminRole")]
841    pub is_super_admin_role: Option<bool>,
842    /// Name of the role.
843    #[serde(rename="roleName")]
844    pub role_name: Option<String>,
845    /// Returns true if this is a pre-defined system role.
846    #[serde(rename="isSystemRole")]
847    pub is_system_role: Option<bool>,
848    /// The set of privileges that are granted to this role.
849    #[serde(rename="rolePrivileges")]
850    pub role_privileges: Option<Vec<RoleRolePrivileges>>,
851}
852
853impl RequestValue for Role {}
854impl Resource for Role {}
855impl ResponseResult for Role {}
856
857
858/// JSON template for privilege resource in Directory API.
859/// 
860/// # Activities
861/// 
862/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
863/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
864/// 
865/// * [list privileges](struct.PrivilegeListCall.html) (none)
866/// 
867#[derive(Default, Clone, Debug, Serialize, Deserialize)]
868pub struct Privilege {
869    /// The type of the API resource. This is always admin#directory#privilege.
870    pub kind: Option<String>,
871    /// The obfuscated ID of the service this privilege is for. This value is returned with Privileges.list().
872    #[serde(rename="serviceId")]
873    pub service_id: Option<String>,
874    /// The name of the privilege.
875    #[serde(rename="privilegeName")]
876    pub privilege_name: Option<String>,
877    /// ETag of the resource.
878    pub etag: Option<String>,
879    /// The name of the service this privilege is for.
880    #[serde(rename="serviceName")]
881    pub service_name: Option<String>,
882    /// A list of child privileges. Privileges for a service form a tree. Each privilege can have a list of child privileges; this list is empty for a leaf privilege.
883    #[serde(rename="childPrivileges")]
884    pub child_privileges: Option<Vec<Privilege>>,
885    /// If the privilege can be restricted to an organization unit.
886    #[serde(rename="isOuScopable")]
887    pub is_ou_scopable: Option<bool>,
888}
889
890impl Resource for Privilege {}
891
892
893/// JSON template for Calendar Resource object in Directory API.
894/// 
895/// # Activities
896/// 
897/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
898/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
899/// 
900/// * [calendars insert resources](struct.ResourceCalendarInsertCall.html) (request|response)
901/// * [calendars get resources](struct.ResourceCalendarGetCall.html) (response)
902/// * [calendars patch resources](struct.ResourceCalendarPatchCall.html) (request|response)
903/// * [calendars update resources](struct.ResourceCalendarUpdateCall.html) (request|response)
904/// 
905#[derive(Default, Clone, Debug, Serialize, Deserialize)]
906pub struct CalendarResource {
907    /// The type of the resource. For calendar resources, the value is admin#directory#resources#calendars#CalendarResource.
908    pub kind: Option<String>,
909    /// Capacity of a resource, number of seats in a room.
910    pub capacity: Option<i32>,
911    /// The type of the calendar resource, intended for non-room resources.
912    #[serde(rename="resourceType")]
913    pub resource_type: Option<String>,
914    /// Description of the resource, visible only to admins.
915    #[serde(rename="resourceDescription")]
916    pub resource_description: Option<String>,
917    /// The read-only auto-generated name of the calendar resource which includes metadata about the resource such as building name, floor, capacity, etc. For example, "NYC-2-Training Room 1A (16)".
918    #[serde(rename="generatedResourceName")]
919    pub generated_resource_name: Option<String>,
920    /// ETag of the resource.
921    pub etags: Option<String>,
922    /// The category of the calendar resource. Either CONFERENCE_ROOM or OTHER. Legacy data is set to CATEGORY_UNKNOWN.
923    #[serde(rename="resourceCategory")]
924    pub resource_category: Option<String>,
925    /// The read-only email for the calendar resource. Generated as part of creating a new calendar resource.
926    #[serde(rename="resourceEmail")]
927    pub resource_email: Option<String>,
928    /// The name of the calendar resource. For example, "Training Room 1A".
929    #[serde(rename="resourceName")]
930    pub resource_name: Option<String>,
931    /// no description provided
932    #[serde(rename="featureInstances")]
933    pub feature_instances: Option<String>,
934    /// Name of the section within a floor a resource is located in.
935    #[serde(rename="floorSection")]
936    pub floor_section: Option<String>,
937    /// The unique ID for the calendar resource.
938    #[serde(rename="resourceId")]
939    pub resource_id: Option<String>,
940    /// Unique ID for the building a resource is located in.
941    #[serde(rename="buildingId")]
942    pub building_id: Option<String>,
943    /// Name of the floor a resource is located on.
944    #[serde(rename="floorName")]
945    pub floor_name: Option<String>,
946    /// Description of the resource, visible to users and admins.
947    #[serde(rename="userVisibleDescription")]
948    pub user_visible_description: Option<String>,
949}
950
951impl RequestValue for CalendarResource {}
952impl ResponseResult for CalendarResource {}
953
954
955/// List of CPU temperature samples.
956/// 
957/// This type is not used in any activity, and only used as *part* of another schema.
958/// 
959#[derive(Default, Clone, Debug, Serialize, Deserialize)]
960pub struct ChromeOsDeviceCpuStatusReportsCpuTemperatureInfo {
961    /// Temperature in Celsius degrees.
962    pub temperature: Option<i32>,
963    /// CPU label
964    pub label: Option<String>,
965}
966
967impl NestedType for ChromeOsDeviceCpuStatusReportsCpuTemperatureInfo {}
968impl Part for ChromeOsDeviceCpuStatusReportsCpuTemperatureInfo {}
969
970
971/// JSON template for roleAssignment resource in Directory API.
972/// 
973/// # Activities
974/// 
975/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
976/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
977/// 
978/// * [insert role assignments](struct.RoleAssignmentInsertCall.html) (request|response)
979/// * [list role assignments](struct.RoleAssignmentListCall.html) (none)
980/// * [delete role assignments](struct.RoleAssignmentDeleteCall.html) (none)
981/// * [get role assignments](struct.RoleAssignmentGetCall.html) (response)
982/// 
983#[derive(Default, Clone, Debug, Serialize, Deserialize)]
984pub struct RoleAssignment {
985    /// The unique ID of the user this role is assigned to.
986    #[serde(rename="assignedTo")]
987    pub assigned_to: Option<String>,
988    /// The type of the API resource. This is always admin#directory#roleAssignment.
989    pub kind: Option<String>,
990    /// ETag of the resource.
991    pub etag: Option<String>,
992    /// ID of this roleAssignment.
993    #[serde(rename="roleAssignmentId")]
994    pub role_assignment_id: Option<String>,
995    /// The ID of the role that is assigned.
996    #[serde(rename="roleId")]
997    pub role_id: Option<String>,
998    /// The scope in which this role is assigned. Possible values are: 
999    /// - CUSTOMER
1000    /// - ORG_UNIT
1001    #[serde(rename="scopeType")]
1002    pub scope_type: Option<String>,
1003    /// If the role is restricted to an organization unit, this contains the ID for the organization unit the exercise of this role is restricted to.
1004    #[serde(rename="orgUnitId")]
1005    pub org_unit_id: Option<String>,
1006}
1007
1008impl RequestValue for RoleAssignment {}
1009impl Resource for RoleAssignment {}
1010impl ResponseResult for RoleAssignment {}
1011
1012
1013/// Template for notifications list response.
1014/// 
1015/// # Activities
1016/// 
1017/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1018/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1019/// 
1020/// * [list notifications](struct.NotificationListCall.html) (response)
1021/// 
1022#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1023pub struct Notifications {
1024    /// Token for fetching the next page of notifications.
1025    #[serde(rename="nextPageToken")]
1026    pub next_page_token: Option<String>,
1027    /// List of notifications in this page.
1028    pub items: Option<Vec<Notification>>,
1029    /// The type of the resource.
1030    pub kind: Option<String>,
1031    /// ETag of the resource.
1032    pub etag: Option<String>,
1033    /// Number of unread notification for the domain.
1034    #[serde(rename="unreadNotificationsCount")]
1035    pub unread_notifications_count: Option<i32>,
1036}
1037
1038impl ResponseResult for Notifications {}
1039
1040
1041/// JSON template for Domain Alias object in Directory API.
1042/// 
1043/// # Activities
1044/// 
1045/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1046/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1047/// 
1048/// * [get domain aliases](struct.DomainAliaseGetCall.html) (response)
1049/// * [insert domain aliases](struct.DomainAliaseInsertCall.html) (request|response)
1050/// 
1051#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1052pub struct DomainAlias {
1053    /// Kind of resource this is.
1054    pub kind: Option<String>,
1055    /// ETag of the resource.
1056    pub etag: Option<String>,
1057    /// Indicates the verification state of a domain alias. (Read-only)
1058    pub verified: Option<bool>,
1059    /// The domain alias name.
1060    #[serde(rename="domainAliasName")]
1061    pub domain_alias_name: Option<String>,
1062    /// The creation time of the domain alias. (Read-only).
1063    #[serde(rename="creationTime")]
1064    pub creation_time: Option<String>,
1065    /// The parent domain name that the domain alias is associated with. This can either be a primary or secondary domain name within a customer.
1066    #[serde(rename="parentDomainName")]
1067    pub parent_domain_name: Option<String>,
1068}
1069
1070impl RequestValue for DomainAlias {}
1071impl ResponseResult for DomainAlias {}
1072
1073
1074/// JSON template for User object in Directory API.
1075/// 
1076/// # Activities
1077/// 
1078/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1079/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1080/// 
1081/// * [photos patch users](struct.UserPhotoPatchCall.html) (none)
1082/// * [aliases delete users](struct.UserAliaseDeleteCall.html) (none)
1083/// * [undelete users](struct.UserUndeleteCall.html) (none)
1084/// * [photos get users](struct.UserPhotoGetCall.html) (none)
1085/// * [update users](struct.UserUpdateCall.html) (request|response)
1086/// * [aliases watch users](struct.UserAliaseWatchCall.html) (none)
1087/// * [insert users](struct.UserInsertCall.html) (request|response)
1088/// * [photos delete users](struct.UserPhotoDeleteCall.html) (none)
1089/// * [patch users](struct.UserPatchCall.html) (request|response)
1090/// * [photos update users](struct.UserPhotoUpdateCall.html) (none)
1091/// * [watch users](struct.UserWatchCall.html) (none)
1092/// * [get users](struct.UserGetCall.html) (response)
1093/// * [aliases insert users](struct.UserAliaseInsertCall.html) (none)
1094/// * [make admin users](struct.UserMakeAdminCall.html) (none)
1095/// * [aliases list users](struct.UserAliaseListCall.html) (none)
1096/// * [list users](struct.UserListCall.html) (none)
1097/// * [delete users](struct.UserDeleteCall.html) (none)
1098/// 
1099#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1100pub struct User {
1101    /// no description provided
1102    pub addresses: Option<String>,
1103    /// no description provided
1104    #[serde(rename="posixAccounts")]
1105    pub posix_accounts: Option<String>,
1106    /// no description provided
1107    pub phones: Option<String>,
1108    /// no description provided
1109    pub locations: Option<String>,
1110    /// Boolean indicating if the user is delegated admin (Read-only)
1111    #[serde(rename="isDelegatedAdmin")]
1112    pub is_delegated_admin: Option<bool>,
1113    /// ETag of the user's photo (Read-only)
1114    #[serde(rename="thumbnailPhotoEtag")]
1115    pub thumbnail_photo_etag: Option<String>,
1116    /// Indicates if user is suspended.
1117    pub suspended: Option<bool>,
1118    /// no description provided
1119    pub keywords: Option<String>,
1120    /// Kind of resource this is.
1121    pub kind: Option<String>,
1122    /// Unique identifier of User (Read-only)
1123    pub id: Option<String>,
1124    /// List of aliases (Read-only)
1125    pub aliases: Option<Vec<String>>,
1126    /// List of non editable aliases (Read-only)
1127    #[serde(rename="nonEditableAliases")]
1128    pub non_editable_aliases: Option<Vec<String>>,
1129    /// Indicates if user is archived.
1130    pub archived: Option<bool>,
1131    /// no description provided
1132    #[serde(rename="deletionTime")]
1133    pub deletion_time: Option<String>,
1134    /// Suspension reason if user is suspended (Read-only)
1135    #[serde(rename="suspensionReason")]
1136    pub suspension_reason: Option<String>,
1137    /// Photo Url of the user (Read-only)
1138    #[serde(rename="thumbnailPhotoUrl")]
1139    pub thumbnail_photo_url: Option<String>,
1140    /// Is enrolled in 2-step verification (Read-only)
1141    #[serde(rename="isEnrolledIn2Sv")]
1142    pub is_enrolled_in2_sv: Option<bool>,
1143    /// Boolean indicating if user is included in Global Address List
1144    #[serde(rename="includeInGlobalAddressList")]
1145    pub include_in_global_address_list: Option<bool>,
1146    /// no description provided
1147    pub relations: Option<String>,
1148    /// no description provided
1149    pub languages: Option<String>,
1150    /// Boolean indicating if the user is admin (Read-only)
1151    #[serde(rename="isAdmin")]
1152    pub is_admin: Option<bool>,
1153    /// ETag of the resource.
1154    pub etag: Option<String>,
1155    /// User's last login time. (Read-only)
1156    #[serde(rename="lastLoginTime")]
1157    pub last_login_time: Option<String>,
1158    /// CustomerId of User (Read-only)
1159    #[serde(rename="customerId")]
1160    pub customer_id: Option<String>,
1161    /// OrgUnit of User
1162    #[serde(rename="orgUnitPath")]
1163    pub org_unit_path: Option<String>,
1164    /// Indicates if user has agreed to terms (Read-only)
1165    #[serde(rename="agreedToTerms")]
1166    pub agreed_to_terms: Option<bool>,
1167    /// no description provided
1168    #[serde(rename="externalIds")]
1169    pub external_ids: Option<String>,
1170    /// Boolean indicating if ip is whitelisted
1171    #[serde(rename="ipWhitelisted")]
1172    pub ip_whitelisted: Option<bool>,
1173    /// no description provided
1174    #[serde(rename="sshPublicKeys")]
1175    pub ssh_public_keys: Option<String>,
1176    /// Custom fields of the user.
1177    #[serde(rename="customSchemas")]
1178    pub custom_schemas: Option<HashMap<String, UserCustomProperties>>,
1179    /// Is 2-step verification enforced (Read-only)
1180    #[serde(rename="isEnforcedIn2Sv")]
1181    pub is_enforced_in2_sv: Option<bool>,
1182    /// Is mailbox setup (Read-only)
1183    #[serde(rename="isMailboxSetup")]
1184    pub is_mailbox_setup: Option<bool>,
1185    /// User's password
1186    pub password: Option<String>,
1187    /// no description provided
1188    pub emails: Option<String>,
1189    /// no description provided
1190    pub organizations: Option<String>,
1191    /// username of User
1192    #[serde(rename="primaryEmail")]
1193    pub primary_email: Option<String>,
1194    /// Hash function name for password. Supported are MD5, SHA-1 and crypt
1195    #[serde(rename="hashFunction")]
1196    pub hash_function: Option<String>,
1197    /// User's name
1198    pub name: Option<UserName>,
1199    /// no description provided
1200    pub gender: Option<String>,
1201    /// no description provided
1202    pub notes: Option<String>,
1203    /// User's G Suite account creation time. (Read-only)
1204    #[serde(rename="creationTime")]
1205    pub creation_time: Option<String>,
1206    /// no description provided
1207    pub websites: Option<String>,
1208    /// Boolean indicating if the user should change password in next login
1209    #[serde(rename="changePasswordAtNextLogin")]
1210    pub change_password_at_next_login: Option<bool>,
1211    /// no description provided
1212    pub ims: Option<String>,
1213    /// Recovery email of the user.
1214    #[serde(rename="recoveryEmail")]
1215    pub recovery_email: Option<String>,
1216    /// Recovery phone of the user. The phone number must be in the E.164 format, starting with the plus sign (+). Example: +16506661212.
1217    #[serde(rename="recoveryPhone")]
1218    pub recovery_phone: Option<String>,
1219}
1220
1221impl RequestValue for User {}
1222impl Resource for User {}
1223impl ResponseResult for User {}
1224
1225
1226/// JSON response template for List Groups operation in Directory API.
1227/// 
1228/// # Activities
1229/// 
1230/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1231/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1232/// 
1233/// * [list groups](struct.GroupListCall.html) (response)
1234/// 
1235#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1236pub struct Groups {
1237    /// Token used to access next page of this result.
1238    #[serde(rename="nextPageToken")]
1239    pub next_page_token: Option<String>,
1240    /// Kind of resource this is.
1241    pub kind: Option<String>,
1242    /// ETag of the resource.
1243    pub etag: Option<String>,
1244    /// List of group objects.
1245    pub groups: Option<Vec<Group>>,
1246}
1247
1248impl ResponseResult for Groups {}
1249
1250
1251/// JSON template for Chrome Os Device resource in Directory API.
1252/// 
1253/// # Activities
1254/// 
1255/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1256/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1257/// 
1258/// * [get chromeosdevices](struct.ChromeosdeviceGetCall.html) (response)
1259/// * [update chromeosdevices](struct.ChromeosdeviceUpdateCall.html) (request|response)
1260/// * [patch chromeosdevices](struct.ChromeosdevicePatchCall.html) (request|response)
1261/// 
1262#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1263pub struct ChromeOsDevice {
1264    /// Chromebook Mac Address on wifi network interface (Read-only)
1265    #[serde(rename="macAddress")]
1266    pub mac_address: Option<String>,
1267    /// Date and time the device was last synchronized with the policy settings in the G Suite administrator control panel (Read-only)
1268    #[serde(rename="lastSync")]
1269    pub last_sync: Option<String>,
1270    /// Chromebook order number (Read-only)
1271    #[serde(rename="orderNumber")]
1272    pub order_number: Option<String>,
1273    /// Address or location of the device as noted by the administrator
1274    #[serde(rename="annotatedLocation")]
1275    pub annotated_location: Option<String>,
1276    /// Reports of disk space and other info about mounted/connected volumes.
1277    #[serde(rename="diskVolumeReports")]
1278    pub disk_volume_reports: Option<Vec<ChromeOsDeviceDiskVolumeReports>>,
1279    /// List of active time ranges (Read-only)
1280    #[serde(rename="activeTimeRanges")]
1281    pub active_time_ranges: Option<Vec<ChromeOsDeviceActiveTimeRanges>>,
1282    /// Reports of amounts of available RAM memory (Read-only)
1283    #[serde(rename="systemRamFreeReports")]
1284    pub system_ram_free_reports: Option<Vec<ChromeOsDeviceSystemRamFreeReports>>,
1285    /// AssetId specified during enrollment or through later annotation
1286    #[serde(rename="annotatedAssetId")]
1287    pub annotated_asset_id: Option<String>,
1288    /// Chromebook firmware version (Read-only)
1289    #[serde(rename="firmwareVersion")]
1290    pub firmware_version: Option<String>,
1291    /// Total RAM on the device [in bytes] (Read-only)
1292    #[serde(rename="systemRamTotal")]
1293    pub system_ram_total: Option<String>,
1294    /// (Read-only) The timestamp after which the device will stop receiving Chrome updates or support
1295    #[serde(rename="autoUpdateExpiration")]
1296    pub auto_update_expiration: Option<String>,
1297    /// (Read-only) MAC address used by the Chromebook’s internal ethernet port, and for onboard network (ethernet) interface. The format is twelve (12) hexadecimal digits without any delimiter (uppercase letters). This is only relevant for some devices.
1298    #[serde(rename="ethernetMacAddress0")]
1299    pub ethernet_mac_address0: Option<String>,
1300    /// Chromebook boot mode (Read-only)
1301    #[serde(rename="bootMode")]
1302    pub boot_mode: Option<String>,
1303    /// ETag of the resource.
1304    pub etag: Option<String>,
1305    /// OrgUnit of the device
1306    #[serde(rename="orgUnitPath")]
1307    pub org_unit_path: Option<String>,
1308    /// List of recent device users, in descending order by last login time (Read-only)
1309    #[serde(rename="recentUsers")]
1310    pub recent_users: Option<Vec<ChromeOsDeviceRecentUsers>>,
1311    /// Date and time the device was last enrolled (Read-only)
1312    #[serde(rename="lastEnrollmentTime")]
1313    pub last_enrollment_time: Option<String>,
1314    /// Chromebook Mac Address on ethernet network interface (Read-only)
1315    #[serde(rename="ethernetMacAddress")]
1316    pub ethernet_mac_address: Option<String>,
1317    /// Contains either the Mobile Equipment identifier (MEID) or the International Mobile Equipment Identity (IMEI) for the 3G mobile card in the Chromebook (Read-only)
1318    pub meid: Option<String>,
1319    /// User of the device
1320    #[serde(rename="annotatedUser")]
1321    pub annotated_user: Option<String>,
1322    /// Reports of CPU utilization and temperature (Read-only)
1323    #[serde(rename="cpuStatusReports")]
1324    pub cpu_status_reports: Option<Vec<ChromeOsDeviceCpuStatusReports>>,
1325    /// Chromebook platform version (Read-only)
1326    #[serde(rename="platformVersion")]
1327    pub platform_version: Option<String>,
1328    /// Chromebook Os Version (Read-only)
1329    #[serde(rename="osVersion")]
1330    pub os_version: Option<String>,
1331    /// (Read-only) Built-in MAC address for the docking station that the device connected to. Factory sets Media access control address (MAC address) assigned for use by a dock. Currently this is only supported on the Dell Arcada / Sarien devices and the Dell WD19 / WD19TB Docking Station. It is reserved specifically for MAC pass through device policy. The format is twelve (12) hexadecimal digits without any delimiter (uppercase letters). This is only relevant for Dell devices.
1332    #[serde(rename="dockMacAddress")]
1333    pub dock_mac_address: Option<String>,
1334    /// Will Chromebook auto renew after support end date (Read-only)
1335    #[serde(rename="willAutoRenew")]
1336    pub will_auto_renew: Option<bool>,
1337    /// Kind of resource this is.
1338    pub kind: Option<String>,
1339    /// List of device files to download (Read-only)
1340    #[serde(rename="deviceFiles")]
1341    pub device_files: Option<Vec<ChromeOsDeviceDeviceFiles>>,
1342    /// Notes added by the administrator
1343    pub notes: Option<String>,
1344    /// Chromebook serial number (Read-only)
1345    #[serde(rename="serialNumber")]
1346    pub serial_number: Option<String>,
1347    /// (Read-only) The date the device was manufactured in yyyy-mm-dd format.
1348    #[serde(rename="manufactureDate")]
1349    pub manufacture_date: Option<String>,
1350    /// status of the device (Read-only)
1351    pub status: Option<String>,
1352    /// Final date the device will be supported (Read-only)
1353    #[serde(rename="supportEndDate")]
1354    pub support_end_date: Option<String>,
1355    /// Trusted Platform Module (TPM) (Read-only)
1356    #[serde(rename="tpmVersionInfo")]
1357    pub tpm_version_info: Option<ChromeOsDeviceTpmVersionInfo>,
1358    /// Chromebook Model (Read-only)
1359    pub model: Option<String>,
1360    /// Unique identifier of Chrome OS Device (Read-only)
1361    #[serde(rename="deviceId")]
1362    pub device_id: Option<String>,
1363}
1364
1365impl RequestValue for ChromeOsDevice {}
1366impl Resource for ChromeOsDevice {}
1367impl ResponseResult for ChromeOsDevice {}
1368
1369
1370/// Trusted Platform Module (TPM) (Read-only)
1371/// 
1372/// This type is not used in any activity, and only used as *part* of another schema.
1373/// 
1374#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1375pub struct ChromeOsDeviceTpmVersionInfo {
1376    /// TPM specification level.
1377    #[serde(rename="specLevel")]
1378    pub spec_level: Option<String>,
1379    /// TPM model number.
1380    #[serde(rename="tpmModel")]
1381    pub tpm_model: Option<String>,
1382    /// Vendor-specific information such as Vendor ID.
1383    #[serde(rename="vendorSpecific")]
1384    pub vendor_specific: Option<String>,
1385    /// TPM family.
1386    pub family: Option<String>,
1387    /// TPM firmware version.
1388    #[serde(rename="firmwareVersion")]
1389    pub firmware_version: Option<String>,
1390    /// TPM manufacturer code.
1391    pub manufacturer: Option<String>,
1392}
1393
1394impl NestedType for ChromeOsDeviceTpmVersionInfo {}
1395impl Part for ChromeOsDeviceTpmVersionInfo {}
1396
1397
1398/// Disk volumes
1399/// 
1400/// This type is not used in any activity, and only used as *part* of another schema.
1401/// 
1402#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1403pub struct ChromeOsDeviceDiskVolumeReportsVolumeInfo {
1404    /// Volume id
1405    #[serde(rename="volumeId")]
1406    pub volume_id: Option<String>,
1407    /// Free disk space [in bytes]
1408    #[serde(rename="storageFree")]
1409    pub storage_free: Option<String>,
1410    /// Total disk space [in bytes]
1411    #[serde(rename="storageTotal")]
1412    pub storage_total: Option<String>,
1413}
1414
1415impl NestedType for ChromeOsDeviceDiskVolumeReportsVolumeInfo {}
1416impl Part for ChromeOsDeviceDiskVolumeReportsVolumeInfo {}
1417
1418
1419/// JSON template for Building object in Directory API.
1420/// 
1421/// # Activities
1422/// 
1423/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1424/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1425/// 
1426/// * [buildings patch resources](struct.ResourceBuildingPatchCall.html) (request|response)
1427/// * [buildings insert resources](struct.ResourceBuildingInsertCall.html) (request|response)
1428/// * [buildings update resources](struct.ResourceBuildingUpdateCall.html) (request|response)
1429/// * [buildings get resources](struct.ResourceBuildingGetCall.html) (response)
1430/// 
1431#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1432pub struct Building {
1433    /// Kind of resource this is.
1434    pub kind: Option<String>,
1435    /// The building name as seen by users in Calendar. Must be unique for the customer. For example, "NYC-CHEL". The maximum length is 100 characters.
1436    #[serde(rename="buildingName")]
1437    pub building_name: Option<String>,
1438    /// The geographic coordinates of the center of the building, expressed as latitude and longitude in decimal degrees.
1439    pub coordinates: Option<BuildingCoordinates>,
1440    /// ETag of the resource.
1441    pub etags: Option<String>,
1442    /// The postal address of the building. See PostalAddress for details. Note that only a single address line and region code are required.
1443    pub address: Option<BuildingAddress>,
1444    /// The display names for all floors in this building. The floors are expected to be sorted in ascending order, from lowest floor to highest floor. For example, ["B2", "B1", "L", "1", "2", "2M", "3", "PH"] Must contain at least one entry.
1445    #[serde(rename="floorNames")]
1446    pub floor_names: Option<Vec<String>>,
1447    /// Unique identifier for the building. The maximum length is 100 characters.
1448    #[serde(rename="buildingId")]
1449    pub building_id: Option<String>,
1450    /// A brief description of the building. For example, "Chelsea Market".
1451    pub description: Option<String>,
1452}
1453
1454impl RequestValue for Building {}
1455impl ResponseResult for Building {}
1456
1457
1458/// JSON template for a set of custom properties (i.e. all fields in a particular schema)
1459/// 
1460/// This type is not used in any activity, and only used as *part* of another schema.
1461/// 
1462#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1463pub struct UserCustomProperties(Option<HashMap<String, String>>);
1464
1465impl Part for UserCustomProperties {}
1466
1467
1468/// JSON template for FieldSpec resource for Schemas in Directory API.
1469/// 
1470/// This type is not used in any activity, and only used as *part* of another schema.
1471/// 
1472#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1473pub struct SchemaFieldSpec {
1474    /// Kind of resource this is.
1475    pub kind: Option<String>,
1476    /// Display Name of the field.
1477    #[serde(rename="displayName")]
1478    pub display_name: Option<String>,
1479    /// ETag of the resource.
1480    pub etag: Option<String>,
1481    /// Name of the field.
1482    #[serde(rename="fieldName")]
1483    pub field_name: Option<String>,
1484    /// Type of the field.
1485    #[serde(rename="fieldType")]
1486    pub field_type: Option<String>,
1487    /// Boolean specifying whether the field is indexed or not.
1488    pub indexed: Option<bool>,
1489    /// Read ACLs on the field specifying who can view values of this field. Valid values are "ALL_DOMAIN_USERS" and "ADMINS_AND_SELF".
1490    #[serde(rename="readAccessType")]
1491    pub read_access_type: Option<String>,
1492    /// 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.
1493    #[serde(rename="numericIndexingSpec")]
1494    pub numeric_indexing_spec: Option<SchemaFieldSpecNumericIndexingSpec>,
1495    /// Unique identifier of Field (Read-only)
1496    #[serde(rename="fieldId")]
1497    pub field_id: Option<String>,
1498    /// Boolean specifying whether this is a multi-valued field or not.
1499    #[serde(rename="multiValued")]
1500    pub multi_valued: Option<bool>,
1501}
1502
1503impl Part for SchemaFieldSpec {}
1504
1505
1506/// JSON response template for List roles operation in Directory API.
1507/// 
1508/// # Activities
1509/// 
1510/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1511/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1512/// 
1513/// * [list roles](struct.RoleListCall.html) (response)
1514/// 
1515#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1516pub struct Roles {
1517    /// no description provided
1518    #[serde(rename="nextPageToken")]
1519    pub next_page_token: Option<String>,
1520    /// A list of Role resources.
1521    pub items: Option<Vec<Role>>,
1522    /// The type of the API resource. This is always admin#directory#roles.
1523    pub kind: Option<String>,
1524    /// ETag of the resource.
1525    pub etag: Option<String>,
1526}
1527
1528impl ResponseResult for Roles {}
1529
1530
1531/// JSON template for Feature object in Directory API.
1532/// 
1533/// # Activities
1534/// 
1535/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1536/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1537/// 
1538/// * [features get resources](struct.ResourceFeatureGetCall.html) (response)
1539/// * [features update resources](struct.ResourceFeatureUpdateCall.html) (request|response)
1540/// * [features patch resources](struct.ResourceFeaturePatchCall.html) (request|response)
1541/// * [features insert resources](struct.ResourceFeatureInsertCall.html) (request|response)
1542/// 
1543#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1544pub struct Feature {
1545    /// Kind of resource this is.
1546    pub kind: Option<String>,
1547    /// ETag of the resource.
1548    pub etags: Option<String>,
1549    /// The name of the feature.
1550    pub name: Option<String>,
1551}
1552
1553impl RequestValue for Feature {}
1554impl ResponseResult for Feature {}
1555
1556
1557/// JSON response template for List verification codes operation in Directory API.
1558/// 
1559/// # Activities
1560/// 
1561/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1562/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1563/// 
1564/// * [list verification codes](struct.VerificationCodeListCall.html) (response)
1565/// 
1566#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1567pub struct VerificationCodes {
1568    /// A list of verification code resources.
1569    pub items: Option<Vec<VerificationCode>>,
1570    /// The type of the resource. This is always admin#directory#verificationCodesList.
1571    pub kind: Option<String>,
1572    /// ETag of the resource.
1573    pub etag: Option<String>,
1574}
1575
1576impl ResponseResult for VerificationCodes {}
1577
1578
1579/// JSON response template for List Chrome OS Devices operation in Directory API.
1580/// 
1581/// # Activities
1582/// 
1583/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1584/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1585/// 
1586/// * [list chromeosdevices](struct.ChromeosdeviceListCall.html) (response)
1587/// 
1588#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1589pub struct ChromeOsDevices {
1590    /// Token used to access next page of this result.
1591    #[serde(rename="nextPageToken")]
1592    pub next_page_token: Option<String>,
1593    /// List of Chrome OS Device objects.
1594    pub chromeosdevices: Option<Vec<ChromeOsDevice>>,
1595    /// ETag of the resource.
1596    pub etag: Option<String>,
1597    /// Kind of resource this is.
1598    pub kind: Option<String>,
1599}
1600
1601impl ResponseResult for ChromeOsDevices {}
1602
1603
1604/// List of active time ranges (Read-only)
1605/// 
1606/// This type is not used in any activity, and only used as *part* of another schema.
1607/// 
1608#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1609pub struct ChromeOsDeviceActiveTimeRanges {
1610    /// Date of usage
1611    pub date: Option<String>,
1612    /// Duration in milliseconds
1613    #[serde(rename="activeTime")]
1614    pub active_time: Option<i32>,
1615}
1616
1617impl NestedType for ChromeOsDeviceActiveTimeRanges {}
1618impl Part for ChromeOsDeviceActiveTimeRanges {}
1619
1620
1621/// JSON template for Photo object in Directory API.
1622/// 
1623/// # Activities
1624/// 
1625/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1626/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1627/// 
1628/// * [photos update users](struct.UserPhotoUpdateCall.html) (request|response)
1629/// * [photos patch users](struct.UserPhotoPatchCall.html) (request|response)
1630/// * [photos get users](struct.UserPhotoGetCall.html) (response)
1631/// 
1632#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1633pub struct UserPhoto {
1634    /// Mime Type of the photo
1635    #[serde(rename="mimeType")]
1636    pub mime_type: Option<String>,
1637    /// Kind of resource this is.
1638    pub kind: Option<String>,
1639    /// Base64 encoded photo data
1640    #[serde(rename="photoData")]
1641    pub photo_data: Option<String>,
1642    /// Height in pixels of the photo
1643    pub height: Option<i32>,
1644    /// Width in pixels of the photo
1645    pub width: Option<i32>,
1646    /// ETag of the resource.
1647    pub etag: Option<String>,
1648    /// Primary email of User (Read-only)
1649    #[serde(rename="primaryEmail")]
1650    pub primary_email: Option<String>,
1651    /// Unique identifier of User (Read-only)
1652    pub id: Option<String>,
1653}
1654
1655impl RequestValue for UserPhoto {}
1656impl ResponseResult for UserPhoto {}
1657
1658
1659/// List of applications installed on Mobile Device
1660/// 
1661/// This type is not used in any activity, and only used as *part* of another schema.
1662/// 
1663#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1664pub struct MobileDeviceApplications {
1665    /// Version code of application
1666    #[serde(rename="versionCode")]
1667    pub version_code: Option<i32>,
1668    /// Package name of application
1669    #[serde(rename="packageName")]
1670    pub package_name: Option<String>,
1671    /// Display name of application
1672    #[serde(rename="displayName")]
1673    pub display_name: Option<String>,
1674    /// Version name of application
1675    #[serde(rename="versionName")]
1676    pub version_name: Option<String>,
1677    /// List of Permissions for application
1678    pub permission: Option<Vec<String>>,
1679}
1680
1681impl NestedType for MobileDeviceApplications {}
1682impl Part for MobileDeviceApplications {}
1683
1684
1685/// JSON request template for setting/revoking admin status of a user in Directory API.
1686/// 
1687/// # Activities
1688/// 
1689/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1690/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1691/// 
1692/// * [make admin users](struct.UserMakeAdminCall.html) (request)
1693/// 
1694#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1695pub struct UserMakeAdmin {
1696    /// Boolean indicating new admin status of the user
1697    pub status: Option<bool>,
1698}
1699
1700impl RequestValue for UserMakeAdmin {}
1701
1702
1703/// JSON template for Feature List Response object in Directory API.
1704/// 
1705/// # Activities
1706/// 
1707/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1708/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1709/// 
1710/// * [features list resources](struct.ResourceFeatureListCall.html) (response)
1711/// 
1712#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1713pub struct Features {
1714    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
1715    #[serde(rename="nextPageToken")]
1716    pub next_page_token: Option<String>,
1717    /// Kind of resource this is.
1718    pub kind: Option<String>,
1719    /// ETag of the resource.
1720    pub etag: Option<String>,
1721    /// The Features in this page of results.
1722    pub features: Option<Vec<Feature>>,
1723}
1724
1725impl ResponseResult for Features {}
1726
1727
1728/// JSON template for the postal address of a building in Directory API.
1729/// 
1730/// This type is not used in any activity, and only used as *part* of another schema.
1731/// 
1732#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1733pub struct BuildingAddress {
1734    /// Optional. BCP-47 language code of the contents of this address (if known).
1735    #[serde(rename="languageCode")]
1736    pub language_code: Option<String>,
1737    /// Optional. Highest administrative subdivision which is used for postal addresses of a country or region.
1738    #[serde(rename="administrativeArea")]
1739    pub administrative_area: Option<String>,
1740    /// Required. CLDR region code of the country/region of the address.
1741    #[serde(rename="regionCode")]
1742    pub region_code: Option<String>,
1743    /// Optional. Generally refers to the city/town portion of the address. Examples: US city, IT comune, UK post town. In regions of the world where localities are not well defined or do not fit into this structure well, leave locality empty and use addressLines.
1744    pub locality: Option<String>,
1745    /// Optional. Postal code of the address.
1746    #[serde(rename="postalCode")]
1747    pub postal_code: Option<String>,
1748    /// Optional. Sublocality of the address.
1749    pub sublocality: Option<String>,
1750    /// Unstructured address lines describing the lower levels of an address.
1751    #[serde(rename="addressLines")]
1752    pub address_lines: Option<Vec<String>>,
1753}
1754
1755impl Part for BuildingAddress {}
1756
1757
1758/// JSON template for Mobile Device resource in Directory API.
1759/// 
1760/// # Activities
1761/// 
1762/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1763/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1764/// 
1765/// * [get mobiledevices](struct.MobiledeviceGetCall.html) (response)
1766/// 
1767#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1768pub struct MobileDevice {
1769    /// Date and time the device was last synchronized with the policy settings in the G Suite administrator control panel (Read-only)
1770    #[serde(rename="lastSync")]
1771    pub last_sync: Option<String>,
1772    /// Mobile Device compromised status (Read-only)
1773    #[serde(rename="deviceCompromisedStatus")]
1774    pub device_compromised_status: Option<String>,
1775    /// Unique identifier of Mobile Device (Read-only)
1776    #[serde(rename="resourceId")]
1777    pub resource_id: Option<String>,
1778    /// The default locale used on the Mobile Device (Read-only)
1779    #[serde(rename="defaultLanguage")]
1780    pub default_language: Option<String>,
1781    /// Mobile Device Hardware (Read-only)
1782    pub hardware: Option<String>,
1783    /// Mobile Device user agent
1784    #[serde(rename="userAgent")]
1785    pub user_agent: Option<String>,
1786    /// Date and time the device was first synchronized with the policy settings in the G Suite administrator control panel (Read-only)
1787    #[serde(rename="firstSync")]
1788    pub first_sync: Option<String>,
1789    /// List of accounts added on device (Read-only)
1790    #[serde(rename="otherAccountsInfo")]
1791    pub other_accounts_info: Option<Vec<String>>,
1792    /// Mobile Device release version version (Read-only)
1793    #[serde(rename="releaseVersion")]
1794    pub release_version: Option<String>,
1795    /// Mobile Device Hardware Id (Read-only)
1796    #[serde(rename="hardwareId")]
1797    pub hardware_id: Option<String>,
1798    /// ETag of the resource.
1799    pub etag: Option<String>,
1800    /// Mobile Device Security patch level (Read-only)
1801    #[serde(rename="securityPatchLevel")]
1802    pub security_patch_level: Option<String>,
1803    /// DMAgentPermission (Read-only)
1804    pub privilege: Option<String>,
1805    /// Mobile Device Encryption Status (Read-only)
1806    #[serde(rename="encryptionStatus")]
1807    pub encryption_status: Option<String>,
1808    /// The type of device (Read-only)
1809    #[serde(rename="type")]
1810    pub type_: Option<String>,
1811    /// List of owner user's email addresses (Read-only)
1812    pub email: Option<Vec<String>>,
1813    /// DevicePasswordStatus (Read-only)
1814    #[serde(rename="devicePasswordStatus")]
1815    pub device_password_status: Option<String>,
1816    /// Mobile Device Kernel version (Read-only)
1817    #[serde(rename="kernelVersion")]
1818    pub kernel_version: Option<String>,
1819    /// Mobile Device Brand (Read-only)
1820    pub brand: Option<String>,
1821    /// Mobile Device MEID number (Read-only)
1822    pub meid: Option<String>,
1823    /// Mobile Device Build number (Read-only)
1824    #[serde(rename="buildNumber")]
1825    pub build_number: Option<String>,
1826    /// List of applications installed on Mobile Device
1827    pub applications: Option<Vec<MobileDeviceApplications>>,
1828    /// Mobile Device serial number (Read-only)
1829    #[serde(rename="deviceId")]
1830    pub device_id: Option<String>,
1831    /// Mobile Device IMEI number (Read-only)
1832    pub imei: Option<String>,
1833    /// Adb (USB debugging) enabled or disabled on device (Read-only)
1834    #[serde(rename="adbStatus")]
1835    pub adb_status: Option<bool>,
1836    /// Mobile Device Bootloader version (Read-only)
1837    #[serde(rename="bootloaderVersion")]
1838    pub bootloader_version: Option<String>,
1839    /// Mobile Device manufacturer (Read-only)
1840    pub manufacturer: Option<String>,
1841    /// Mobile Device Baseband version (Read-only)
1842    #[serde(rename="basebandVersion")]
1843    pub baseband_version: Option<String>,
1844    /// Kind of resource this is.
1845    pub kind: Option<String>,
1846    /// Developer options enabled or disabled on device (Read-only)
1847    #[serde(rename="developerOptionsStatus")]
1848    pub developer_options_status: Option<bool>,
1849    /// List of owner user's names (Read-only)
1850    pub name: Option<Vec<String>>,
1851    /// Mobile Device SSN or Serial Number (Read-only)
1852    #[serde(rename="serialNumber")]
1853    pub serial_number: Option<String>,
1854    /// Work profile supported on device (Read-only)
1855    #[serde(rename="supportsWorkProfile")]
1856    pub supports_work_profile: Option<bool>,
1857    /// Mobile Device mobile or network operator (if available) (Read-only)
1858    #[serde(rename="networkOperator")]
1859    pub network_operator: Option<String>,
1860    /// Status of the device (Read-only)
1861    pub status: Option<String>,
1862    /// Unknown sources enabled or disabled on device (Read-only)
1863    #[serde(rename="unknownSourcesStatus")]
1864    pub unknown_sources_status: Option<bool>,
1865    /// Boolean indicating if this account is on owner/primary profile or not (Read-only)
1866    #[serde(rename="managedAccountIsOnOwnerProfile")]
1867    pub managed_account_is_on_owner_profile: Option<bool>,
1868    /// Name of the model of the device
1869    pub model: Option<String>,
1870    /// Name of the mobile operating system
1871    pub os: Option<String>,
1872    /// Mobile Device WiFi MAC address (Read-only)
1873    #[serde(rename="wifiMacAddress")]
1874    pub wifi_mac_address: Option<String>,
1875}
1876
1877impl Resource for MobileDevice {}
1878impl ResponseResult for MobileDevice {}
1879
1880
1881/// JSON response template to list Domains in Directory API.
1882/// 
1883/// # Activities
1884/// 
1885/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1886/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1887/// 
1888/// * [list domains](struct.DomainListCall.html) (response)
1889/// 
1890#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1891pub struct Domains2 {
1892    /// List of domain objects.
1893    pub domains: Option<Vec<Domains>>,
1894    /// Kind of resource this is.
1895    pub kind: Option<String>,
1896    /// ETag of the resource.
1897    pub etag: Option<String>,
1898}
1899
1900impl ResponseResult for Domains2 {}
1901
1902
1903/// JSON template for coordinates of a building in Directory API.
1904/// 
1905/// This type is not used in any activity, and only used as *part* of another schema.
1906/// 
1907#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1908pub struct BuildingCoordinates {
1909    /// Latitude in decimal degrees.
1910    pub latitude: Option<f64>,
1911    /// Longitude in decimal degrees.
1912    pub longitude: Option<f64>,
1913}
1914
1915impl Part for BuildingCoordinates {}
1916
1917
1918/// List of device files to download (Read-only)
1919/// 
1920/// This type is not used in any activity, and only used as *part* of another schema.
1921/// 
1922#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1923pub struct ChromeOsDeviceDeviceFiles {
1924    /// File download URL
1925    #[serde(rename="downloadUrl")]
1926    pub download_url: Option<String>,
1927    /// File type
1928    #[serde(rename="type")]
1929    pub type_: Option<String>,
1930    /// Date and time the file was created
1931    #[serde(rename="createTime")]
1932    pub create_time: Option<String>,
1933    /// File name
1934    pub name: Option<String>,
1935}
1936
1937impl NestedType for ChromeOsDeviceDeviceFiles {}
1938impl Part for ChromeOsDeviceDeviceFiles {}
1939
1940
1941/// JSON template for Has Member response in Directory API.
1942/// 
1943/// # Activities
1944/// 
1945/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1946/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1947/// 
1948/// * [has member members](struct.MemberHasMemberCall.html) (response)
1949/// 
1950#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1951pub struct MembersHasMember {
1952    /// Identifies whether the given user is a member of the group. Membership can be direct or nested.
1953    #[serde(rename="isMember")]
1954    pub is_member: Option<bool>,
1955}
1956
1957impl ResponseResult for MembersHasMember {}
1958
1959
1960/// JSON template for Alias object in Directory API.
1961/// 
1962/// # Activities
1963/// 
1964/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
1965/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1966/// 
1967/// * [aliases insert users](struct.UserAliaseInsertCall.html) (request|response)
1968/// * [aliases insert groups](struct.GroupAliaseInsertCall.html) (request|response)
1969/// 
1970#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1971pub struct Alias {
1972    /// A alias email
1973    pub alias: Option<String>,
1974    /// Kind of resource this is.
1975    pub kind: Option<String>,
1976    /// ETag of the resource.
1977    pub etag: Option<String>,
1978    /// Group's primary email (Read-only) User's primary email (Read-only)
1979    #[serde(rename="primaryEmail")]
1980    pub primary_email: Option<String>,
1981    /// Unique id of the group (Read-only) Unique id of the user (Read-only)
1982    pub id: Option<String>,
1983}
1984
1985impl RequestValue for Alias {}
1986impl ResponseResult for Alias {}
1987
1988
1989/// 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.
1990/// 
1991/// This type is not used in any activity, and only used as *part* of another schema.
1992/// 
1993#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1994pub struct SchemaFieldSpecNumericIndexingSpec {
1995    /// 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.
1996    #[serde(rename="maxValue")]
1997    pub max_value: Option<f64>,
1998    /// 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.
1999    #[serde(rename="minValue")]
2000    pub min_value: Option<f64>,
2001}
2002
2003impl NestedType for SchemaFieldSpecNumericIndexingSpec {}
2004impl Part for SchemaFieldSpecNumericIndexingSpec {}
2005
2006
2007/// Reports of CPU utilization and temperature (Read-only)
2008/// 
2009/// This type is not used in any activity, and only used as *part* of another schema.
2010/// 
2011#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2012pub struct ChromeOsDeviceCpuStatusReports {
2013    /// Date and time the report was received.
2014    #[serde(rename="reportTime")]
2015    pub report_time: Option<String>,
2016    /// List of CPU temperature samples.
2017    #[serde(rename="cpuTemperatureInfo")]
2018    pub cpu_temperature_info: Option<Vec<ChromeOsDeviceCpuStatusReportsCpuTemperatureInfo>>,
2019    /// no description provided
2020    #[serde(rename="cpuUtilizationPercentageInfo")]
2021    pub cpu_utilization_percentage_info: Option<Vec<i32>>,
2022}
2023
2024impl NestedType for ChromeOsDeviceCpuStatusReports {}
2025impl Part for ChromeOsDeviceCpuStatusReports {}
2026
2027
2028/// There is no detailed description.
2029/// 
2030/// # Activities
2031/// 
2032/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2033/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2034/// 
2035/// * [list asps](struct.AspListCall.html) (response)
2036/// 
2037#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2038pub struct Asps {
2039    /// A list of ASP resources.
2040    pub items: Option<Vec<Asp>>,
2041    /// The type of the API resource. This is always admin#directory#aspList.
2042    pub kind: Option<String>,
2043    /// ETag of the resource.
2044    pub etag: Option<String>,
2045}
2046
2047impl ResponseResult for Asps {}
2048
2049
2050/// JSON template for postal address of a customer.
2051/// 
2052/// This type is not used in any activity, and only used as *part* of another schema.
2053/// 
2054#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2055pub struct CustomerPostalAddress {
2056    /// The company or company division name.
2057    #[serde(rename="organizationName")]
2058    pub organization_name: Option<String>,
2059    /// This is a required property. For countryCode information see the ISO 3166 country code elements.
2060    #[serde(rename="countryCode")]
2061    pub country_code: Option<String>,
2062    /// Name of the locality. An example of a locality value is the city of San Francisco.
2063    pub locality: Option<String>,
2064    /// Name of the region. An example of a region value is NY for the state of New York.
2065    pub region: Option<String>,
2066    /// Address line 2 of the address.
2067    #[serde(rename="addressLine2")]
2068    pub address_line2: Option<String>,
2069    /// Address line 3 of the address.
2070    #[serde(rename="addressLine3")]
2071    pub address_line3: Option<String>,
2072    /// The customer contact's name.
2073    #[serde(rename="contactName")]
2074    pub contact_name: Option<String>,
2075    /// A customer's physical address. The address can be composed of one to three lines.
2076    #[serde(rename="addressLine1")]
2077    pub address_line1: Option<String>,
2078    /// The postal code. A postalCode example is a postal zip code such as 10009. This is in accordance with - http://portablecontacts.net/draft-spec.html#address_element.
2079    #[serde(rename="postalCode")]
2080    pub postal_code: Option<String>,
2081}
2082
2083impl Part for CustomerPostalAddress {}
2084
2085
2086/// An notification channel used to watch for resource changes.
2087/// 
2088/// # Activities
2089/// 
2090/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2091/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2092/// 
2093/// * [watch users](struct.UserWatchCall.html) (request|response)
2094/// * [stop channels](struct.ChannelStopCall.html) (request)
2095/// * [aliases watch users](struct.UserAliaseWatchCall.html) (request|response)
2096/// 
2097#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2098pub struct Channel {
2099    /// A version-specific identifier for the watched resource.
2100    #[serde(rename="resourceUri")]
2101    pub resource_uri: Option<String>,
2102    /// Identifies this as a notification channel used to watch for changes to a resource, which is "api#channel".
2103    pub kind: Option<String>,
2104    /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
2105    #[serde(rename="resourceId")]
2106    pub resource_id: Option<String>,
2107    /// A UUID or similar unique string that identifies this channel.
2108    pub id: Option<String>,
2109    /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
2110    pub token: Option<String>,
2111    /// Additional parameters controlling delivery channel behavior. Optional.
2112    pub params: Option<HashMap<String, String>>,
2113    /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
2114    pub expiration: Option<String>,
2115    /// The address where notifications are delivered for this channel.
2116    pub address: Option<String>,
2117    /// The type of delivery mechanism used for this channel.
2118    #[serde(rename="type")]
2119    pub type_: Option<String>,
2120    /// A Boolean value to indicate whether payload is wanted. Optional.
2121    pub payload: Option<bool>,
2122}
2123
2124impl RequestValue for Channel {}
2125impl Resource for Channel {}
2126impl ResponseResult for Channel {}
2127
2128
2129/// JSON template for Schema resource in Directory API.
2130/// 
2131/// # Activities
2132/// 
2133/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2134/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2135/// 
2136/// * [get schemas](struct.SchemaGetCall.html) (response)
2137/// * [insert schemas](struct.SchemaInsertCall.html) (request|response)
2138/// * [patch schemas](struct.SchemaPatchCall.html) (request|response)
2139/// * [delete schemas](struct.SchemaDeleteCall.html) (none)
2140/// * [list schemas](struct.SchemaListCall.html) (none)
2141/// * [update schemas](struct.SchemaUpdateCall.html) (request|response)
2142/// 
2143#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2144pub struct Schema {
2145    /// Kind of resource this is.
2146    pub kind: Option<String>,
2147    /// ETag of the resource.
2148    pub etag: Option<String>,
2149    /// Display name for the schema.
2150    #[serde(rename="displayName")]
2151    pub display_name: Option<String>,
2152    /// Fields of Schema
2153    pub fields: Option<Vec<SchemaFieldSpec>>,
2154    /// Unique identifier of Schema (Read-only)
2155    #[serde(rename="schemaId")]
2156    pub schema_id: Option<String>,
2157    /// Schema name
2158    #[serde(rename="schemaName")]
2159    pub schema_name: Option<String>,
2160}
2161
2162impl RequestValue for Schema {}
2163impl Resource for Schema {}
2164impl ResponseResult for Schema {}
2165
2166
2167/// JSON template for Building List Response object in Directory API.
2168/// 
2169/// # Activities
2170/// 
2171/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2172/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2173/// 
2174/// * [buildings list resources](struct.ResourceBuildingListCall.html) (response)
2175/// 
2176#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2177pub struct Buildings {
2178    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
2179    #[serde(rename="nextPageToken")]
2180    pub next_page_token: Option<String>,
2181    /// The Buildings in this page of results.
2182    pub buildings: Option<Vec<Building>>,
2183    /// ETag of the resource.
2184    pub etag: Option<String>,
2185    /// Kind of resource this is.
2186    pub kind: Option<String>,
2187}
2188
2189impl ResponseResult for Buildings {}
2190
2191
2192/// The template that returns individual ASP (Access Code) data.
2193/// 
2194/// # Activities
2195/// 
2196/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2197/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2198/// 
2199/// * [list asps](struct.AspListCall.html) (none)
2200/// * [delete asps](struct.AspDeleteCall.html) (none)
2201/// * [get asps](struct.AspGetCall.html) (response)
2202/// 
2203#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2204pub struct Asp {
2205    /// The type of the API resource. This is always admin#directory#asp.
2206    pub kind: Option<String>,
2207    /// ETag of the ASP.
2208    pub etag: Option<String>,
2209    /// The name of the application that the user, represented by their userId, entered when the ASP was created.
2210    pub name: Option<String>,
2211    /// The unique ID of the ASP.
2212    #[serde(rename="codeId")]
2213    pub code_id: Option<i32>,
2214    /// The time when the ASP was last used. Expressed in Unix time format.
2215    #[serde(rename="lastTimeUsed")]
2216    pub last_time_used: Option<String>,
2217    /// The unique ID of the user who issued the ASP.
2218    #[serde(rename="userKey")]
2219    pub user_key: Option<String>,
2220    /// The time when the ASP was created. Expressed in Unix time format.
2221    #[serde(rename="creationTime")]
2222    pub creation_time: Option<String>,
2223}
2224
2225impl Resource for Asp {}
2226impl ResponseResult for Asp {}
2227
2228
2229/// JSON response template for List Users operation in Apps Directory API.
2230/// 
2231/// # Activities
2232/// 
2233/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2234/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2235/// 
2236/// * [list users](struct.UserListCall.html) (response)
2237/// 
2238#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2239pub struct Users {
2240    /// Token used to access next page of this result.
2241    #[serde(rename="nextPageToken")]
2242    pub next_page_token: Option<String>,
2243    /// Kind of resource this is.
2244    pub kind: Option<String>,
2245    /// ETag of the resource.
2246    pub etag: Option<String>,
2247    /// Event that triggered this response (only used in case of Push Response)
2248    pub trigger_event: Option<String>,
2249    /// List of user objects.
2250    pub users: Option<Vec<User>>,
2251}
2252
2253impl ResponseResult for Users {}
2254
2255
2256/// Reports of amounts of available RAM memory (Read-only)
2257/// 
2258/// This type is not used in any activity, and only used as *part* of another schema.
2259/// 
2260#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2261pub struct ChromeOsDeviceSystemRamFreeReports {
2262    /// Date and time the report was received.
2263    #[serde(rename="reportTime")]
2264    pub report_time: Option<String>,
2265    /// no description provided
2266    #[serde(rename="systemRamFreeInfo")]
2267    pub system_ram_free_info: Option<Vec<String>>,
2268}
2269
2270impl NestedType for ChromeOsDeviceSystemRamFreeReports {}
2271impl Part for ChromeOsDeviceSystemRamFreeReports {}
2272
2273
2274/// JSON response template for List tokens operation in Directory API.
2275/// 
2276/// # Activities
2277/// 
2278/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2279/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2280/// 
2281/// * [list tokens](struct.TokenListCall.html) (response)
2282/// 
2283#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2284pub struct Tokens {
2285    /// A list of Token resources.
2286    pub items: Option<Vec<Token>>,
2287    /// The type of the API resource. This is always admin#directory#tokenList.
2288    pub kind: Option<String>,
2289    /// ETag of the resource.
2290    pub etag: Option<String>,
2291}
2292
2293impl ResponseResult for Tokens {}
2294
2295
2296/// JSON response template for List Members operation in Directory API.
2297/// 
2298/// # Activities
2299/// 
2300/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2301/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2302/// 
2303/// * [list members](struct.MemberListCall.html) (response)
2304/// 
2305#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2306pub struct Members {
2307    /// Token used to access next page of this result.
2308    #[serde(rename="nextPageToken")]
2309    pub next_page_token: Option<String>,
2310    /// Kind of resource this is.
2311    pub kind: Option<String>,
2312    /// ETag of the resource.
2313    pub etag: Option<String>,
2314    /// List of member objects.
2315    pub members: Option<Vec<Member>>,
2316}
2317
2318impl ResponseResult for Members {}
2319
2320
2321/// Reports of disk space and other info about mounted/connected volumes.
2322/// 
2323/// This type is not used in any activity, and only used as *part* of another schema.
2324/// 
2325#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2326pub struct ChromeOsDeviceDiskVolumeReports {
2327    /// Disk volumes
2328    #[serde(rename="volumeInfo")]
2329    pub volume_info: Option<Vec<ChromeOsDeviceDiskVolumeReportsVolumeInfo>>,
2330}
2331
2332impl NestedType for ChromeOsDeviceDiskVolumeReports {}
2333impl Part for ChromeOsDeviceDiskVolumeReports {}
2334
2335
2336/// List of recent device users, in descending order by last login time (Read-only)
2337/// 
2338/// This type is not used in any activity, and only used as *part* of another schema.
2339/// 
2340#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2341pub struct ChromeOsDeviceRecentUsers {
2342    /// The type of the user
2343    #[serde(rename="type")]
2344    pub type_: Option<String>,
2345    /// Email address of the user. Present only if the user type is managed
2346    pub email: Option<String>,
2347}
2348
2349impl NestedType for ChromeOsDeviceRecentUsers {}
2350impl Part for ChromeOsDeviceRecentUsers {}
2351
2352
2353/// JSON response template for List Mobile Devices operation in Directory API.
2354/// 
2355/// # Activities
2356/// 
2357/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2358/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2359/// 
2360/// * [list mobiledevices](struct.MobiledeviceListCall.html) (response)
2361/// 
2362#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2363pub struct MobileDevices {
2364    /// Token used to access next page of this result.
2365    #[serde(rename="nextPageToken")]
2366    pub next_page_token: Option<String>,
2367    /// Kind of resource this is.
2368    pub kind: Option<String>,
2369    /// ETag of the resource.
2370    pub etag: Option<String>,
2371    /// List of Mobile Device objects.
2372    pub mobiledevices: Option<Vec<MobileDevice>>,
2373}
2374
2375impl ResponseResult for MobileDevices {}
2376
2377
2378/// JSON request template for renaming a feature.
2379/// 
2380/// # Activities
2381/// 
2382/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2383/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2384/// 
2385/// * [features rename resources](struct.ResourceFeatureRenameCall.html) (request)
2386/// 
2387#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2388pub struct FeatureRename {
2389    /// New name of the feature.
2390    #[serde(rename="newName")]
2391    pub new_name: Option<String>,
2392}
2393
2394impl RequestValue for FeatureRename {}
2395
2396
2397/// JSON template for Customer Resource object in Directory API.
2398/// 
2399/// # Activities
2400/// 
2401/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2402/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2403/// 
2404/// * [patch customers](struct.CustomerPatchCall.html) (request|response)
2405/// * [update customers](struct.CustomerUpdateCall.html) (request|response)
2406/// * [get customers](struct.CustomerGetCall.html) (response)
2407/// 
2408#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2409pub struct Customer {
2410    /// The customer's primary domain name string. Do not include the www prefix when creating a new customer.
2411    #[serde(rename="customerDomain")]
2412    pub customer_domain: Option<String>,
2413    /// The customer's ISO 639-2 language code. The default value is en-US
2414    pub language: Option<String>,
2415    /// The customer's secondary contact email address. This email address cannot be on the same domain as the customerDomain
2416    #[serde(rename="alternateEmail")]
2417    pub alternate_email: Option<String>,
2418    /// The customer's creation time (Readonly)
2419    #[serde(rename="customerCreationTime")]
2420    pub customer_creation_time: Option<String>,
2421    /// Identifies the resource as a customer. Value: admin#directory#customer
2422    pub kind: Option<String>,
2423    /// ETag of the resource.
2424    pub etag: Option<String>,
2425    /// The customer's contact phone number in E.164 format.
2426    #[serde(rename="phoneNumber")]
2427    pub phone_number: Option<String>,
2428    /// The customer's postal address information.
2429    #[serde(rename="postalAddress")]
2430    pub postal_address: Option<CustomerPostalAddress>,
2431    /// The unique ID for the customer's G Suite account. (Readonly)
2432    pub id: Option<String>,
2433}
2434
2435impl RequestValue for Customer {}
2436impl Resource for Customer {}
2437impl ResponseResult for Customer {}
2438
2439
2440/// JSON response template for List Organization Units operation in Directory API.
2441/// 
2442/// # Activities
2443/// 
2444/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2445/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2446/// 
2447/// * [list orgunits](struct.OrgunitListCall.html) (response)
2448/// 
2449#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2450pub struct OrgUnits {
2451    /// Kind of resource this is.
2452    pub kind: Option<String>,
2453    /// ETag of the resource.
2454    pub etag: Option<String>,
2455    /// List of user objects.
2456    #[serde(rename="organizationUnits")]
2457    pub organization_units: Option<Vec<OrgUnit>>,
2458}
2459
2460impl ResponseResult for OrgUnits {}
2461
2462
2463/// JSON response template for List roleAssignments operation in Directory API.
2464/// 
2465/// # Activities
2466/// 
2467/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2468/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2469/// 
2470/// * [list role assignments](struct.RoleAssignmentListCall.html) (response)
2471/// 
2472#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2473pub struct RoleAssignments {
2474    /// no description provided
2475    #[serde(rename="nextPageToken")]
2476    pub next_page_token: Option<String>,
2477    /// A list of RoleAssignment resources.
2478    pub items: Option<Vec<RoleAssignment>>,
2479    /// The type of the API resource. This is always admin#directory#roleAssignments.
2480    pub kind: Option<String>,
2481    /// ETag of the resource.
2482    pub etag: Option<String>,
2483}
2484
2485impl ResponseResult for RoleAssignments {}
2486
2487
2488/// JSON request template to undelete a user in Directory API.
2489/// 
2490/// # Activities
2491/// 
2492/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2494/// 
2495/// * [undelete users](struct.UserUndeleteCall.html) (request)
2496/// 
2497#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2498pub struct UserUndelete {
2499    /// OrgUnit of User
2500    #[serde(rename="orgUnitPath")]
2501    pub org_unit_path: Option<String>,
2502}
2503
2504impl RequestValue for UserUndelete {}
2505
2506
2507/// The set of privileges that are granted to this role.
2508/// 
2509/// This type is not used in any activity, and only used as *part* of another schema.
2510/// 
2511#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2512pub struct RoleRolePrivileges {
2513    /// The obfuscated ID of the service this privilege is for. This value is returned with Privileges.list().
2514    #[serde(rename="serviceId")]
2515    pub service_id: Option<String>,
2516    /// The name of the privilege.
2517    #[serde(rename="privilegeName")]
2518    pub privilege_name: Option<String>,
2519}
2520
2521impl NestedType for RoleRolePrivileges {}
2522impl Part for RoleRolePrivileges {}
2523
2524
2525/// JSON request template for moving ChromeOs Device to given OU in Directory Devices API.
2526/// 
2527/// # Activities
2528/// 
2529/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2530/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2531/// 
2532/// * [move devices to ou chromeosdevices](struct.ChromeosdeviceMoveDevicesToOuCall.html) (request)
2533/// 
2534#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2535pub struct ChromeOsMoveDevicesToOu {
2536    /// ChromeOs Devices to be moved to OU
2537    #[serde(rename="deviceIds")]
2538    pub device_ids: Option<Vec<String>>,
2539}
2540
2541impl RequestValue for ChromeOsMoveDevicesToOu {}
2542
2543
2544/// JSON template for Domain object in Directory API.
2545/// 
2546/// # Activities
2547/// 
2548/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2549/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2550/// 
2551/// * [insert domains](struct.DomainInsertCall.html) (request|response)
2552/// * [get domains](struct.DomainGetCall.html) (response)
2553/// 
2554#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2555pub struct Domains {
2556    /// Kind of resource this is.
2557    pub kind: Option<String>,
2558    /// ETag of the resource.
2559    pub etag: Option<String>,
2560    /// Indicates the verification state of a domain. (Read-only).
2561    pub verified: Option<bool>,
2562    /// The domain name of the customer.
2563    #[serde(rename="domainName")]
2564    pub domain_name: Option<String>,
2565    /// List of domain alias objects. (Read-only)
2566    #[serde(rename="domainAliases")]
2567    pub domain_aliases: Option<Vec<DomainAlias>>,
2568    /// Indicates if the domain is a primary domain (Read-only).
2569    #[serde(rename="isPrimary")]
2570    pub is_primary: Option<bool>,
2571    /// Creation time of the domain. (Read-only).
2572    #[serde(rename="creationTime")]
2573    pub creation_time: Option<String>,
2574}
2575
2576impl RequestValue for Domains {}
2577impl ResponseResult for Domains {}
2578
2579
2580/// JSON response template to list domain aliases in Directory API.
2581/// 
2582/// # Activities
2583/// 
2584/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2585/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2586/// 
2587/// * [list domain aliases](struct.DomainAliaseListCall.html) (response)
2588/// 
2589#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2590pub struct DomainAliases {
2591    /// List of domain alias objects.
2592    #[serde(rename="domainAliases")]
2593    pub domain_aliases: Option<Vec<DomainAlias>>,
2594    /// Kind of resource this is.
2595    pub kind: Option<String>,
2596    /// ETag of the resource.
2597    pub etag: Option<String>,
2598}
2599
2600impl ResponseResult for DomainAliases {}
2601
2602
2603/// JSON template for token resource in Directory API.
2604/// 
2605/// # Activities
2606/// 
2607/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2608/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2609/// 
2610/// * [list tokens](struct.TokenListCall.html) (none)
2611/// * [delete tokens](struct.TokenDeleteCall.html) (none)
2612/// * [get tokens](struct.TokenGetCall.html) (response)
2613/// 
2614#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2615pub struct Token {
2616    /// A list of authorization scopes the application is granted.
2617    pub scopes: Option<Vec<String>>,
2618    /// The type of the API resource. This is always admin#directory#token.
2619    pub kind: Option<String>,
2620    /// The Client ID of the application the token is issued to.
2621    #[serde(rename="clientId")]
2622    pub client_id: Option<String>,
2623    /// Whether the token is issued to an installed application. The value is true if the application is installed to a desktop or mobile device.
2624    #[serde(rename="nativeApp")]
2625    pub native_app: Option<bool>,
2626    /// The displayable name of the application the token is issued to.
2627    #[serde(rename="displayText")]
2628    pub display_text: Option<String>,
2629    /// ETag of the resource.
2630    pub etag: Option<String>,
2631    /// Whether the application is registered with Google. The value is true if the application has an anonymous Client ID.
2632    pub anonymous: Option<bool>,
2633    /// The unique ID of the user that issued the token.
2634    #[serde(rename="userKey")]
2635    pub user_key: Option<String>,
2636}
2637
2638impl Resource for Token {}
2639impl ResponseResult for Token {}
2640
2641
2642/// JSON template for Org Unit resource in Directory API.
2643/// 
2644/// # Activities
2645/// 
2646/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2647/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2648/// 
2649/// * [patch orgunits](struct.OrgunitPatchCall.html) (request|response)
2650/// * [get orgunits](struct.OrgunitGetCall.html) (response)
2651/// * [update orgunits](struct.OrgunitUpdateCall.html) (request|response)
2652/// * [insert orgunits](struct.OrgunitInsertCall.html) (request|response)
2653/// 
2654#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2655pub struct OrgUnit {
2656    /// Kind of resource this is.
2657    pub kind: Option<String>,
2658    /// Path of parent OrgUnit
2659    #[serde(rename="parentOrgUnitPath")]
2660    pub parent_org_unit_path: Option<String>,
2661    /// Name of OrgUnit
2662    pub name: Option<String>,
2663    /// ETag of the resource.
2664    pub etag: Option<String>,
2665    /// Id of OrgUnit
2666    #[serde(rename="orgUnitId")]
2667    pub org_unit_id: Option<String>,
2668    /// Id of parent OrgUnit
2669    #[serde(rename="parentOrgUnitId")]
2670    pub parent_org_unit_id: Option<String>,
2671    /// Should block inheritance
2672    #[serde(rename="blockInheritance")]
2673    pub block_inheritance: Option<bool>,
2674    /// Path of OrgUnit
2675    #[serde(rename="orgUnitPath")]
2676    pub org_unit_path: Option<String>,
2677    /// Description of OrgUnit
2678    pub description: Option<String>,
2679}
2680
2681impl RequestValue for OrgUnit {}
2682impl Resource for OrgUnit {}
2683impl ResponseResult for OrgUnit {}
2684
2685
2686/// JSON template for verification codes in Directory API.
2687/// 
2688/// # Activities
2689/// 
2690/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2691/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2692/// 
2693/// * [invalidate verification codes](struct.VerificationCodeInvalidateCall.html) (none)
2694/// * [list verification codes](struct.VerificationCodeListCall.html) (none)
2695/// * [generate verification codes](struct.VerificationCodeGenerateCall.html) (none)
2696/// 
2697#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2698pub struct VerificationCode {
2699    /// The type of the resource. This is always admin#directory#verificationCode.
2700    pub kind: Option<String>,
2701    /// ETag of the resource.
2702    pub etag: Option<String>,
2703    /// The obfuscated unique ID of the user.
2704    #[serde(rename="userId")]
2705    pub user_id: Option<String>,
2706    /// A current verification code for the user. Invalidated or used verification codes are not returned as part of the result.
2707    #[serde(rename="verificationCode")]
2708    pub verification_code: Option<String>,
2709}
2710
2711impl Resource for VerificationCode {}
2712
2713
2714/// JSON request template for firing actions on ChromeOs Device in Directory Devices API.
2715/// 
2716/// # Activities
2717/// 
2718/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2719/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2720/// 
2721/// * [action chromeosdevices](struct.ChromeosdeviceActionCall.html) (request)
2722/// 
2723#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2724pub struct ChromeOsDeviceAction {
2725    /// Action to be taken on the ChromeOs Device
2726    pub action: Option<String>,
2727    /// no description provided
2728    #[serde(rename="deprovisionReason")]
2729    pub deprovision_reason: Option<String>,
2730}
2731
2732impl RequestValue for ChromeOsDeviceAction {}
2733
2734
2735/// JSON request template for firing commands on Mobile Device in Directory Devices API.
2736/// 
2737/// # Activities
2738/// 
2739/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2740/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2741/// 
2742/// * [action mobiledevices](struct.MobiledeviceActionCall.html) (request)
2743/// 
2744#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2745pub struct MobileDeviceAction {
2746    /// Action to be taken on the Mobile Device
2747    pub action: Option<String>,
2748}
2749
2750impl RequestValue for MobileDeviceAction {}
2751
2752
2753/// JSON template for Calendar Resource List Response object in Directory API.
2754/// 
2755/// # Activities
2756/// 
2757/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2758/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2759/// 
2760/// * [calendars list resources](struct.ResourceCalendarListCall.html) (response)
2761/// 
2762#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2763pub struct CalendarResources {
2764    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
2765    #[serde(rename="nextPageToken")]
2766    pub next_page_token: Option<String>,
2767    /// The CalendarResources in this page of results.
2768    pub items: Option<Vec<CalendarResource>>,
2769    /// Identifies this as a collection of CalendarResources. This is always admin#directory#resources#calendars#calendarResourcesList.
2770    pub kind: Option<String>,
2771    /// ETag of the resource.
2772    pub etag: Option<String>,
2773}
2774
2775impl ResponseResult for CalendarResources {}
2776
2777
2778/// JSON response template to list aliases in Directory API.
2779/// 
2780/// # Activities
2781/// 
2782/// This type is used in activities, which are methods you may call on this type or where this type is involved in. 
2783/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2784/// 
2785/// * [aliases list users](struct.UserAliaseListCall.html) (response)
2786/// * [aliases list groups](struct.GroupAliaseListCall.html) (response)
2787/// 
2788#[derive(Default, Clone, Debug, Serialize, Deserialize)]
2789pub struct Aliases {
2790    /// Kind of resource this is.
2791    pub kind: Option<String>,
2792    /// ETag of the resource.
2793    pub etag: Option<String>,
2794    /// List of alias objects.
2795    pub aliases: Option<Vec<String>>,
2796}
2797
2798impl ResponseResult for Aliases {}
2799
2800
2801
2802// ###################
2803// MethodBuilders ###
2804// #################
2805
2806/// A builder providing access to all methods supported on *verificationCode* resources.
2807/// It is not used directly, but through the `Directory` hub.
2808///
2809/// # Example
2810///
2811/// Instantiate a resource builder
2812///
2813/// ```test_harness,no_run
2814/// extern crate hyper;
2815/// extern crate hyper_rustls;
2816/// extern crate yup_oauth2 as oauth2;
2817/// extern crate google_admin1_directory as admin1_directory;
2818/// 
2819/// # #[test] fn egal() {
2820/// use std::default::Default;
2821/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
2822/// use admin1_directory::Directory;
2823/// 
2824/// let secret: ApplicationSecret = Default::default();
2825/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
2826///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
2827///                               <MemoryStorage as Default>::default(), None);
2828/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
2829/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2830/// // like `generate(...)`, `invalidate(...)` and `list(...)`
2831/// // to build up your call.
2832/// let rb = hub.verification_codes();
2833/// # }
2834/// ```
2835pub struct VerificationCodeMethods<'a, C, A>
2836    where C: 'a, A: 'a {
2837
2838    hub: &'a Directory<C, A>,
2839}
2840
2841impl<'a, C, A> MethodsBuilder for VerificationCodeMethods<'a, C, A> {}
2842
2843impl<'a, C, A> VerificationCodeMethods<'a, C, A> {
2844    
2845    /// Create a builder to help you perform the following task:
2846    ///
2847    /// Generate new backup verification codes for the user.
2848    /// 
2849    /// # Arguments
2850    ///
2851    /// * `userKey` - Email or immutable ID of the user
2852    pub fn generate(&self, user_key: &str) -> VerificationCodeGenerateCall<'a, C, A> {
2853        VerificationCodeGenerateCall {
2854            hub: self.hub,
2855            _user_key: user_key.to_string(),
2856            _delegate: Default::default(),
2857            _scopes: Default::default(),
2858            _additional_params: Default::default(),
2859        }
2860    }
2861    
2862    /// Create a builder to help you perform the following task:
2863    ///
2864    /// Invalidate the current backup verification codes for the user.
2865    /// 
2866    /// # Arguments
2867    ///
2868    /// * `userKey` - Email or immutable ID of the user
2869    pub fn invalidate(&self, user_key: &str) -> VerificationCodeInvalidateCall<'a, C, A> {
2870        VerificationCodeInvalidateCall {
2871            hub: self.hub,
2872            _user_key: user_key.to_string(),
2873            _delegate: Default::default(),
2874            _scopes: Default::default(),
2875            _additional_params: Default::default(),
2876        }
2877    }
2878    
2879    /// Create a builder to help you perform the following task:
2880    ///
2881    /// Returns the current set of valid backup verification codes for the specified user.
2882    /// 
2883    /// # Arguments
2884    ///
2885    /// * `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.
2886    pub fn list(&self, user_key: &str) -> VerificationCodeListCall<'a, C, A> {
2887        VerificationCodeListCall {
2888            hub: self.hub,
2889            _user_key: user_key.to_string(),
2890            _delegate: Default::default(),
2891            _scopes: Default::default(),
2892            _additional_params: Default::default(),
2893        }
2894    }
2895}
2896
2897
2898
2899/// A builder providing access to all methods supported on *customer* resources.
2900/// It is not used directly, but through the `Directory` hub.
2901///
2902/// # Example
2903///
2904/// Instantiate a resource builder
2905///
2906/// ```test_harness,no_run
2907/// extern crate hyper;
2908/// extern crate hyper_rustls;
2909/// extern crate yup_oauth2 as oauth2;
2910/// extern crate google_admin1_directory as admin1_directory;
2911/// 
2912/// # #[test] fn egal() {
2913/// use std::default::Default;
2914/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
2915/// use admin1_directory::Directory;
2916/// 
2917/// let secret: ApplicationSecret = Default::default();
2918/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
2919///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
2920///                               <MemoryStorage as Default>::default(), None);
2921/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
2922/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2923/// // like `get(...)`, `patch(...)` and `update(...)`
2924/// // to build up your call.
2925/// let rb = hub.customers();
2926/// # }
2927/// ```
2928pub struct CustomerMethods<'a, C, A>
2929    where C: 'a, A: 'a {
2930
2931    hub: &'a Directory<C, A>,
2932}
2933
2934impl<'a, C, A> MethodsBuilder for CustomerMethods<'a, C, A> {}
2935
2936impl<'a, C, A> CustomerMethods<'a, C, A> {
2937    
2938    /// Create a builder to help you perform the following task:
2939    ///
2940    /// Updates a customer. This method supports patch semantics.
2941    /// 
2942    /// # Arguments
2943    ///
2944    /// * `request` - No description provided.
2945    /// * `customerKey` - Id of the customer to be updated
2946    pub fn patch(&self, request: Customer, customer_key: &str) -> CustomerPatchCall<'a, C, A> {
2947        CustomerPatchCall {
2948            hub: self.hub,
2949            _request: request,
2950            _customer_key: customer_key.to_string(),
2951            _delegate: Default::default(),
2952            _scopes: Default::default(),
2953            _additional_params: Default::default(),
2954        }
2955    }
2956    
2957    /// Create a builder to help you perform the following task:
2958    ///
2959    /// Retrieves a customer.
2960    /// 
2961    /// # Arguments
2962    ///
2963    /// * `customerKey` - Id of the customer to be retrieved
2964    pub fn get(&self, customer_key: &str) -> CustomerGetCall<'a, C, A> {
2965        CustomerGetCall {
2966            hub: self.hub,
2967            _customer_key: customer_key.to_string(),
2968            _delegate: Default::default(),
2969            _scopes: Default::default(),
2970            _additional_params: Default::default(),
2971        }
2972    }
2973    
2974    /// Create a builder to help you perform the following task:
2975    ///
2976    /// Updates a customer.
2977    /// 
2978    /// # Arguments
2979    ///
2980    /// * `request` - No description provided.
2981    /// * `customerKey` - Id of the customer to be updated
2982    pub fn update(&self, request: Customer, customer_key: &str) -> CustomerUpdateCall<'a, C, A> {
2983        CustomerUpdateCall {
2984            hub: self.hub,
2985            _request: request,
2986            _customer_key: customer_key.to_string(),
2987            _delegate: Default::default(),
2988            _scopes: Default::default(),
2989            _additional_params: Default::default(),
2990        }
2991    }
2992}
2993
2994
2995
2996/// A builder providing access to all methods supported on *orgunit* resources.
2997/// It is not used directly, but through the `Directory` hub.
2998///
2999/// # Example
3000///
3001/// Instantiate a resource builder
3002///
3003/// ```test_harness,no_run
3004/// extern crate hyper;
3005/// extern crate hyper_rustls;
3006/// extern crate yup_oauth2 as oauth2;
3007/// extern crate google_admin1_directory as admin1_directory;
3008/// 
3009/// # #[test] fn egal() {
3010/// use std::default::Default;
3011/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3012/// use admin1_directory::Directory;
3013/// 
3014/// let secret: ApplicationSecret = Default::default();
3015/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3016///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3017///                               <MemoryStorage as Default>::default(), None);
3018/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3019/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3020/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
3021/// // to build up your call.
3022/// let rb = hub.orgunits();
3023/// # }
3024/// ```
3025pub struct OrgunitMethods<'a, C, A>
3026    where C: 'a, A: 'a {
3027
3028    hub: &'a Directory<C, A>,
3029}
3030
3031impl<'a, C, A> MethodsBuilder for OrgunitMethods<'a, C, A> {}
3032
3033impl<'a, C, A> OrgunitMethods<'a, C, A> {
3034    
3035    /// Create a builder to help you perform the following task:
3036    ///
3037    /// Retrieve all organizational units
3038    /// 
3039    /// # Arguments
3040    ///
3041    /// * `customerId` - Immutable ID of the G Suite account
3042    pub fn list(&self, customer_id: &str) -> OrgunitListCall<'a, C, A> {
3043        OrgunitListCall {
3044            hub: self.hub,
3045            _customer_id: customer_id.to_string(),
3046            _type_: Default::default(),
3047            _org_unit_path: Default::default(),
3048            _delegate: Default::default(),
3049            _scopes: Default::default(),
3050            _additional_params: Default::default(),
3051        }
3052    }
3053    
3054    /// Create a builder to help you perform the following task:
3055    ///
3056    /// Add organizational unit
3057    /// 
3058    /// # Arguments
3059    ///
3060    /// * `request` - No description provided.
3061    /// * `customerId` - Immutable ID of the G Suite account
3062    pub fn insert(&self, request: OrgUnit, customer_id: &str) -> OrgunitInsertCall<'a, C, A> {
3063        OrgunitInsertCall {
3064            hub: self.hub,
3065            _request: request,
3066            _customer_id: customer_id.to_string(),
3067            _delegate: Default::default(),
3068            _scopes: Default::default(),
3069            _additional_params: Default::default(),
3070        }
3071    }
3072    
3073    /// Create a builder to help you perform the following task:
3074    ///
3075    /// Update organizational unit
3076    /// 
3077    /// # Arguments
3078    ///
3079    /// * `request` - No description provided.
3080    /// * `customerId` - Immutable ID of the G Suite account
3081    /// * `orgUnitPath` - Full path of the organizational unit or its ID
3082    pub fn update(&self, request: OrgUnit, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitUpdateCall<'a, C, A> {
3083        OrgunitUpdateCall {
3084            hub: self.hub,
3085            _request: request,
3086            _customer_id: customer_id.to_string(),
3087            _org_unit_path: org_unit_path.clone(),
3088            _delegate: Default::default(),
3089            _scopes: Default::default(),
3090            _additional_params: Default::default(),
3091        }
3092    }
3093    
3094    /// Create a builder to help you perform the following task:
3095    ///
3096    /// Retrieve organizational unit
3097    /// 
3098    /// # Arguments
3099    ///
3100    /// * `customerId` - Immutable ID of the G Suite account
3101    /// * `orgUnitPath` - Full path of the organizational unit or its ID
3102    pub fn get(&self, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitGetCall<'a, C, A> {
3103        OrgunitGetCall {
3104            hub: self.hub,
3105            _customer_id: customer_id.to_string(),
3106            _org_unit_path: org_unit_path.clone(),
3107            _delegate: Default::default(),
3108            _scopes: Default::default(),
3109            _additional_params: Default::default(),
3110        }
3111    }
3112    
3113    /// Create a builder to help you perform the following task:
3114    ///
3115    /// Remove organizational unit
3116    /// 
3117    /// # Arguments
3118    ///
3119    /// * `customerId` - Immutable ID of the G Suite account
3120    /// * `orgUnitPath` - Full path of the organizational unit or its ID
3121    pub fn delete(&self, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitDeleteCall<'a, C, A> {
3122        OrgunitDeleteCall {
3123            hub: self.hub,
3124            _customer_id: customer_id.to_string(),
3125            _org_unit_path: org_unit_path.clone(),
3126            _delegate: Default::default(),
3127            _scopes: Default::default(),
3128            _additional_params: Default::default(),
3129        }
3130    }
3131    
3132    /// Create a builder to help you perform the following task:
3133    ///
3134    /// Update organizational unit. This method supports patch semantics.
3135    /// 
3136    /// # Arguments
3137    ///
3138    /// * `request` - No description provided.
3139    /// * `customerId` - Immutable ID of the G Suite account
3140    /// * `orgUnitPath` - Full path of the organizational unit or its ID
3141    pub fn patch(&self, request: OrgUnit, customer_id: &str, org_unit_path: &Vec<String>) -> OrgunitPatchCall<'a, C, A> {
3142        OrgunitPatchCall {
3143            hub: self.hub,
3144            _request: request,
3145            _customer_id: customer_id.to_string(),
3146            _org_unit_path: org_unit_path.clone(),
3147            _delegate: Default::default(),
3148            _scopes: Default::default(),
3149            _additional_params: Default::default(),
3150        }
3151    }
3152}
3153
3154
3155
3156/// A builder providing access to all methods supported on *group* resources.
3157/// It is not used directly, but through the `Directory` hub.
3158///
3159/// # Example
3160///
3161/// Instantiate a resource builder
3162///
3163/// ```test_harness,no_run
3164/// extern crate hyper;
3165/// extern crate hyper_rustls;
3166/// extern crate yup_oauth2 as oauth2;
3167/// extern crate google_admin1_directory as admin1_directory;
3168/// 
3169/// # #[test] fn egal() {
3170/// use std::default::Default;
3171/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3172/// use admin1_directory::Directory;
3173/// 
3174/// let secret: ApplicationSecret = Default::default();
3175/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3176///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3177///                               <MemoryStorage as Default>::default(), None);
3178/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3179/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3180/// // like `aliases_delete(...)`, `aliases_insert(...)`, `aliases_list(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
3181/// // to build up your call.
3182/// let rb = hub.groups();
3183/// # }
3184/// ```
3185pub struct GroupMethods<'a, C, A>
3186    where C: 'a, A: 'a {
3187
3188    hub: &'a Directory<C, A>,
3189}
3190
3191impl<'a, C, A> MethodsBuilder for GroupMethods<'a, C, A> {}
3192
3193impl<'a, C, A> GroupMethods<'a, C, A> {
3194    
3195    /// Create a builder to help you perform the following task:
3196    ///
3197    /// Delete Group
3198    /// 
3199    /// # Arguments
3200    ///
3201    /// * `groupKey` - Email or immutable ID of the group
3202    pub fn delete(&self, group_key: &str) -> GroupDeleteCall<'a, C, A> {
3203        GroupDeleteCall {
3204            hub: self.hub,
3205            _group_key: group_key.to_string(),
3206            _delegate: Default::default(),
3207            _scopes: Default::default(),
3208            _additional_params: Default::default(),
3209        }
3210    }
3211    
3212    /// Create a builder to help you perform the following task:
3213    ///
3214    /// Retrieve all groups of a domain or of a user given a userKey (paginated)
3215    pub fn list(&self) -> GroupListCall<'a, C, A> {
3216        GroupListCall {
3217            hub: self.hub,
3218            _user_key: Default::default(),
3219            _sort_order: Default::default(),
3220            _query: Default::default(),
3221            _page_token: Default::default(),
3222            _order_by: Default::default(),
3223            _max_results: Default::default(),
3224            _domain: Default::default(),
3225            _customer: Default::default(),
3226            _delegate: Default::default(),
3227            _scopes: Default::default(),
3228            _additional_params: Default::default(),
3229        }
3230    }
3231    
3232    /// Create a builder to help you perform the following task:
3233    ///
3234    /// Update Group
3235    /// 
3236    /// # Arguments
3237    ///
3238    /// * `request` - No description provided.
3239    /// * `groupKey` - Email or immutable ID of the group. If ID, it should match with id of group object
3240    pub fn update(&self, request: Group, group_key: &str) -> GroupUpdateCall<'a, C, A> {
3241        GroupUpdateCall {
3242            hub: self.hub,
3243            _request: request,
3244            _group_key: group_key.to_string(),
3245            _delegate: Default::default(),
3246            _scopes: Default::default(),
3247            _additional_params: Default::default(),
3248        }
3249    }
3250    
3251    /// Create a builder to help you perform the following task:
3252    ///
3253    /// Create Group
3254    /// 
3255    /// # Arguments
3256    ///
3257    /// * `request` - No description provided.
3258    pub fn insert(&self, request: Group) -> GroupInsertCall<'a, C, A> {
3259        GroupInsertCall {
3260            hub: self.hub,
3261            _request: request,
3262            _delegate: Default::default(),
3263            _scopes: Default::default(),
3264            _additional_params: Default::default(),
3265        }
3266    }
3267    
3268    /// Create a builder to help you perform the following task:
3269    ///
3270    /// Add a alias for the group
3271    /// 
3272    /// # Arguments
3273    ///
3274    /// * `request` - No description provided.
3275    /// * `groupKey` - Email or immutable ID of the group
3276    pub fn aliases_insert(&self, request: Alias, group_key: &str) -> GroupAliaseInsertCall<'a, C, A> {
3277        GroupAliaseInsertCall {
3278            hub: self.hub,
3279            _request: request,
3280            _group_key: group_key.to_string(),
3281            _delegate: Default::default(),
3282            _scopes: Default::default(),
3283            _additional_params: Default::default(),
3284        }
3285    }
3286    
3287    /// Create a builder to help you perform the following task:
3288    ///
3289    /// List all aliases for a group
3290    /// 
3291    /// # Arguments
3292    ///
3293    /// * `groupKey` - Email or immutable ID of the group
3294    pub fn aliases_list(&self, group_key: &str) -> GroupAliaseListCall<'a, C, A> {
3295        GroupAliaseListCall {
3296            hub: self.hub,
3297            _group_key: group_key.to_string(),
3298            _delegate: Default::default(),
3299            _scopes: Default::default(),
3300            _additional_params: Default::default(),
3301        }
3302    }
3303    
3304    /// Create a builder to help you perform the following task:
3305    ///
3306    /// Retrieve Group
3307    /// 
3308    /// # Arguments
3309    ///
3310    /// * `groupKey` - Email or immutable ID of the group
3311    pub fn get(&self, group_key: &str) -> GroupGetCall<'a, C, A> {
3312        GroupGetCall {
3313            hub: self.hub,
3314            _group_key: group_key.to_string(),
3315            _delegate: Default::default(),
3316            _scopes: Default::default(),
3317            _additional_params: Default::default(),
3318        }
3319    }
3320    
3321    /// Create a builder to help you perform the following task:
3322    ///
3323    /// Update Group. This method supports patch semantics.
3324    /// 
3325    /// # Arguments
3326    ///
3327    /// * `request` - No description provided.
3328    /// * `groupKey` - Email or immutable ID of the group. If ID, it should match with id of group object
3329    pub fn patch(&self, request: Group, group_key: &str) -> GroupPatchCall<'a, C, A> {
3330        GroupPatchCall {
3331            hub: self.hub,
3332            _request: request,
3333            _group_key: group_key.to_string(),
3334            _delegate: Default::default(),
3335            _scopes: Default::default(),
3336            _additional_params: Default::default(),
3337        }
3338    }
3339    
3340    /// Create a builder to help you perform the following task:
3341    ///
3342    /// Remove a alias for the group
3343    /// 
3344    /// # Arguments
3345    ///
3346    /// * `groupKey` - Email or immutable ID of the group
3347    /// * `alias` - The alias to be removed
3348    pub fn aliases_delete(&self, group_key: &str, alias: &str) -> GroupAliaseDeleteCall<'a, C, A> {
3349        GroupAliaseDeleteCall {
3350            hub: self.hub,
3351            _group_key: group_key.to_string(),
3352            _alias: alias.to_string(),
3353            _delegate: Default::default(),
3354            _scopes: Default::default(),
3355            _additional_params: Default::default(),
3356        }
3357    }
3358}
3359
3360
3361
3362/// A builder providing access to all methods supported on *role* resources.
3363/// It is not used directly, but through the `Directory` hub.
3364///
3365/// # Example
3366///
3367/// Instantiate a resource builder
3368///
3369/// ```test_harness,no_run
3370/// extern crate hyper;
3371/// extern crate hyper_rustls;
3372/// extern crate yup_oauth2 as oauth2;
3373/// extern crate google_admin1_directory as admin1_directory;
3374/// 
3375/// # #[test] fn egal() {
3376/// use std::default::Default;
3377/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3378/// use admin1_directory::Directory;
3379/// 
3380/// let secret: ApplicationSecret = Default::default();
3381/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3382///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3383///                               <MemoryStorage as Default>::default(), None);
3384/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3385/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3386/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
3387/// // to build up your call.
3388/// let rb = hub.roles();
3389/// # }
3390/// ```
3391pub struct RoleMethods<'a, C, A>
3392    where C: 'a, A: 'a {
3393
3394    hub: &'a Directory<C, A>,
3395}
3396
3397impl<'a, C, A> MethodsBuilder for RoleMethods<'a, C, A> {}
3398
3399impl<'a, C, A> RoleMethods<'a, C, A> {
3400    
3401    /// Create a builder to help you perform the following task:
3402    ///
3403    /// Updates a role.
3404    /// 
3405    /// # Arguments
3406    ///
3407    /// * `request` - No description provided.
3408    /// * `customer` - Immutable ID of the G Suite account.
3409    /// * `roleId` - Immutable ID of the role.
3410    pub fn update(&self, request: Role, customer: &str, role_id: &str) -> RoleUpdateCall<'a, C, A> {
3411        RoleUpdateCall {
3412            hub: self.hub,
3413            _request: request,
3414            _customer: customer.to_string(),
3415            _role_id: role_id.to_string(),
3416            _delegate: Default::default(),
3417            _scopes: Default::default(),
3418            _additional_params: Default::default(),
3419        }
3420    }
3421    
3422    /// Create a builder to help you perform the following task:
3423    ///
3424    /// Retrieves a role.
3425    /// 
3426    /// # Arguments
3427    ///
3428    /// * `customer` - Immutable ID of the G Suite account.
3429    /// * `roleId` - Immutable ID of the role.
3430    pub fn get(&self, customer: &str, role_id: &str) -> RoleGetCall<'a, C, A> {
3431        RoleGetCall {
3432            hub: self.hub,
3433            _customer: customer.to_string(),
3434            _role_id: role_id.to_string(),
3435            _delegate: Default::default(),
3436            _scopes: Default::default(),
3437            _additional_params: Default::default(),
3438        }
3439    }
3440    
3441    /// Create a builder to help you perform the following task:
3442    ///
3443    /// Deletes a role.
3444    /// 
3445    /// # Arguments
3446    ///
3447    /// * `customer` - Immutable ID of the G Suite account.
3448    /// * `roleId` - Immutable ID of the role.
3449    pub fn delete(&self, customer: &str, role_id: &str) -> RoleDeleteCall<'a, C, A> {
3450        RoleDeleteCall {
3451            hub: self.hub,
3452            _customer: customer.to_string(),
3453            _role_id: role_id.to_string(),
3454            _delegate: Default::default(),
3455            _scopes: Default::default(),
3456            _additional_params: Default::default(),
3457        }
3458    }
3459    
3460    /// Create a builder to help you perform the following task:
3461    ///
3462    /// Updates a role. This method supports patch semantics.
3463    /// 
3464    /// # Arguments
3465    ///
3466    /// * `request` - No description provided.
3467    /// * `customer` - Immutable ID of the G Suite account.
3468    /// * `roleId` - Immutable ID of the role.
3469    pub fn patch(&self, request: Role, customer: &str, role_id: &str) -> RolePatchCall<'a, C, A> {
3470        RolePatchCall {
3471            hub: self.hub,
3472            _request: request,
3473            _customer: customer.to_string(),
3474            _role_id: role_id.to_string(),
3475            _delegate: Default::default(),
3476            _scopes: Default::default(),
3477            _additional_params: Default::default(),
3478        }
3479    }
3480    
3481    /// Create a builder to help you perform the following task:
3482    ///
3483    /// Creates a role.
3484    /// 
3485    /// # Arguments
3486    ///
3487    /// * `request` - No description provided.
3488    /// * `customer` - Immutable ID of the G Suite account.
3489    pub fn insert(&self, request: Role, customer: &str) -> RoleInsertCall<'a, C, A> {
3490        RoleInsertCall {
3491            hub: self.hub,
3492            _request: request,
3493            _customer: customer.to_string(),
3494            _delegate: Default::default(),
3495            _scopes: Default::default(),
3496            _additional_params: Default::default(),
3497        }
3498    }
3499    
3500    /// Create a builder to help you perform the following task:
3501    ///
3502    /// Retrieves a paginated list of all the roles in a domain.
3503    /// 
3504    /// # Arguments
3505    ///
3506    /// * `customer` - Immutable ID of the G Suite account.
3507    pub fn list(&self, customer: &str) -> RoleListCall<'a, C, A> {
3508        RoleListCall {
3509            hub: self.hub,
3510            _customer: customer.to_string(),
3511            _page_token: Default::default(),
3512            _max_results: Default::default(),
3513            _delegate: Default::default(),
3514            _scopes: Default::default(),
3515            _additional_params: Default::default(),
3516        }
3517    }
3518}
3519
3520
3521
3522/// A builder providing access to all methods supported on *notification* resources.
3523/// It is not used directly, but through the `Directory` hub.
3524///
3525/// # Example
3526///
3527/// Instantiate a resource builder
3528///
3529/// ```test_harness,no_run
3530/// extern crate hyper;
3531/// extern crate hyper_rustls;
3532/// extern crate yup_oauth2 as oauth2;
3533/// extern crate google_admin1_directory as admin1_directory;
3534/// 
3535/// # #[test] fn egal() {
3536/// use std::default::Default;
3537/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3538/// use admin1_directory::Directory;
3539/// 
3540/// let secret: ApplicationSecret = Default::default();
3541/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3542///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3543///                               <MemoryStorage as Default>::default(), None);
3544/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3545/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3546/// // like `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
3547/// // to build up your call.
3548/// let rb = hub.notifications();
3549/// # }
3550/// ```
3551pub struct NotificationMethods<'a, C, A>
3552    where C: 'a, A: 'a {
3553
3554    hub: &'a Directory<C, A>,
3555}
3556
3557impl<'a, C, A> MethodsBuilder for NotificationMethods<'a, C, A> {}
3558
3559impl<'a, C, A> NotificationMethods<'a, C, A> {
3560    
3561    /// Create a builder to help you perform the following task:
3562    ///
3563    /// Retrieves a list of notifications.
3564    /// 
3565    /// # Arguments
3566    ///
3567    /// * `customer` - The unique ID for the customer's G Suite account.
3568    pub fn list(&self, customer: &str) -> NotificationListCall<'a, C, A> {
3569        NotificationListCall {
3570            hub: self.hub,
3571            _customer: customer.to_string(),
3572            _page_token: Default::default(),
3573            _max_results: Default::default(),
3574            _language: Default::default(),
3575            _delegate: Default::default(),
3576            _scopes: Default::default(),
3577            _additional_params: Default::default(),
3578        }
3579    }
3580    
3581    /// Create a builder to help you perform the following task:
3582    ///
3583    /// Updates a notification.
3584    /// 
3585    /// # Arguments
3586    ///
3587    /// * `request` - No description provided.
3588    /// * `customer` - The unique ID for the customer's G Suite account.
3589    /// * `notificationId` - The unique ID of the notification.
3590    pub fn update(&self, request: Notification, customer: &str, notification_id: &str) -> NotificationUpdateCall<'a, C, A> {
3591        NotificationUpdateCall {
3592            hub: self.hub,
3593            _request: request,
3594            _customer: customer.to_string(),
3595            _notification_id: notification_id.to_string(),
3596            _delegate: Default::default(),
3597            _scopes: Default::default(),
3598            _additional_params: Default::default(),
3599        }
3600    }
3601    
3602    /// Create a builder to help you perform the following task:
3603    ///
3604    /// Deletes a notification
3605    /// 
3606    /// # Arguments
3607    ///
3608    /// * `customer` - The unique ID for the customer's G Suite account. The customerId is also returned as part of the Users resource.
3609    /// * `notificationId` - The unique ID of the notification.
3610    pub fn delete(&self, customer: &str, notification_id: &str) -> NotificationDeleteCall<'a, C, A> {
3611        NotificationDeleteCall {
3612            hub: self.hub,
3613            _customer: customer.to_string(),
3614            _notification_id: notification_id.to_string(),
3615            _delegate: Default::default(),
3616            _scopes: Default::default(),
3617            _additional_params: Default::default(),
3618        }
3619    }
3620    
3621    /// Create a builder to help you perform the following task:
3622    ///
3623    /// Retrieves a notification.
3624    /// 
3625    /// # Arguments
3626    ///
3627    /// * `customer` - The unique ID for the customer's G Suite account. The customerId is also returned as part of the Users resource.
3628    /// * `notificationId` - The unique ID of the notification.
3629    pub fn get(&self, customer: &str, notification_id: &str) -> NotificationGetCall<'a, C, A> {
3630        NotificationGetCall {
3631            hub: self.hub,
3632            _customer: customer.to_string(),
3633            _notification_id: notification_id.to_string(),
3634            _delegate: Default::default(),
3635            _scopes: Default::default(),
3636            _additional_params: Default::default(),
3637        }
3638    }
3639    
3640    /// Create a builder to help you perform the following task:
3641    ///
3642    /// Updates a notification. This method supports patch semantics.
3643    /// 
3644    /// # Arguments
3645    ///
3646    /// * `request` - No description provided.
3647    /// * `customer` - The unique ID for the customer's G Suite account.
3648    /// * `notificationId` - The unique ID of the notification.
3649    pub fn patch(&self, request: Notification, customer: &str, notification_id: &str) -> NotificationPatchCall<'a, C, A> {
3650        NotificationPatchCall {
3651            hub: self.hub,
3652            _request: request,
3653            _customer: customer.to_string(),
3654            _notification_id: notification_id.to_string(),
3655            _delegate: Default::default(),
3656            _scopes: Default::default(),
3657            _additional_params: Default::default(),
3658        }
3659    }
3660}
3661
3662
3663
3664/// A builder providing access to all methods supported on *privilege* resources.
3665/// It is not used directly, but through the `Directory` hub.
3666///
3667/// # Example
3668///
3669/// Instantiate a resource builder
3670///
3671/// ```test_harness,no_run
3672/// extern crate hyper;
3673/// extern crate hyper_rustls;
3674/// extern crate yup_oauth2 as oauth2;
3675/// extern crate google_admin1_directory as admin1_directory;
3676/// 
3677/// # #[test] fn egal() {
3678/// use std::default::Default;
3679/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3680/// use admin1_directory::Directory;
3681/// 
3682/// let secret: ApplicationSecret = Default::default();
3683/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3684///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3685///                               <MemoryStorage as Default>::default(), None);
3686/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3687/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3688/// // like `list(...)`
3689/// // to build up your call.
3690/// let rb = hub.privileges();
3691/// # }
3692/// ```
3693pub struct PrivilegeMethods<'a, C, A>
3694    where C: 'a, A: 'a {
3695
3696    hub: &'a Directory<C, A>,
3697}
3698
3699impl<'a, C, A> MethodsBuilder for PrivilegeMethods<'a, C, A> {}
3700
3701impl<'a, C, A> PrivilegeMethods<'a, C, A> {
3702    
3703    /// Create a builder to help you perform the following task:
3704    ///
3705    /// Retrieves a paginated list of all privileges for a customer.
3706    /// 
3707    /// # Arguments
3708    ///
3709    /// * `customer` - Immutable ID of the G Suite account.
3710    pub fn list(&self, customer: &str) -> PrivilegeListCall<'a, C, A> {
3711        PrivilegeListCall {
3712            hub: self.hub,
3713            _customer: customer.to_string(),
3714            _delegate: Default::default(),
3715            _scopes: Default::default(),
3716            _additional_params: Default::default(),
3717        }
3718    }
3719}
3720
3721
3722
3723/// A builder providing access to all methods supported on *channel* resources.
3724/// It is not used directly, but through the `Directory` hub.
3725///
3726/// # Example
3727///
3728/// Instantiate a resource builder
3729///
3730/// ```test_harness,no_run
3731/// extern crate hyper;
3732/// extern crate hyper_rustls;
3733/// extern crate yup_oauth2 as oauth2;
3734/// extern crate google_admin1_directory as admin1_directory;
3735/// 
3736/// # #[test] fn egal() {
3737/// use std::default::Default;
3738/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3739/// use admin1_directory::Directory;
3740/// 
3741/// let secret: ApplicationSecret = Default::default();
3742/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3743///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3744///                               <MemoryStorage as Default>::default(), None);
3745/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3746/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3747/// // like `stop(...)`
3748/// // to build up your call.
3749/// let rb = hub.channels();
3750/// # }
3751/// ```
3752pub struct ChannelMethods<'a, C, A>
3753    where C: 'a, A: 'a {
3754
3755    hub: &'a Directory<C, A>,
3756}
3757
3758impl<'a, C, A> MethodsBuilder for ChannelMethods<'a, C, A> {}
3759
3760impl<'a, C, A> ChannelMethods<'a, C, A> {
3761    
3762    /// Create a builder to help you perform the following task:
3763    ///
3764    /// Stop watching resources through this channel
3765    /// 
3766    /// # Arguments
3767    ///
3768    /// * `request` - No description provided.
3769    pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C, A> {
3770        ChannelStopCall {
3771            hub: self.hub,
3772            _request: request,
3773            _delegate: Default::default(),
3774            _scopes: Default::default(),
3775            _additional_params: Default::default(),
3776        }
3777    }
3778}
3779
3780
3781
3782/// A builder providing access to all methods supported on *mobiledevice* resources.
3783/// It is not used directly, but through the `Directory` hub.
3784///
3785/// # Example
3786///
3787/// Instantiate a resource builder
3788///
3789/// ```test_harness,no_run
3790/// extern crate hyper;
3791/// extern crate hyper_rustls;
3792/// extern crate yup_oauth2 as oauth2;
3793/// extern crate google_admin1_directory as admin1_directory;
3794/// 
3795/// # #[test] fn egal() {
3796/// use std::default::Default;
3797/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3798/// use admin1_directory::Directory;
3799/// 
3800/// let secret: ApplicationSecret = Default::default();
3801/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3802///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3803///                               <MemoryStorage as Default>::default(), None);
3804/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3805/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3806/// // like `action(...)`, `delete(...)`, `get(...)` and `list(...)`
3807/// // to build up your call.
3808/// let rb = hub.mobiledevices();
3809/// # }
3810/// ```
3811pub struct MobiledeviceMethods<'a, C, A>
3812    where C: 'a, A: 'a {
3813
3814    hub: &'a Directory<C, A>,
3815}
3816
3817impl<'a, C, A> MethodsBuilder for MobiledeviceMethods<'a, C, A> {}
3818
3819impl<'a, C, A> MobiledeviceMethods<'a, C, A> {
3820    
3821    /// Create a builder to help you perform the following task:
3822    ///
3823    /// Retrieve Mobile Device
3824    /// 
3825    /// # Arguments
3826    ///
3827    /// * `customerId` - Immutable ID of the G Suite account
3828    /// * `resourceId` - Immutable ID of Mobile Device
3829    pub fn get(&self, customer_id: &str, resource_id: &str) -> MobiledeviceGetCall<'a, C, A> {
3830        MobiledeviceGetCall {
3831            hub: self.hub,
3832            _customer_id: customer_id.to_string(),
3833            _resource_id: resource_id.to_string(),
3834            _projection: Default::default(),
3835            _delegate: Default::default(),
3836            _scopes: Default::default(),
3837            _additional_params: Default::default(),
3838        }
3839    }
3840    
3841    /// Create a builder to help you perform the following task:
3842    ///
3843    /// Retrieve all Mobile Devices of a customer (paginated)
3844    /// 
3845    /// # Arguments
3846    ///
3847    /// * `customerId` - Immutable ID of the G Suite account
3848    pub fn list(&self, customer_id: &str) -> MobiledeviceListCall<'a, C, A> {
3849        MobiledeviceListCall {
3850            hub: self.hub,
3851            _customer_id: customer_id.to_string(),
3852            _sort_order: Default::default(),
3853            _query: Default::default(),
3854            _projection: Default::default(),
3855            _page_token: Default::default(),
3856            _order_by: Default::default(),
3857            _max_results: Default::default(),
3858            _delegate: Default::default(),
3859            _scopes: Default::default(),
3860            _additional_params: Default::default(),
3861        }
3862    }
3863    
3864    /// Create a builder to help you perform the following task:
3865    ///
3866    /// Delete Mobile Device
3867    /// 
3868    /// # Arguments
3869    ///
3870    /// * `customerId` - Immutable ID of the G Suite account
3871    /// * `resourceId` - Immutable ID of Mobile Device
3872    pub fn delete(&self, customer_id: &str, resource_id: &str) -> MobiledeviceDeleteCall<'a, C, A> {
3873        MobiledeviceDeleteCall {
3874            hub: self.hub,
3875            _customer_id: customer_id.to_string(),
3876            _resource_id: resource_id.to_string(),
3877            _delegate: Default::default(),
3878            _scopes: Default::default(),
3879            _additional_params: Default::default(),
3880        }
3881    }
3882    
3883    /// Create a builder to help you perform the following task:
3884    ///
3885    /// Take action on Mobile Device
3886    /// 
3887    /// # Arguments
3888    ///
3889    /// * `request` - No description provided.
3890    /// * `customerId` - Immutable ID of the G Suite account
3891    /// * `resourceId` - Immutable ID of Mobile Device
3892    pub fn action(&self, request: MobileDeviceAction, customer_id: &str, resource_id: &str) -> MobiledeviceActionCall<'a, C, A> {
3893        MobiledeviceActionCall {
3894            hub: self.hub,
3895            _request: request,
3896            _customer_id: customer_id.to_string(),
3897            _resource_id: resource_id.to_string(),
3898            _delegate: Default::default(),
3899            _scopes: Default::default(),
3900            _additional_params: Default::default(),
3901        }
3902    }
3903}
3904
3905
3906
3907/// A builder providing access to all methods supported on *token* resources.
3908/// It is not used directly, but through the `Directory` hub.
3909///
3910/// # Example
3911///
3912/// Instantiate a resource builder
3913///
3914/// ```test_harness,no_run
3915/// extern crate hyper;
3916/// extern crate hyper_rustls;
3917/// extern crate yup_oauth2 as oauth2;
3918/// extern crate google_admin1_directory as admin1_directory;
3919/// 
3920/// # #[test] fn egal() {
3921/// use std::default::Default;
3922/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
3923/// use admin1_directory::Directory;
3924/// 
3925/// let secret: ApplicationSecret = Default::default();
3926/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
3927///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
3928///                               <MemoryStorage as Default>::default(), None);
3929/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
3930/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3931/// // like `delete(...)`, `get(...)` and `list(...)`
3932/// // to build up your call.
3933/// let rb = hub.tokens();
3934/// # }
3935/// ```
3936pub struct TokenMethods<'a, C, A>
3937    where C: 'a, A: 'a {
3938
3939    hub: &'a Directory<C, A>,
3940}
3941
3942impl<'a, C, A> MethodsBuilder for TokenMethods<'a, C, A> {}
3943
3944impl<'a, C, A> TokenMethods<'a, C, A> {
3945    
3946    /// Create a builder to help you perform the following task:
3947    ///
3948    /// Get information about an access token issued by a user.
3949    /// 
3950    /// # Arguments
3951    ///
3952    /// * `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.
3953    /// * `clientId` - The Client ID of the application the token is issued to.
3954    pub fn get(&self, user_key: &str, client_id: &str) -> TokenGetCall<'a, C, A> {
3955        TokenGetCall {
3956            hub: self.hub,
3957            _user_key: user_key.to_string(),
3958            _client_id: client_id.to_string(),
3959            _delegate: Default::default(),
3960            _scopes: Default::default(),
3961            _additional_params: Default::default(),
3962        }
3963    }
3964    
3965    /// Create a builder to help you perform the following task:
3966    ///
3967    /// Returns the set of tokens specified user has issued to 3rd party applications.
3968    /// 
3969    /// # Arguments
3970    ///
3971    /// * `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.
3972    pub fn list(&self, user_key: &str) -> TokenListCall<'a, C, A> {
3973        TokenListCall {
3974            hub: self.hub,
3975            _user_key: user_key.to_string(),
3976            _delegate: Default::default(),
3977            _scopes: Default::default(),
3978            _additional_params: Default::default(),
3979        }
3980    }
3981    
3982    /// Create a builder to help you perform the following task:
3983    ///
3984    /// Delete all access tokens issued by a user for an application.
3985    /// 
3986    /// # Arguments
3987    ///
3988    /// * `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.
3989    /// * `clientId` - The Client ID of the application the token is issued to.
3990    pub fn delete(&self, user_key: &str, client_id: &str) -> TokenDeleteCall<'a, C, A> {
3991        TokenDeleteCall {
3992            hub: self.hub,
3993            _user_key: user_key.to_string(),
3994            _client_id: client_id.to_string(),
3995            _delegate: Default::default(),
3996            _scopes: Default::default(),
3997            _additional_params: Default::default(),
3998        }
3999    }
4000}
4001
4002
4003
4004/// A builder providing access to all methods supported on *roleAssignment* resources.
4005/// It is not used directly, but through the `Directory` hub.
4006///
4007/// # Example
4008///
4009/// Instantiate a resource builder
4010///
4011/// ```test_harness,no_run
4012/// extern crate hyper;
4013/// extern crate hyper_rustls;
4014/// extern crate yup_oauth2 as oauth2;
4015/// extern crate google_admin1_directory as admin1_directory;
4016/// 
4017/// # #[test] fn egal() {
4018/// use std::default::Default;
4019/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4020/// use admin1_directory::Directory;
4021/// 
4022/// let secret: ApplicationSecret = Default::default();
4023/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4024///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4025///                               <MemoryStorage as Default>::default(), None);
4026/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4027/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4028/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
4029/// // to build up your call.
4030/// let rb = hub.role_assignments();
4031/// # }
4032/// ```
4033pub struct RoleAssignmentMethods<'a, C, A>
4034    where C: 'a, A: 'a {
4035
4036    hub: &'a Directory<C, A>,
4037}
4038
4039impl<'a, C, A> MethodsBuilder for RoleAssignmentMethods<'a, C, A> {}
4040
4041impl<'a, C, A> RoleAssignmentMethods<'a, C, A> {
4042    
4043    /// Create a builder to help you perform the following task:
4044    ///
4045    /// Creates a role assignment.
4046    /// 
4047    /// # Arguments
4048    ///
4049    /// * `request` - No description provided.
4050    /// * `customer` - Immutable ID of the G Suite account.
4051    pub fn insert(&self, request: RoleAssignment, customer: &str) -> RoleAssignmentInsertCall<'a, C, A> {
4052        RoleAssignmentInsertCall {
4053            hub: self.hub,
4054            _request: request,
4055            _customer: customer.to_string(),
4056            _delegate: Default::default(),
4057            _scopes: Default::default(),
4058            _additional_params: Default::default(),
4059        }
4060    }
4061    
4062    /// Create a builder to help you perform the following task:
4063    ///
4064    /// Retrieve a role assignment.
4065    /// 
4066    /// # Arguments
4067    ///
4068    /// * `customer` - Immutable ID of the G Suite account.
4069    /// * `roleAssignmentId` - Immutable ID of the role assignment.
4070    pub fn get(&self, customer: &str, role_assignment_id: &str) -> RoleAssignmentGetCall<'a, C, A> {
4071        RoleAssignmentGetCall {
4072            hub: self.hub,
4073            _customer: customer.to_string(),
4074            _role_assignment_id: role_assignment_id.to_string(),
4075            _delegate: Default::default(),
4076            _scopes: Default::default(),
4077            _additional_params: Default::default(),
4078        }
4079    }
4080    
4081    /// Create a builder to help you perform the following task:
4082    ///
4083    /// Deletes a role assignment.
4084    /// 
4085    /// # Arguments
4086    ///
4087    /// * `customer` - Immutable ID of the G Suite account.
4088    /// * `roleAssignmentId` - Immutable ID of the role assignment.
4089    pub fn delete(&self, customer: &str, role_assignment_id: &str) -> RoleAssignmentDeleteCall<'a, C, A> {
4090        RoleAssignmentDeleteCall {
4091            hub: self.hub,
4092            _customer: customer.to_string(),
4093            _role_assignment_id: role_assignment_id.to_string(),
4094            _delegate: Default::default(),
4095            _scopes: Default::default(),
4096            _additional_params: Default::default(),
4097        }
4098    }
4099    
4100    /// Create a builder to help you perform the following task:
4101    ///
4102    /// Retrieves a paginated list of all roleAssignments.
4103    /// 
4104    /// # Arguments
4105    ///
4106    /// * `customer` - Immutable ID of the G Suite account.
4107    pub fn list(&self, customer: &str) -> RoleAssignmentListCall<'a, C, A> {
4108        RoleAssignmentListCall {
4109            hub: self.hub,
4110            _customer: customer.to_string(),
4111            _user_key: Default::default(),
4112            _role_id: Default::default(),
4113            _page_token: Default::default(),
4114            _max_results: Default::default(),
4115            _delegate: Default::default(),
4116            _scopes: Default::default(),
4117            _additional_params: Default::default(),
4118        }
4119    }
4120}
4121
4122
4123
4124/// A builder providing access to all methods supported on *chromeosdevice* resources.
4125/// It is not used directly, but through the `Directory` hub.
4126///
4127/// # Example
4128///
4129/// Instantiate a resource builder
4130///
4131/// ```test_harness,no_run
4132/// extern crate hyper;
4133/// extern crate hyper_rustls;
4134/// extern crate yup_oauth2 as oauth2;
4135/// extern crate google_admin1_directory as admin1_directory;
4136/// 
4137/// # #[test] fn egal() {
4138/// use std::default::Default;
4139/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4140/// use admin1_directory::Directory;
4141/// 
4142/// let secret: ApplicationSecret = Default::default();
4143/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4144///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4145///                               <MemoryStorage as Default>::default(), None);
4146/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4147/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4148/// // like `action(...)`, `get(...)`, `list(...)`, `move_devices_to_ou(...)`, `patch(...)` and `update(...)`
4149/// // to build up your call.
4150/// let rb = hub.chromeosdevices();
4151/// # }
4152/// ```
4153pub struct ChromeosdeviceMethods<'a, C, A>
4154    where C: 'a, A: 'a {
4155
4156    hub: &'a Directory<C, A>,
4157}
4158
4159impl<'a, C, A> MethodsBuilder for ChromeosdeviceMethods<'a, C, A> {}
4160
4161impl<'a, C, A> ChromeosdeviceMethods<'a, C, A> {
4162    
4163    /// Create a builder to help you perform the following task:
4164    ///
4165    /// Retrieve all Chrome OS Devices of a customer (paginated)
4166    /// 
4167    /// # Arguments
4168    ///
4169    /// * `customerId` - Immutable ID of the G Suite account
4170    pub fn list(&self, customer_id: &str) -> ChromeosdeviceListCall<'a, C, A> {
4171        ChromeosdeviceListCall {
4172            hub: self.hub,
4173            _customer_id: customer_id.to_string(),
4174            _sort_order: Default::default(),
4175            _query: Default::default(),
4176            _projection: Default::default(),
4177            _page_token: Default::default(),
4178            _org_unit_path: Default::default(),
4179            _order_by: Default::default(),
4180            _max_results: Default::default(),
4181            _delegate: Default::default(),
4182            _scopes: Default::default(),
4183            _additional_params: Default::default(),
4184        }
4185    }
4186    
4187    /// Create a builder to help you perform the following task:
4188    ///
4189    /// Update Chrome OS Device. This method supports patch semantics.
4190    /// 
4191    /// # Arguments
4192    ///
4193    /// * `request` - No description provided.
4194    /// * `customerId` - Immutable ID of the G Suite account
4195    /// * `deviceId` - Immutable ID of Chrome OS Device
4196    pub fn patch(&self, request: ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdevicePatchCall<'a, C, A> {
4197        ChromeosdevicePatchCall {
4198            hub: self.hub,
4199            _request: request,
4200            _customer_id: customer_id.to_string(),
4201            _device_id: device_id.to_string(),
4202            _projection: Default::default(),
4203            _delegate: Default::default(),
4204            _scopes: Default::default(),
4205            _additional_params: Default::default(),
4206        }
4207    }
4208    
4209    /// Create a builder to help you perform the following task:
4210    ///
4211    /// Update Chrome OS Device
4212    /// 
4213    /// # Arguments
4214    ///
4215    /// * `request` - No description provided.
4216    /// * `customerId` - Immutable ID of the G Suite account
4217    /// * `deviceId` - Immutable ID of Chrome OS Device
4218    pub fn update(&self, request: ChromeOsDevice, customer_id: &str, device_id: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
4219        ChromeosdeviceUpdateCall {
4220            hub: self.hub,
4221            _request: request,
4222            _customer_id: customer_id.to_string(),
4223            _device_id: device_id.to_string(),
4224            _projection: Default::default(),
4225            _delegate: Default::default(),
4226            _scopes: Default::default(),
4227            _additional_params: Default::default(),
4228        }
4229    }
4230    
4231    /// Create a builder to help you perform the following task:
4232    ///
4233    /// Retrieve Chrome OS Device
4234    /// 
4235    /// # Arguments
4236    ///
4237    /// * `customerId` - Immutable ID of the G Suite account
4238    /// * `deviceId` - Immutable ID of Chrome OS Device
4239    pub fn get(&self, customer_id: &str, device_id: &str) -> ChromeosdeviceGetCall<'a, C, A> {
4240        ChromeosdeviceGetCall {
4241            hub: self.hub,
4242            _customer_id: customer_id.to_string(),
4243            _device_id: device_id.to_string(),
4244            _projection: Default::default(),
4245            _delegate: Default::default(),
4246            _scopes: Default::default(),
4247            _additional_params: Default::default(),
4248        }
4249    }
4250    
4251    /// Create a builder to help you perform the following task:
4252    ///
4253    /// Take action on Chrome OS Device
4254    /// 
4255    /// # Arguments
4256    ///
4257    /// * `request` - No description provided.
4258    /// * `customerId` - Immutable ID of the G Suite account
4259    /// * `resourceId` - Immutable ID of Chrome OS Device
4260    pub fn action(&self, request: ChromeOsDeviceAction, customer_id: &str, resource_id: &str) -> ChromeosdeviceActionCall<'a, C, A> {
4261        ChromeosdeviceActionCall {
4262            hub: self.hub,
4263            _request: request,
4264            _customer_id: customer_id.to_string(),
4265            _resource_id: resource_id.to_string(),
4266            _delegate: Default::default(),
4267            _scopes: Default::default(),
4268            _additional_params: Default::default(),
4269        }
4270    }
4271    
4272    /// Create a builder to help you perform the following task:
4273    ///
4274    /// Move or insert multiple Chrome OS Devices to organizational unit
4275    /// 
4276    /// # Arguments
4277    ///
4278    /// * `request` - No description provided.
4279    /// * `customerId` - Immutable ID of the G Suite account
4280    /// * `orgUnitPath` - Full path of the target organizational unit or its ID
4281    pub fn move_devices_to_ou(&self, request: ChromeOsMoveDevicesToOu, customer_id: &str, org_unit_path: &str) -> ChromeosdeviceMoveDevicesToOuCall<'a, C, A> {
4282        ChromeosdeviceMoveDevicesToOuCall {
4283            hub: self.hub,
4284            _request: request,
4285            _customer_id: customer_id.to_string(),
4286            _org_unit_path: org_unit_path.to_string(),
4287            _delegate: Default::default(),
4288            _scopes: Default::default(),
4289            _additional_params: Default::default(),
4290        }
4291    }
4292}
4293
4294
4295
4296/// A builder providing access to all methods supported on *member* resources.
4297/// It is not used directly, but through the `Directory` hub.
4298///
4299/// # Example
4300///
4301/// Instantiate a resource builder
4302///
4303/// ```test_harness,no_run
4304/// extern crate hyper;
4305/// extern crate hyper_rustls;
4306/// extern crate yup_oauth2 as oauth2;
4307/// extern crate google_admin1_directory as admin1_directory;
4308/// 
4309/// # #[test] fn egal() {
4310/// use std::default::Default;
4311/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4312/// use admin1_directory::Directory;
4313/// 
4314/// let secret: ApplicationSecret = Default::default();
4315/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4316///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4317///                               <MemoryStorage as Default>::default(), None);
4318/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4319/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4320/// // like `delete(...)`, `get(...)`, `has_member(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
4321/// // to build up your call.
4322/// let rb = hub.members();
4323/// # }
4324/// ```
4325pub struct MemberMethods<'a, C, A>
4326    where C: 'a, A: 'a {
4327
4328    hub: &'a Directory<C, A>,
4329}
4330
4331impl<'a, C, A> MethodsBuilder for MemberMethods<'a, C, A> {}
4332
4333impl<'a, C, A> MemberMethods<'a, C, A> {
4334    
4335    /// Create a builder to help you perform the following task:
4336    ///
4337    /// Checks whether the given user is a member of the group. Membership can be direct or nested.
4338    /// 
4339    /// # Arguments
4340    ///
4341    /// * `groupKey` - Identifies the group in the API request. The value can be the group's email address, group alias, or the unique group ID.
4342    /// * `memberKey` - Identifies the user member in the API request. The value can be the user's primary email address, alias, or unique ID.
4343    pub fn has_member(&self, group_key: &str, member_key: &str) -> MemberHasMemberCall<'a, C, A> {
4344        MemberHasMemberCall {
4345            hub: self.hub,
4346            _group_key: group_key.to_string(),
4347            _member_key: member_key.to_string(),
4348            _delegate: Default::default(),
4349            _scopes: Default::default(),
4350            _additional_params: Default::default(),
4351        }
4352    }
4353    
4354    /// Create a builder to help you perform the following task:
4355    ///
4356    /// Add user to the specified group.
4357    /// 
4358    /// # Arguments
4359    ///
4360    /// * `request` - No description provided.
4361    /// * `groupKey` - Email or immutable ID of the group
4362    pub fn insert(&self, request: Member, group_key: &str) -> MemberInsertCall<'a, C, A> {
4363        MemberInsertCall {
4364            hub: self.hub,
4365            _request: request,
4366            _group_key: group_key.to_string(),
4367            _delegate: Default::default(),
4368            _scopes: Default::default(),
4369            _additional_params: Default::default(),
4370        }
4371    }
4372    
4373    /// Create a builder to help you perform the following task:
4374    ///
4375    /// Update membership of a user in the specified group. This method supports patch semantics.
4376    /// 
4377    /// # Arguments
4378    ///
4379    /// * `request` - No description provided.
4380    /// * `groupKey` - Email or immutable ID of the group. If ID, it should match with id of group object
4381    /// * `memberKey` - Email or immutable ID of the user. If ID, it should match with id of member object
4382    pub fn patch(&self, request: Member, group_key: &str, member_key: &str) -> MemberPatchCall<'a, C, A> {
4383        MemberPatchCall {
4384            hub: self.hub,
4385            _request: request,
4386            _group_key: group_key.to_string(),
4387            _member_key: member_key.to_string(),
4388            _delegate: Default::default(),
4389            _scopes: Default::default(),
4390            _additional_params: Default::default(),
4391        }
4392    }
4393    
4394    /// Create a builder to help you perform the following task:
4395    ///
4396    /// Update membership of a user in the specified group.
4397    /// 
4398    /// # Arguments
4399    ///
4400    /// * `request` - No description provided.
4401    /// * `groupKey` - Email or immutable ID of the group. If ID, it should match with id of group object
4402    /// * `memberKey` - Email or immutable ID of the user. If ID, it should match with id of member object
4403    pub fn update(&self, request: Member, group_key: &str, member_key: &str) -> MemberUpdateCall<'a, C, A> {
4404        MemberUpdateCall {
4405            hub: self.hub,
4406            _request: request,
4407            _group_key: group_key.to_string(),
4408            _member_key: member_key.to_string(),
4409            _delegate: Default::default(),
4410            _scopes: Default::default(),
4411            _additional_params: Default::default(),
4412        }
4413    }
4414    
4415    /// Create a builder to help you perform the following task:
4416    ///
4417    /// Retrieve all members in a group (paginated)
4418    /// 
4419    /// # Arguments
4420    ///
4421    /// * `groupKey` - Email or immutable ID of the group
4422    pub fn list(&self, group_key: &str) -> MemberListCall<'a, C, A> {
4423        MemberListCall {
4424            hub: self.hub,
4425            _group_key: group_key.to_string(),
4426            _roles: Default::default(),
4427            _page_token: Default::default(),
4428            _max_results: Default::default(),
4429            _include_derived_membership: Default::default(),
4430            _delegate: Default::default(),
4431            _scopes: Default::default(),
4432            _additional_params: Default::default(),
4433        }
4434    }
4435    
4436    /// Create a builder to help you perform the following task:
4437    ///
4438    /// Retrieve Group Member
4439    /// 
4440    /// # Arguments
4441    ///
4442    /// * `groupKey` - Email or immutable ID of the group
4443    /// * `memberKey` - Email or immutable ID of the member
4444    pub fn get(&self, group_key: &str, member_key: &str) -> MemberGetCall<'a, C, A> {
4445        MemberGetCall {
4446            hub: self.hub,
4447            _group_key: group_key.to_string(),
4448            _member_key: member_key.to_string(),
4449            _delegate: Default::default(),
4450            _scopes: Default::default(),
4451            _additional_params: Default::default(),
4452        }
4453    }
4454    
4455    /// Create a builder to help you perform the following task:
4456    ///
4457    /// Remove membership.
4458    /// 
4459    /// # Arguments
4460    ///
4461    /// * `groupKey` - Email or immutable ID of the group
4462    /// * `memberKey` - Email or immutable ID of the member
4463    pub fn delete(&self, group_key: &str, member_key: &str) -> MemberDeleteCall<'a, C, A> {
4464        MemberDeleteCall {
4465            hub: self.hub,
4466            _group_key: group_key.to_string(),
4467            _member_key: member_key.to_string(),
4468            _delegate: Default::default(),
4469            _scopes: Default::default(),
4470            _additional_params: Default::default(),
4471        }
4472    }
4473}
4474
4475
4476
4477/// A builder providing access to all methods supported on *asp* resources.
4478/// It is not used directly, but through the `Directory` hub.
4479///
4480/// # Example
4481///
4482/// Instantiate a resource builder
4483///
4484/// ```test_harness,no_run
4485/// extern crate hyper;
4486/// extern crate hyper_rustls;
4487/// extern crate yup_oauth2 as oauth2;
4488/// extern crate google_admin1_directory as admin1_directory;
4489/// 
4490/// # #[test] fn egal() {
4491/// use std::default::Default;
4492/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4493/// use admin1_directory::Directory;
4494/// 
4495/// let secret: ApplicationSecret = Default::default();
4496/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4497///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4498///                               <MemoryStorage as Default>::default(), None);
4499/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4500/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4501/// // like `delete(...)`, `get(...)` and `list(...)`
4502/// // to build up your call.
4503/// let rb = hub.asps();
4504/// # }
4505/// ```
4506pub struct AspMethods<'a, C, A>
4507    where C: 'a, A: 'a {
4508
4509    hub: &'a Directory<C, A>,
4510}
4511
4512impl<'a, C, A> MethodsBuilder for AspMethods<'a, C, A> {}
4513
4514impl<'a, C, A> AspMethods<'a, C, A> {
4515    
4516    /// Create a builder to help you perform the following task:
4517    ///
4518    /// Get information about an ASP issued by a user.
4519    /// 
4520    /// # Arguments
4521    ///
4522    /// * `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.
4523    /// * `codeId` - The unique ID of the ASP.
4524    pub fn get(&self, user_key: &str, code_id: i32) -> AspGetCall<'a, C, A> {
4525        AspGetCall {
4526            hub: self.hub,
4527            _user_key: user_key.to_string(),
4528            _code_id: code_id,
4529            _delegate: Default::default(),
4530            _scopes: Default::default(),
4531            _additional_params: Default::default(),
4532        }
4533    }
4534    
4535    /// Create a builder to help you perform the following task:
4536    ///
4537    /// Delete an ASP issued by a user.
4538    /// 
4539    /// # Arguments
4540    ///
4541    /// * `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.
4542    /// * `codeId` - The unique ID of the ASP to be deleted.
4543    pub fn delete(&self, user_key: &str, code_id: i32) -> AspDeleteCall<'a, C, A> {
4544        AspDeleteCall {
4545            hub: self.hub,
4546            _user_key: user_key.to_string(),
4547            _code_id: code_id,
4548            _delegate: Default::default(),
4549            _scopes: Default::default(),
4550            _additional_params: Default::default(),
4551        }
4552    }
4553    
4554    /// Create a builder to help you perform the following task:
4555    ///
4556    /// List the ASPs issued by a user.
4557    /// 
4558    /// # Arguments
4559    ///
4560    /// * `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.
4561    pub fn list(&self, user_key: &str) -> AspListCall<'a, C, A> {
4562        AspListCall {
4563            hub: self.hub,
4564            _user_key: user_key.to_string(),
4565            _delegate: Default::default(),
4566            _scopes: Default::default(),
4567            _additional_params: Default::default(),
4568        }
4569    }
4570}
4571
4572
4573
4574/// A builder providing access to all methods supported on *domain* resources.
4575/// It is not used directly, but through the `Directory` hub.
4576///
4577/// # Example
4578///
4579/// Instantiate a resource builder
4580///
4581/// ```test_harness,no_run
4582/// extern crate hyper;
4583/// extern crate hyper_rustls;
4584/// extern crate yup_oauth2 as oauth2;
4585/// extern crate google_admin1_directory as admin1_directory;
4586/// 
4587/// # #[test] fn egal() {
4588/// use std::default::Default;
4589/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4590/// use admin1_directory::Directory;
4591/// 
4592/// let secret: ApplicationSecret = Default::default();
4593/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4594///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4595///                               <MemoryStorage as Default>::default(), None);
4596/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4597/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4598/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
4599/// // to build up your call.
4600/// let rb = hub.domains();
4601/// # }
4602/// ```
4603pub struct DomainMethods<'a, C, A>
4604    where C: 'a, A: 'a {
4605
4606    hub: &'a Directory<C, A>,
4607}
4608
4609impl<'a, C, A> MethodsBuilder for DomainMethods<'a, C, A> {}
4610
4611impl<'a, C, A> DomainMethods<'a, C, A> {
4612    
4613    /// Create a builder to help you perform the following task:
4614    ///
4615    /// Lists the domains of the customer.
4616    /// 
4617    /// # Arguments
4618    ///
4619    /// * `customer` - Immutable ID of the G Suite account.
4620    pub fn list(&self, customer: &str) -> DomainListCall<'a, C, A> {
4621        DomainListCall {
4622            hub: self.hub,
4623            _customer: customer.to_string(),
4624            _delegate: Default::default(),
4625            _scopes: Default::default(),
4626            _additional_params: Default::default(),
4627        }
4628    }
4629    
4630    /// Create a builder to help you perform the following task:
4631    ///
4632    /// Retrieves a domain of the customer.
4633    /// 
4634    /// # Arguments
4635    ///
4636    /// * `customer` - Immutable ID of the G Suite account.
4637    /// * `domainName` - Name of domain to be retrieved
4638    pub fn get(&self, customer: &str, domain_name: &str) -> DomainGetCall<'a, C, A> {
4639        DomainGetCall {
4640            hub: self.hub,
4641            _customer: customer.to_string(),
4642            _domain_name: domain_name.to_string(),
4643            _delegate: Default::default(),
4644            _scopes: Default::default(),
4645            _additional_params: Default::default(),
4646        }
4647    }
4648    
4649    /// Create a builder to help you perform the following task:
4650    ///
4651    /// Inserts a domain of the customer.
4652    /// 
4653    /// # Arguments
4654    ///
4655    /// * `request` - No description provided.
4656    /// * `customer` - Immutable ID of the G Suite account.
4657    pub fn insert(&self, request: Domains, customer: &str) -> DomainInsertCall<'a, C, A> {
4658        DomainInsertCall {
4659            hub: self.hub,
4660            _request: request,
4661            _customer: customer.to_string(),
4662            _delegate: Default::default(),
4663            _scopes: Default::default(),
4664            _additional_params: Default::default(),
4665        }
4666    }
4667    
4668    /// Create a builder to help you perform the following task:
4669    ///
4670    /// Deletes a domain of the customer.
4671    /// 
4672    /// # Arguments
4673    ///
4674    /// * `customer` - Immutable ID of the G Suite account.
4675    /// * `domainName` - Name of domain to be deleted
4676    pub fn delete(&self, customer: &str, domain_name: &str) -> DomainDeleteCall<'a, C, A> {
4677        DomainDeleteCall {
4678            hub: self.hub,
4679            _customer: customer.to_string(),
4680            _domain_name: domain_name.to_string(),
4681            _delegate: Default::default(),
4682            _scopes: Default::default(),
4683            _additional_params: Default::default(),
4684        }
4685    }
4686}
4687
4688
4689
4690/// A builder providing access to all methods supported on *domainAliase* resources.
4691/// It is not used directly, but through the `Directory` hub.
4692///
4693/// # Example
4694///
4695/// Instantiate a resource builder
4696///
4697/// ```test_harness,no_run
4698/// extern crate hyper;
4699/// extern crate hyper_rustls;
4700/// extern crate yup_oauth2 as oauth2;
4701/// extern crate google_admin1_directory as admin1_directory;
4702/// 
4703/// # #[test] fn egal() {
4704/// use std::default::Default;
4705/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4706/// use admin1_directory::Directory;
4707/// 
4708/// let secret: ApplicationSecret = Default::default();
4709/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4710///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4711///                               <MemoryStorage as Default>::default(), None);
4712/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4713/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4714/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
4715/// // to build up your call.
4716/// let rb = hub.domain_aliases();
4717/// # }
4718/// ```
4719pub struct DomainAliaseMethods<'a, C, A>
4720    where C: 'a, A: 'a {
4721
4722    hub: &'a Directory<C, A>,
4723}
4724
4725impl<'a, C, A> MethodsBuilder for DomainAliaseMethods<'a, C, A> {}
4726
4727impl<'a, C, A> DomainAliaseMethods<'a, C, A> {
4728    
4729    /// Create a builder to help you perform the following task:
4730    ///
4731    /// Inserts a Domain alias of the customer.
4732    /// 
4733    /// # Arguments
4734    ///
4735    /// * `request` - No description provided.
4736    /// * `customer` - Immutable ID of the G Suite account.
4737    pub fn insert(&self, request: DomainAlias, customer: &str) -> DomainAliaseInsertCall<'a, C, A> {
4738        DomainAliaseInsertCall {
4739            hub: self.hub,
4740            _request: request,
4741            _customer: customer.to_string(),
4742            _delegate: Default::default(),
4743            _scopes: Default::default(),
4744            _additional_params: Default::default(),
4745        }
4746    }
4747    
4748    /// Create a builder to help you perform the following task:
4749    ///
4750    /// Retrieves a domain alias of the customer.
4751    /// 
4752    /// # Arguments
4753    ///
4754    /// * `customer` - Immutable ID of the G Suite account.
4755    /// * `domainAliasName` - Name of domain alias to be retrieved.
4756    pub fn get(&self, customer: &str, domain_alias_name: &str) -> DomainAliaseGetCall<'a, C, A> {
4757        DomainAliaseGetCall {
4758            hub: self.hub,
4759            _customer: customer.to_string(),
4760            _domain_alias_name: domain_alias_name.to_string(),
4761            _delegate: Default::default(),
4762            _scopes: Default::default(),
4763            _additional_params: Default::default(),
4764        }
4765    }
4766    
4767    /// Create a builder to help you perform the following task:
4768    ///
4769    /// Lists the domain aliases of the customer.
4770    /// 
4771    /// # Arguments
4772    ///
4773    /// * `customer` - Immutable ID of the G Suite account.
4774    pub fn list(&self, customer: &str) -> DomainAliaseListCall<'a, C, A> {
4775        DomainAliaseListCall {
4776            hub: self.hub,
4777            _customer: customer.to_string(),
4778            _parent_domain_name: Default::default(),
4779            _delegate: Default::default(),
4780            _scopes: Default::default(),
4781            _additional_params: Default::default(),
4782        }
4783    }
4784    
4785    /// Create a builder to help you perform the following task:
4786    ///
4787    /// Deletes a Domain Alias of the customer.
4788    /// 
4789    /// # Arguments
4790    ///
4791    /// * `customer` - Immutable ID of the G Suite account.
4792    /// * `domainAliasName` - Name of domain alias to be retrieved.
4793    pub fn delete(&self, customer: &str, domain_alias_name: &str) -> DomainAliaseDeleteCall<'a, C, A> {
4794        DomainAliaseDeleteCall {
4795            hub: self.hub,
4796            _customer: customer.to_string(),
4797            _domain_alias_name: domain_alias_name.to_string(),
4798            _delegate: Default::default(),
4799            _scopes: Default::default(),
4800            _additional_params: Default::default(),
4801        }
4802    }
4803}
4804
4805
4806
4807/// A builder providing access to all methods supported on *schema* resources.
4808/// It is not used directly, but through the `Directory` hub.
4809///
4810/// # Example
4811///
4812/// Instantiate a resource builder
4813///
4814/// ```test_harness,no_run
4815/// extern crate hyper;
4816/// extern crate hyper_rustls;
4817/// extern crate yup_oauth2 as oauth2;
4818/// extern crate google_admin1_directory as admin1_directory;
4819/// 
4820/// # #[test] fn egal() {
4821/// use std::default::Default;
4822/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4823/// use admin1_directory::Directory;
4824/// 
4825/// let secret: ApplicationSecret = Default::default();
4826/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4827///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4828///                               <MemoryStorage as Default>::default(), None);
4829/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4830/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4831/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
4832/// // to build up your call.
4833/// let rb = hub.schemas();
4834/// # }
4835/// ```
4836pub struct SchemaMethods<'a, C, A>
4837    where C: 'a, A: 'a {
4838
4839    hub: &'a Directory<C, A>,
4840}
4841
4842impl<'a, C, A> MethodsBuilder for SchemaMethods<'a, C, A> {}
4843
4844impl<'a, C, A> SchemaMethods<'a, C, A> {
4845    
4846    /// Create a builder to help you perform the following task:
4847    ///
4848    /// Retrieve schema
4849    /// 
4850    /// # Arguments
4851    ///
4852    /// * `customerId` - Immutable ID of the G Suite account
4853    /// * `schemaKey` - Name or immutable ID of the schema
4854    pub fn get(&self, customer_id: &str, schema_key: &str) -> SchemaGetCall<'a, C, A> {
4855        SchemaGetCall {
4856            hub: self.hub,
4857            _customer_id: customer_id.to_string(),
4858            _schema_key: schema_key.to_string(),
4859            _delegate: Default::default(),
4860            _scopes: Default::default(),
4861            _additional_params: Default::default(),
4862        }
4863    }
4864    
4865    /// Create a builder to help you perform the following task:
4866    ///
4867    /// Update schema
4868    /// 
4869    /// # Arguments
4870    ///
4871    /// * `request` - No description provided.
4872    /// * `customerId` - Immutable ID of the G Suite account
4873    /// * `schemaKey` - Name or immutable ID of the schema.
4874    pub fn update(&self, request: Schema, customer_id: &str, schema_key: &str) -> SchemaUpdateCall<'a, C, A> {
4875        SchemaUpdateCall {
4876            hub: self.hub,
4877            _request: request,
4878            _customer_id: customer_id.to_string(),
4879            _schema_key: schema_key.to_string(),
4880            _delegate: Default::default(),
4881            _scopes: Default::default(),
4882            _additional_params: Default::default(),
4883        }
4884    }
4885    
4886    /// Create a builder to help you perform the following task:
4887    ///
4888    /// Retrieve all schemas for a customer
4889    /// 
4890    /// # Arguments
4891    ///
4892    /// * `customerId` - Immutable ID of the G Suite account
4893    pub fn list(&self, customer_id: &str) -> SchemaListCall<'a, C, A> {
4894        SchemaListCall {
4895            hub: self.hub,
4896            _customer_id: customer_id.to_string(),
4897            _delegate: Default::default(),
4898            _scopes: Default::default(),
4899            _additional_params: Default::default(),
4900        }
4901    }
4902    
4903    /// Create a builder to help you perform the following task:
4904    ///
4905    /// Update schema. This method supports patch semantics.
4906    /// 
4907    /// # Arguments
4908    ///
4909    /// * `request` - No description provided.
4910    /// * `customerId` - Immutable ID of the G Suite account
4911    /// * `schemaKey` - Name or immutable ID of the schema.
4912    pub fn patch(&self, request: Schema, customer_id: &str, schema_key: &str) -> SchemaPatchCall<'a, C, A> {
4913        SchemaPatchCall {
4914            hub: self.hub,
4915            _request: request,
4916            _customer_id: customer_id.to_string(),
4917            _schema_key: schema_key.to_string(),
4918            _delegate: Default::default(),
4919            _scopes: Default::default(),
4920            _additional_params: Default::default(),
4921        }
4922    }
4923    
4924    /// Create a builder to help you perform the following task:
4925    ///
4926    /// Create schema.
4927    /// 
4928    /// # Arguments
4929    ///
4930    /// * `request` - No description provided.
4931    /// * `customerId` - Immutable ID of the G Suite account
4932    pub fn insert(&self, request: Schema, customer_id: &str) -> SchemaInsertCall<'a, C, A> {
4933        SchemaInsertCall {
4934            hub: self.hub,
4935            _request: request,
4936            _customer_id: customer_id.to_string(),
4937            _delegate: Default::default(),
4938            _scopes: Default::default(),
4939            _additional_params: Default::default(),
4940        }
4941    }
4942    
4943    /// Create a builder to help you perform the following task:
4944    ///
4945    /// Delete schema
4946    /// 
4947    /// # Arguments
4948    ///
4949    /// * `customerId` - Immutable ID of the G Suite account
4950    /// * `schemaKey` - Name or immutable ID of the schema
4951    pub fn delete(&self, customer_id: &str, schema_key: &str) -> SchemaDeleteCall<'a, C, A> {
4952        SchemaDeleteCall {
4953            hub: self.hub,
4954            _customer_id: customer_id.to_string(),
4955            _schema_key: schema_key.to_string(),
4956            _delegate: Default::default(),
4957            _scopes: Default::default(),
4958            _additional_params: Default::default(),
4959        }
4960    }
4961}
4962
4963
4964
4965/// A builder providing access to all methods supported on *resource* resources.
4966/// It is not used directly, but through the `Directory` hub.
4967///
4968/// # Example
4969///
4970/// Instantiate a resource builder
4971///
4972/// ```test_harness,no_run
4973/// extern crate hyper;
4974/// extern crate hyper_rustls;
4975/// extern crate yup_oauth2 as oauth2;
4976/// extern crate google_admin1_directory as admin1_directory;
4977/// 
4978/// # #[test] fn egal() {
4979/// use std::default::Default;
4980/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
4981/// use admin1_directory::Directory;
4982/// 
4983/// let secret: ApplicationSecret = Default::default();
4984/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
4985///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
4986///                               <MemoryStorage as Default>::default(), None);
4987/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
4988/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4989/// // like `buildings_delete(...)`, `buildings_get(...)`, `buildings_insert(...)`, `buildings_list(...)`, `buildings_patch(...)`, `buildings_update(...)`, `calendars_delete(...)`, `calendars_get(...)`, `calendars_insert(...)`, `calendars_list(...)`, `calendars_patch(...)`, `calendars_update(...)`, `features_delete(...)`, `features_get(...)`, `features_insert(...)`, `features_list(...)`, `features_patch(...)`, `features_rename(...)` and `features_update(...)`
4990/// // to build up your call.
4991/// let rb = hub.resources();
4992/// # }
4993/// ```
4994pub struct ResourceMethods<'a, C, A>
4995    where C: 'a, A: 'a {
4996
4997    hub: &'a Directory<C, A>,
4998}
4999
5000impl<'a, C, A> MethodsBuilder for ResourceMethods<'a, C, A> {}
5001
5002impl<'a, C, A> ResourceMethods<'a, C, A> {
5003    
5004    /// Create a builder to help you perform the following task:
5005    ///
5006    /// Retrieves a list of calendar resources for an account.
5007    /// 
5008    /// # Arguments
5009    ///
5010    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5011    pub fn calendars_list(&self, customer: &str) -> ResourceCalendarListCall<'a, C, A> {
5012        ResourceCalendarListCall {
5013            hub: self.hub,
5014            _customer: customer.to_string(),
5015            _query: Default::default(),
5016            _page_token: Default::default(),
5017            _order_by: Default::default(),
5018            _max_results: Default::default(),
5019            _delegate: Default::default(),
5020            _scopes: Default::default(),
5021            _additional_params: Default::default(),
5022        }
5023    }
5024    
5025    /// Create a builder to help you perform the following task:
5026    ///
5027    /// Renames a feature.
5028    /// 
5029    /// # Arguments
5030    ///
5031    /// * `request` - No description provided.
5032    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5033    /// * `oldName` - The unique ID of the feature to rename.
5034    pub fn features_rename(&self, request: FeatureRename, customer: &str, old_name: &str) -> ResourceFeatureRenameCall<'a, C, A> {
5035        ResourceFeatureRenameCall {
5036            hub: self.hub,
5037            _request: request,
5038            _customer: customer.to_string(),
5039            _old_name: old_name.to_string(),
5040            _delegate: Default::default(),
5041            _scopes: Default::default(),
5042            _additional_params: Default::default(),
5043        }
5044    }
5045    
5046    /// Create a builder to help you perform the following task:
5047    ///
5048    /// Inserts a feature.
5049    /// 
5050    /// # Arguments
5051    ///
5052    /// * `request` - No description provided.
5053    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5054    pub fn features_insert(&self, request: Feature, customer: &str) -> ResourceFeatureInsertCall<'a, C, A> {
5055        ResourceFeatureInsertCall {
5056            hub: self.hub,
5057            _request: request,
5058            _customer: customer.to_string(),
5059            _delegate: Default::default(),
5060            _scopes: Default::default(),
5061            _additional_params: Default::default(),
5062        }
5063    }
5064    
5065    /// Create a builder to help you perform the following task:
5066    ///
5067    /// Updates a building.
5068    /// 
5069    /// # Arguments
5070    ///
5071    /// * `request` - No description provided.
5072    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5073    /// * `buildingId` - The ID of the building to update.
5074    pub fn buildings_update(&self, request: Building, customer: &str, building_id: &str) -> ResourceBuildingUpdateCall<'a, C, A> {
5075        ResourceBuildingUpdateCall {
5076            hub: self.hub,
5077            _request: request,
5078            _customer: customer.to_string(),
5079            _building_id: building_id.to_string(),
5080            _coordinates_source: Default::default(),
5081            _delegate: Default::default(),
5082            _scopes: Default::default(),
5083            _additional_params: Default::default(),
5084        }
5085    }
5086    
5087    /// Create a builder to help you perform the following task:
5088    ///
5089    /// Deletes a building.
5090    /// 
5091    /// # Arguments
5092    ///
5093    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5094    /// * `buildingId` - The ID of the building to delete.
5095    pub fn buildings_delete(&self, customer: &str, building_id: &str) -> ResourceBuildingDeleteCall<'a, C, A> {
5096        ResourceBuildingDeleteCall {
5097            hub: self.hub,
5098            _customer: customer.to_string(),
5099            _building_id: building_id.to_string(),
5100            _delegate: Default::default(),
5101            _scopes: Default::default(),
5102            _additional_params: Default::default(),
5103        }
5104    }
5105    
5106    /// Create a builder to help you perform the following task:
5107    ///
5108    /// Retrieves a list of features for an account.
5109    /// 
5110    /// # Arguments
5111    ///
5112    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5113    pub fn features_list(&self, customer: &str) -> ResourceFeatureListCall<'a, C, A> {
5114        ResourceFeatureListCall {
5115            hub: self.hub,
5116            _customer: customer.to_string(),
5117            _page_token: Default::default(),
5118            _max_results: Default::default(),
5119            _delegate: Default::default(),
5120            _scopes: Default::default(),
5121            _additional_params: Default::default(),
5122        }
5123    }
5124    
5125    /// Create a builder to help you perform the following task:
5126    ///
5127    /// Retrieves a calendar resource.
5128    /// 
5129    /// # Arguments
5130    ///
5131    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5132    /// * `calendarResourceId` - The unique ID of the calendar resource to retrieve.
5133    pub fn calendars_get(&self, customer: &str, calendar_resource_id: &str) -> ResourceCalendarGetCall<'a, C, A> {
5134        ResourceCalendarGetCall {
5135            hub: self.hub,
5136            _customer: customer.to_string(),
5137            _calendar_resource_id: calendar_resource_id.to_string(),
5138            _delegate: Default::default(),
5139            _scopes: Default::default(),
5140            _additional_params: Default::default(),
5141        }
5142    }
5143    
5144    /// Create a builder to help you perform the following task:
5145    ///
5146    /// Updates a building. This method supports patch semantics.
5147    /// 
5148    /// # Arguments
5149    ///
5150    /// * `request` - No description provided.
5151    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5152    /// * `buildingId` - The ID of the building to update.
5153    pub fn buildings_patch(&self, request: Building, customer: &str, building_id: &str) -> ResourceBuildingPatchCall<'a, C, A> {
5154        ResourceBuildingPatchCall {
5155            hub: self.hub,
5156            _request: request,
5157            _customer: customer.to_string(),
5158            _building_id: building_id.to_string(),
5159            _coordinates_source: Default::default(),
5160            _delegate: Default::default(),
5161            _scopes: Default::default(),
5162            _additional_params: Default::default(),
5163        }
5164    }
5165    
5166    /// Create a builder to help you perform the following task:
5167    ///
5168    /// Retrieves a list of buildings for an account.
5169    /// 
5170    /// # Arguments
5171    ///
5172    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5173    pub fn buildings_list(&self, customer: &str) -> ResourceBuildingListCall<'a, C, A> {
5174        ResourceBuildingListCall {
5175            hub: self.hub,
5176            _customer: customer.to_string(),
5177            _page_token: Default::default(),
5178            _max_results: Default::default(),
5179            _delegate: Default::default(),
5180            _scopes: Default::default(),
5181            _additional_params: Default::default(),
5182        }
5183    }
5184    
5185    /// Create a builder to help you perform the following task:
5186    ///
5187    /// Retrieves a feature.
5188    /// 
5189    /// # Arguments
5190    ///
5191    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5192    /// * `featureKey` - The unique ID of the feature to retrieve.
5193    pub fn features_get(&self, customer: &str, feature_key: &str) -> ResourceFeatureGetCall<'a, C, A> {
5194        ResourceFeatureGetCall {
5195            hub: self.hub,
5196            _customer: customer.to_string(),
5197            _feature_key: feature_key.to_string(),
5198            _delegate: Default::default(),
5199            _scopes: Default::default(),
5200            _additional_params: Default::default(),
5201        }
5202    }
5203    
5204    /// Create a builder to help you perform the following task:
5205    ///
5206    /// Inserts a calendar resource.
5207    /// 
5208    /// # Arguments
5209    ///
5210    /// * `request` - No description provided.
5211    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5212    pub fn calendars_insert(&self, request: CalendarResource, customer: &str) -> ResourceCalendarInsertCall<'a, C, A> {
5213        ResourceCalendarInsertCall {
5214            hub: self.hub,
5215            _request: request,
5216            _customer: customer.to_string(),
5217            _delegate: Default::default(),
5218            _scopes: Default::default(),
5219            _additional_params: Default::default(),
5220        }
5221    }
5222    
5223    /// Create a builder to help you perform the following task:
5224    ///
5225    /// Updates a feature. This method supports patch semantics.
5226    /// 
5227    /// # Arguments
5228    ///
5229    /// * `request` - No description provided.
5230    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5231    /// * `featureKey` - The unique ID of the feature to update.
5232    pub fn features_patch(&self, request: Feature, customer: &str, feature_key: &str) -> ResourceFeaturePatchCall<'a, C, A> {
5233        ResourceFeaturePatchCall {
5234            hub: self.hub,
5235            _request: request,
5236            _customer: customer.to_string(),
5237            _feature_key: feature_key.to_string(),
5238            _delegate: Default::default(),
5239            _scopes: Default::default(),
5240            _additional_params: Default::default(),
5241        }
5242    }
5243    
5244    /// Create a builder to help you perform the following task:
5245    ///
5246    /// Retrieves a building.
5247    /// 
5248    /// # Arguments
5249    ///
5250    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5251    /// * `buildingId` - The unique ID of the building to retrieve.
5252    pub fn buildings_get(&self, customer: &str, building_id: &str) -> ResourceBuildingGetCall<'a, C, A> {
5253        ResourceBuildingGetCall {
5254            hub: self.hub,
5255            _customer: customer.to_string(),
5256            _building_id: building_id.to_string(),
5257            _delegate: Default::default(),
5258            _scopes: Default::default(),
5259            _additional_params: Default::default(),
5260        }
5261    }
5262    
5263    /// Create a builder to help you perform the following task:
5264    ///
5265    /// Deletes a feature.
5266    /// 
5267    /// # Arguments
5268    ///
5269    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5270    /// * `featureKey` - The unique ID of the feature to delete.
5271    pub fn features_delete(&self, customer: &str, feature_key: &str) -> ResourceFeatureDeleteCall<'a, C, A> {
5272        ResourceFeatureDeleteCall {
5273            hub: self.hub,
5274            _customer: customer.to_string(),
5275            _feature_key: feature_key.to_string(),
5276            _delegate: Default::default(),
5277            _scopes: Default::default(),
5278            _additional_params: Default::default(),
5279        }
5280    }
5281    
5282    /// Create a builder to help you perform the following task:
5283    ///
5284    /// Updates a feature.
5285    /// 
5286    /// # Arguments
5287    ///
5288    /// * `request` - No description provided.
5289    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5290    /// * `featureKey` - The unique ID of the feature to update.
5291    pub fn features_update(&self, request: Feature, customer: &str, feature_key: &str) -> ResourceFeatureUpdateCall<'a, C, A> {
5292        ResourceFeatureUpdateCall {
5293            hub: self.hub,
5294            _request: request,
5295            _customer: customer.to_string(),
5296            _feature_key: feature_key.to_string(),
5297            _delegate: Default::default(),
5298            _scopes: Default::default(),
5299            _additional_params: Default::default(),
5300        }
5301    }
5302    
5303    /// Create a builder to help you perform the following task:
5304    ///
5305    /// Inserts a building.
5306    /// 
5307    /// # Arguments
5308    ///
5309    /// * `request` - No description provided.
5310    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5311    pub fn buildings_insert(&self, request: Building, customer: &str) -> ResourceBuildingInsertCall<'a, C, A> {
5312        ResourceBuildingInsertCall {
5313            hub: self.hub,
5314            _request: request,
5315            _customer: customer.to_string(),
5316            _coordinates_source: Default::default(),
5317            _delegate: Default::default(),
5318            _scopes: Default::default(),
5319            _additional_params: Default::default(),
5320        }
5321    }
5322    
5323    /// Create a builder to help you perform the following task:
5324    ///
5325    /// Updates a calendar resource.
5326    /// 
5327    /// This method supports patch semantics, meaning you only need to include the fields you wish to update. Fields that are not present in the request will be preserved. This method supports patch semantics.
5328    /// 
5329    /// # Arguments
5330    ///
5331    /// * `request` - No description provided.
5332    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5333    /// * `calendarResourceId` - The unique ID of the calendar resource to update.
5334    pub fn calendars_patch(&self, request: CalendarResource, customer: &str, calendar_resource_id: &str) -> ResourceCalendarPatchCall<'a, C, A> {
5335        ResourceCalendarPatchCall {
5336            hub: self.hub,
5337            _request: request,
5338            _customer: customer.to_string(),
5339            _calendar_resource_id: calendar_resource_id.to_string(),
5340            _delegate: Default::default(),
5341            _scopes: Default::default(),
5342            _additional_params: Default::default(),
5343        }
5344    }
5345    
5346    /// Create a builder to help you perform the following task:
5347    ///
5348    /// Updates a calendar resource.
5349    /// 
5350    /// This method supports patch semantics, meaning you only need to include the fields you wish to update. Fields that are not present in the request will be preserved.
5351    /// 
5352    /// # Arguments
5353    ///
5354    /// * `request` - No description provided.
5355    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5356    /// * `calendarResourceId` - The unique ID of the calendar resource to update.
5357    pub fn calendars_update(&self, request: CalendarResource, customer: &str, calendar_resource_id: &str) -> ResourceCalendarUpdateCall<'a, C, A> {
5358        ResourceCalendarUpdateCall {
5359            hub: self.hub,
5360            _request: request,
5361            _customer: customer.to_string(),
5362            _calendar_resource_id: calendar_resource_id.to_string(),
5363            _delegate: Default::default(),
5364            _scopes: Default::default(),
5365            _additional_params: Default::default(),
5366        }
5367    }
5368    
5369    /// Create a builder to help you perform the following task:
5370    ///
5371    /// Deletes a calendar resource.
5372    /// 
5373    /// # Arguments
5374    ///
5375    /// * `customer` - The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
5376    /// * `calendarResourceId` - The unique ID of the calendar resource to delete.
5377    pub fn calendars_delete(&self, customer: &str, calendar_resource_id: &str) -> ResourceCalendarDeleteCall<'a, C, A> {
5378        ResourceCalendarDeleteCall {
5379            hub: self.hub,
5380            _customer: customer.to_string(),
5381            _calendar_resource_id: calendar_resource_id.to_string(),
5382            _delegate: Default::default(),
5383            _scopes: Default::default(),
5384            _additional_params: Default::default(),
5385        }
5386    }
5387}
5388
5389
5390
5391/// A builder providing access to all methods supported on *user* resources.
5392/// It is not used directly, but through the `Directory` hub.
5393///
5394/// # Example
5395///
5396/// Instantiate a resource builder
5397///
5398/// ```test_harness,no_run
5399/// extern crate hyper;
5400/// extern crate hyper_rustls;
5401/// extern crate yup_oauth2 as oauth2;
5402/// extern crate google_admin1_directory as admin1_directory;
5403/// 
5404/// # #[test] fn egal() {
5405/// use std::default::Default;
5406/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
5407/// use admin1_directory::Directory;
5408/// 
5409/// let secret: ApplicationSecret = Default::default();
5410/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
5411///                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
5412///                               <MemoryStorage as Default>::default(), None);
5413/// let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
5414/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
5415/// // 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(...)`
5416/// // to build up your call.
5417/// let rb = hub.users();
5418/// # }
5419/// ```
5420pub struct UserMethods<'a, C, A>
5421    where C: 'a, A: 'a {
5422
5423    hub: &'a Directory<C, A>,
5424}
5425
5426impl<'a, C, A> MethodsBuilder for UserMethods<'a, C, A> {}
5427
5428impl<'a, C, A> UserMethods<'a, C, A> {
5429    
5430    /// Create a builder to help you perform the following task:
5431    ///
5432    /// Undelete a deleted user
5433    /// 
5434    /// # Arguments
5435    ///
5436    /// * `request` - No description provided.
5437    /// * `userKey` - The immutable id of the user
5438    pub fn undelete(&self, request: UserUndelete, user_key: &str) -> UserUndeleteCall<'a, C, A> {
5439        UserUndeleteCall {
5440            hub: self.hub,
5441            _request: request,
5442            _user_key: user_key.to_string(),
5443            _delegate: Default::default(),
5444            _scopes: Default::default(),
5445            _additional_params: Default::default(),
5446        }
5447    }
5448    
5449    /// Create a builder to help you perform the following task:
5450    ///
5451    /// Remove photos for the user
5452    /// 
5453    /// # Arguments
5454    ///
5455    /// * `userKey` - Email or immutable ID of the user
5456    pub fn photos_delete(&self, user_key: &str) -> UserPhotoDeleteCall<'a, C, A> {
5457        UserPhotoDeleteCall {
5458            hub: self.hub,
5459            _user_key: user_key.to_string(),
5460            _delegate: Default::default(),
5461            _scopes: Default::default(),
5462            _additional_params: Default::default(),
5463        }
5464    }
5465    
5466    /// Create a builder to help you perform the following task:
5467    ///
5468    /// Add a photo for the user. This method supports patch semantics.
5469    /// 
5470    /// # Arguments
5471    ///
5472    /// * `request` - No description provided.
5473    /// * `userKey` - Email or immutable ID of the user
5474    pub fn photos_patch(&self, request: UserPhoto, user_key: &str) -> UserPhotoPatchCall<'a, C, A> {
5475        UserPhotoPatchCall {
5476            hub: self.hub,
5477            _request: request,
5478            _user_key: user_key.to_string(),
5479            _delegate: Default::default(),
5480            _scopes: Default::default(),
5481            _additional_params: Default::default(),
5482        }
5483    }
5484    
5485    /// Create a builder to help you perform the following task:
5486    ///
5487    /// create user.
5488    /// 
5489    /// # Arguments
5490    ///
5491    /// * `request` - No description provided.
5492    pub fn insert(&self, request: User) -> UserInsertCall<'a, C, A> {
5493        UserInsertCall {
5494            hub: self.hub,
5495            _request: request,
5496            _delegate: Default::default(),
5497            _scopes: Default::default(),
5498            _additional_params: Default::default(),
5499        }
5500    }
5501    
5502    /// Create a builder to help you perform the following task:
5503    ///
5504    /// Watch for changes in user aliases list
5505    /// 
5506    /// # Arguments
5507    ///
5508    /// * `request` - No description provided.
5509    /// * `userKey` - Email or immutable ID of the user
5510    pub fn aliases_watch(&self, request: Channel, user_key: &str) -> UserAliaseWatchCall<'a, C, A> {
5511        UserAliaseWatchCall {
5512            hub: self.hub,
5513            _request: request,
5514            _user_key: user_key.to_string(),
5515            _event: Default::default(),
5516            _delegate: Default::default(),
5517            _scopes: Default::default(),
5518            _additional_params: Default::default(),
5519        }
5520    }
5521    
5522    /// Create a builder to help you perform the following task:
5523    ///
5524    /// Add a photo for the user
5525    /// 
5526    /// # Arguments
5527    ///
5528    /// * `request` - No description provided.
5529    /// * `userKey` - Email or immutable ID of the user
5530    pub fn photos_update(&self, request: UserPhoto, user_key: &str) -> UserPhotoUpdateCall<'a, C, A> {
5531        UserPhotoUpdateCall {
5532            hub: self.hub,
5533            _request: request,
5534            _user_key: user_key.to_string(),
5535            _delegate: Default::default(),
5536            _scopes: Default::default(),
5537            _additional_params: Default::default(),
5538        }
5539    }
5540    
5541    /// Create a builder to help you perform the following task:
5542    ///
5543    /// Watch for changes in users list
5544    /// 
5545    /// # Arguments
5546    ///
5547    /// * `request` - No description provided.
5548    pub fn watch(&self, request: Channel) -> UserWatchCall<'a, C, A> {
5549        UserWatchCall {
5550            hub: self.hub,
5551            _request: request,
5552            _view_type: Default::default(),
5553            _sort_order: Default::default(),
5554            _show_deleted: Default::default(),
5555            _query: Default::default(),
5556            _projection: Default::default(),
5557            _page_token: Default::default(),
5558            _order_by: Default::default(),
5559            _max_results: Default::default(),
5560            _event: Default::default(),
5561            _domain: Default::default(),
5562            _customer: Default::default(),
5563            _custom_field_mask: Default::default(),
5564            _delegate: Default::default(),
5565            _scopes: Default::default(),
5566            _additional_params: Default::default(),
5567        }
5568    }
5569    
5570    /// Create a builder to help you perform the following task:
5571    ///
5572    /// update user
5573    /// 
5574    /// # Arguments
5575    ///
5576    /// * `request` - No description provided.
5577    /// * `userKey` - Email or immutable ID of the user. If ID, it should match with id of user object
5578    pub fn update(&self, request: User, user_key: &str) -> UserUpdateCall<'a, C, A> {
5579        UserUpdateCall {
5580            hub: self.hub,
5581            _request: request,
5582            _user_key: user_key.to_string(),
5583            _delegate: Default::default(),
5584            _scopes: Default::default(),
5585            _additional_params: Default::default(),
5586        }
5587    }
5588    
5589    /// Create a builder to help you perform the following task:
5590    ///
5591    /// Retrieve photo of a user
5592    /// 
5593    /// # Arguments
5594    ///
5595    /// * `userKey` - Email or immutable ID of the user
5596    pub fn photos_get(&self, user_key: &str) -> UserPhotoGetCall<'a, C, A> {
5597        UserPhotoGetCall {
5598            hub: self.hub,
5599            _user_key: user_key.to_string(),
5600            _delegate: Default::default(),
5601            _scopes: Default::default(),
5602            _additional_params: Default::default(),
5603        }
5604    }
5605    
5606    /// Create a builder to help you perform the following task:
5607    ///
5608    /// Retrieve either deleted users or all users in a domain (paginated)
5609    pub fn list(&self) -> UserListCall<'a, C, A> {
5610        UserListCall {
5611            hub: self.hub,
5612            _view_type: Default::default(),
5613            _sort_order: Default::default(),
5614            _show_deleted: Default::default(),
5615            _query: Default::default(),
5616            _projection: Default::default(),
5617            _page_token: Default::default(),
5618            _order_by: Default::default(),
5619            _max_results: Default::default(),
5620            _event: Default::default(),
5621            _domain: Default::default(),
5622            _customer: Default::default(),
5623            _custom_field_mask: Default::default(),
5624            _delegate: Default::default(),
5625            _scopes: Default::default(),
5626            _additional_params: Default::default(),
5627        }
5628    }
5629    
5630    /// Create a builder to help you perform the following task:
5631    ///
5632    /// retrieve user
5633    /// 
5634    /// # Arguments
5635    ///
5636    /// * `userKey` - Email or immutable ID of the user
5637    pub fn get(&self, user_key: &str) -> UserGetCall<'a, C, A> {
5638        UserGetCall {
5639            hub: self.hub,
5640            _user_key: user_key.to_string(),
5641            _view_type: Default::default(),
5642            _projection: Default::default(),
5643            _custom_field_mask: Default::default(),
5644            _delegate: Default::default(),
5645            _scopes: Default::default(),
5646            _additional_params: Default::default(),
5647        }
5648    }
5649    
5650    /// Create a builder to help you perform the following task:
5651    ///
5652    /// Add a alias for the user
5653    /// 
5654    /// # Arguments
5655    ///
5656    /// * `request` - No description provided.
5657    /// * `userKey` - Email or immutable ID of the user
5658    pub fn aliases_insert(&self, request: Alias, user_key: &str) -> UserAliaseInsertCall<'a, C, A> {
5659        UserAliaseInsertCall {
5660            hub: self.hub,
5661            _request: request,
5662            _user_key: user_key.to_string(),
5663            _delegate: Default::default(),
5664            _scopes: Default::default(),
5665            _additional_params: Default::default(),
5666        }
5667    }
5668    
5669    /// Create a builder to help you perform the following task:
5670    ///
5671    /// List all aliases for a user
5672    /// 
5673    /// # Arguments
5674    ///
5675    /// * `userKey` - Email or immutable ID of the user
5676    pub fn aliases_list(&self, user_key: &str) -> UserAliaseListCall<'a, C, A> {
5677        UserAliaseListCall {
5678            hub: self.hub,
5679            _user_key: user_key.to_string(),
5680            _event: Default::default(),
5681            _delegate: Default::default(),
5682            _scopes: Default::default(),
5683            _additional_params: Default::default(),
5684        }
5685    }
5686    
5687    /// Create a builder to help you perform the following task:
5688    ///
5689    /// change admin status of a user
5690    /// 
5691    /// # Arguments
5692    ///
5693    /// * `request` - No description provided.
5694    /// * `userKey` - Email or immutable ID of the user as admin
5695    pub fn make_admin(&self, request: UserMakeAdmin, user_key: &str) -> UserMakeAdminCall<'a, C, A> {
5696        UserMakeAdminCall {
5697            hub: self.hub,
5698            _request: request,
5699            _user_key: user_key.to_string(),
5700            _delegate: Default::default(),
5701            _scopes: Default::default(),
5702            _additional_params: Default::default(),
5703        }
5704    }
5705    
5706    /// Create a builder to help you perform the following task:
5707    ///
5708    /// update user. This method supports patch semantics.
5709    /// 
5710    /// # Arguments
5711    ///
5712    /// * `request` - No description provided.
5713    /// * `userKey` - Email or immutable ID of the user. If ID, it should match with id of user object
5714    pub fn patch(&self, request: User, user_key: &str) -> UserPatchCall<'a, C, A> {
5715        UserPatchCall {
5716            hub: self.hub,
5717            _request: request,
5718            _user_key: user_key.to_string(),
5719            _delegate: Default::default(),
5720            _scopes: Default::default(),
5721            _additional_params: Default::default(),
5722        }
5723    }
5724    
5725    /// Create a builder to help you perform the following task:
5726    ///
5727    /// Remove a alias for the user
5728    /// 
5729    /// # Arguments
5730    ///
5731    /// * `userKey` - Email or immutable ID of the user
5732    /// * `alias` - The alias to be removed
5733    pub fn aliases_delete(&self, user_key: &str, alias: &str) -> UserAliaseDeleteCall<'a, C, A> {
5734        UserAliaseDeleteCall {
5735            hub: self.hub,
5736            _user_key: user_key.to_string(),
5737            _alias: alias.to_string(),
5738            _delegate: Default::default(),
5739            _scopes: Default::default(),
5740            _additional_params: Default::default(),
5741        }
5742    }
5743    
5744    /// Create a builder to help you perform the following task:
5745    ///
5746    /// Delete user
5747    /// 
5748    /// # Arguments
5749    ///
5750    /// * `userKey` - Email or immutable ID of the user
5751    pub fn delete(&self, user_key: &str) -> UserDeleteCall<'a, C, A> {
5752        UserDeleteCall {
5753            hub: self.hub,
5754            _user_key: user_key.to_string(),
5755            _delegate: Default::default(),
5756            _scopes: Default::default(),
5757            _additional_params: Default::default(),
5758        }
5759    }
5760}
5761
5762
5763
5764
5765
5766// ###################
5767// CallBuilders   ###
5768// #################
5769
5770/// Generate new backup verification codes for the user.
5771///
5772/// A builder for the *generate* method supported by a *verificationCode* resource.
5773/// It is not used directly, but through a `VerificationCodeMethods` instance.
5774///
5775/// # Example
5776///
5777/// Instantiate a resource method builder
5778///
5779/// ```test_harness,no_run
5780/// # extern crate hyper;
5781/// # extern crate hyper_rustls;
5782/// # extern crate yup_oauth2 as oauth2;
5783/// # extern crate google_admin1_directory as admin1_directory;
5784/// # #[test] fn egal() {
5785/// # use std::default::Default;
5786/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
5787/// # use admin1_directory::Directory;
5788/// 
5789/// # let secret: ApplicationSecret = Default::default();
5790/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
5791/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
5792/// #                               <MemoryStorage as Default>::default(), None);
5793/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
5794/// // You can configure optional parameters by calling the respective setters at will, and
5795/// // execute the final call using `doit()`.
5796/// // Values shown here are possibly random and not representative !
5797/// let result = hub.verification_codes().generate("userKey")
5798///              .doit();
5799/// # }
5800/// ```
5801pub struct VerificationCodeGenerateCall<'a, C, A>
5802    where C: 'a, A: 'a {
5803
5804    hub: &'a Directory<C, A>,
5805    _user_key: String,
5806    _delegate: Option<&'a mut dyn Delegate>,
5807    _additional_params: HashMap<String, String>,
5808    _scopes: BTreeMap<String, ()>
5809}
5810
5811impl<'a, C, A> CallBuilder for VerificationCodeGenerateCall<'a, C, A> {}
5812
5813impl<'a, C, A> VerificationCodeGenerateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
5814
5815
5816    /// Perform the operation you have build so far.
5817    pub fn doit(mut self) -> Result<hyper::client::Response> {
5818        use std::io::{Read, Seek};
5819        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
5820        let mut dd = DefaultDelegate;
5821        let mut dlg: &mut dyn Delegate = match self._delegate {
5822            Some(d) => d,
5823            None => &mut dd
5824        };
5825        dlg.begin(MethodInfo { id: "directory.verificationCodes.generate",
5826                               http_method: hyper::method::Method::Post });
5827        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
5828        params.push(("userKey", self._user_key.to_string()));
5829        for &field in ["userKey"].iter() {
5830            if self._additional_params.contains_key(field) {
5831                dlg.finished(false);
5832                return Err(Error::FieldClash(field));
5833            }
5834        }
5835        for (name, value) in self._additional_params.iter() {
5836            params.push((&name, value.clone()));
5837        }
5838
5839
5840        let mut url = self.hub._base_url.clone() + "users/{userKey}/verificationCodes/generate";
5841        if self._scopes.len() == 0 {
5842            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
5843        }
5844
5845        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
5846            let mut replace_with: Option<&str> = None;
5847            for &(name, ref value) in params.iter() {
5848                if name == param_name {
5849                    replace_with = Some(value);
5850                    break;
5851                }
5852            }
5853            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
5854        }
5855        {
5856            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
5857            for param_name in ["userKey"].iter() {
5858                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
5859                    indices_for_removal.push(index);
5860                }
5861            }
5862            for &index in indices_for_removal.iter() {
5863                params.remove(index);
5864            }
5865        }
5866
5867        let url = hyper::Url::parse_with_params(&url, params).unwrap();
5868
5869
5870
5871        loop {
5872            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
5873                Ok(token) => token,
5874                Err(err) => {
5875                    match  dlg.token(&*err) {
5876                        Some(token) => token,
5877                        None => {
5878                            dlg.finished(false);
5879                            return Err(Error::MissingToken(err))
5880                        }
5881                    }
5882                }
5883            };
5884            let auth_header = Authorization(Bearer { token: token.access_token });
5885            let mut req_result = {
5886                let mut client = &mut *self.hub.client.borrow_mut();
5887                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
5888                    .header(UserAgent(self.hub._user_agent.clone()))
5889                    .header(auth_header.clone());
5890
5891                dlg.pre_request();
5892                req.send()
5893            };
5894
5895            match req_result {
5896                Err(err) => {
5897                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
5898                        sleep(d);
5899                        continue;
5900                    }
5901                    dlg.finished(false);
5902                    return Err(Error::HttpError(err))
5903                }
5904                Ok(mut res) => {
5905                    if !res.status.is_success() {
5906                        let mut json_err = String::new();
5907                        res.read_to_string(&mut json_err).unwrap();
5908                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
5909                                                              json::from_str(&json_err).ok(),
5910                                                              json::from_str(&json_err).ok()) {
5911                            sleep(d);
5912                            continue;
5913                        }
5914                        dlg.finished(false);
5915                        return match json::from_str::<ErrorResponse>(&json_err){
5916                            Err(_) => Err(Error::Failure(res)),
5917                            Ok(serr) => Err(Error::BadRequest(serr))
5918                        }
5919                    }
5920                    let result_value = res;
5921
5922                    dlg.finished(true);
5923                    return Ok(result_value)
5924                }
5925            }
5926        }
5927    }
5928
5929
5930    /// Email or immutable ID of the user
5931    ///
5932    /// Sets the *user key* path property to the given value.
5933    ///
5934    /// Even though the property as already been set when instantiating this call,
5935    /// we provide this method for API completeness.
5936    pub fn user_key(mut self, new_value: &str) -> VerificationCodeGenerateCall<'a, C, A> {
5937        self._user_key = new_value.to_string();
5938        self
5939    }
5940    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5941    /// while executing the actual API request.
5942    /// 
5943    /// It should be used to handle progress information, and to implement a certain level of resilience.
5944    ///
5945    /// Sets the *delegate* property to the given value.
5946    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> VerificationCodeGenerateCall<'a, C, A> {
5947        self._delegate = Some(new_value);
5948        self
5949    }
5950
5951    /// Set any additional parameter of the query string used in the request.
5952    /// It should be used to set parameters which are not yet available through their own
5953    /// setters.
5954    ///
5955    /// Please note that this method must not be used to set any of the known parameters
5956    /// which have their own setter method. If done anyway, the request will fail.
5957    ///
5958    /// # Additional Parameters
5959    ///
5960    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5961    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5962    /// * *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.
5963    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5964    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5965    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5966    /// * *alt* (query-string) - Data format for the response.
5967    pub fn param<T>(mut self, name: T, value: T) -> VerificationCodeGenerateCall<'a, C, A>
5968                                                        where T: AsRef<str> {
5969        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
5970        self
5971    }
5972
5973    /// Identifies the authorization scope for the method you are building.
5974    ///
5975    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
5976    /// `Scope::DirectoryUserSecurity`.
5977    ///
5978    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5979    /// tokens for more than one scope.
5980    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
5981    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
5982    /// function for details).
5983    ///
5984    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5985    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5986    /// sufficient, a read-write scope will do as well.
5987    pub fn add_scope<T, S>(mut self, scope: T) -> VerificationCodeGenerateCall<'a, C, A>
5988                                                        where T: Into<Option<S>>,
5989                                                              S: AsRef<str> {
5990        match scope.into() {
5991          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
5992          None => None,
5993        };
5994        self
5995    }
5996}
5997
5998
5999/// Invalidate the current backup verification codes for the user.
6000///
6001/// A builder for the *invalidate* method supported by a *verificationCode* resource.
6002/// It is not used directly, but through a `VerificationCodeMethods` instance.
6003///
6004/// # Example
6005///
6006/// Instantiate a resource method builder
6007///
6008/// ```test_harness,no_run
6009/// # extern crate hyper;
6010/// # extern crate hyper_rustls;
6011/// # extern crate yup_oauth2 as oauth2;
6012/// # extern crate google_admin1_directory as admin1_directory;
6013/// # #[test] fn egal() {
6014/// # use std::default::Default;
6015/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
6016/// # use admin1_directory::Directory;
6017/// 
6018/// # let secret: ApplicationSecret = Default::default();
6019/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
6020/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
6021/// #                               <MemoryStorage as Default>::default(), None);
6022/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
6023/// // You can configure optional parameters by calling the respective setters at will, and
6024/// // execute the final call using `doit()`.
6025/// // Values shown here are possibly random and not representative !
6026/// let result = hub.verification_codes().invalidate("userKey")
6027///              .doit();
6028/// # }
6029/// ```
6030pub struct VerificationCodeInvalidateCall<'a, C, A>
6031    where C: 'a, A: 'a {
6032
6033    hub: &'a Directory<C, A>,
6034    _user_key: String,
6035    _delegate: Option<&'a mut dyn Delegate>,
6036    _additional_params: HashMap<String, String>,
6037    _scopes: BTreeMap<String, ()>
6038}
6039
6040impl<'a, C, A> CallBuilder for VerificationCodeInvalidateCall<'a, C, A> {}
6041
6042impl<'a, C, A> VerificationCodeInvalidateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
6043
6044
6045    /// Perform the operation you have build so far.
6046    pub fn doit(mut self) -> Result<hyper::client::Response> {
6047        use std::io::{Read, Seek};
6048        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
6049        let mut dd = DefaultDelegate;
6050        let mut dlg: &mut dyn Delegate = match self._delegate {
6051            Some(d) => d,
6052            None => &mut dd
6053        };
6054        dlg.begin(MethodInfo { id: "directory.verificationCodes.invalidate",
6055                               http_method: hyper::method::Method::Post });
6056        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
6057        params.push(("userKey", self._user_key.to_string()));
6058        for &field in ["userKey"].iter() {
6059            if self._additional_params.contains_key(field) {
6060                dlg.finished(false);
6061                return Err(Error::FieldClash(field));
6062            }
6063        }
6064        for (name, value) in self._additional_params.iter() {
6065            params.push((&name, value.clone()));
6066        }
6067
6068
6069        let mut url = self.hub._base_url.clone() + "users/{userKey}/verificationCodes/invalidate";
6070        if self._scopes.len() == 0 {
6071            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
6072        }
6073
6074        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
6075            let mut replace_with: Option<&str> = None;
6076            for &(name, ref value) in params.iter() {
6077                if name == param_name {
6078                    replace_with = Some(value);
6079                    break;
6080                }
6081            }
6082            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
6083        }
6084        {
6085            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
6086            for param_name in ["userKey"].iter() {
6087                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
6088                    indices_for_removal.push(index);
6089                }
6090            }
6091            for &index in indices_for_removal.iter() {
6092                params.remove(index);
6093            }
6094        }
6095
6096        let url = hyper::Url::parse_with_params(&url, params).unwrap();
6097
6098
6099
6100        loop {
6101            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
6102                Ok(token) => token,
6103                Err(err) => {
6104                    match  dlg.token(&*err) {
6105                        Some(token) => token,
6106                        None => {
6107                            dlg.finished(false);
6108                            return Err(Error::MissingToken(err))
6109                        }
6110                    }
6111                }
6112            };
6113            let auth_header = Authorization(Bearer { token: token.access_token });
6114            let mut req_result = {
6115                let mut client = &mut *self.hub.client.borrow_mut();
6116                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
6117                    .header(UserAgent(self.hub._user_agent.clone()))
6118                    .header(auth_header.clone());
6119
6120                dlg.pre_request();
6121                req.send()
6122            };
6123
6124            match req_result {
6125                Err(err) => {
6126                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
6127                        sleep(d);
6128                        continue;
6129                    }
6130                    dlg.finished(false);
6131                    return Err(Error::HttpError(err))
6132                }
6133                Ok(mut res) => {
6134                    if !res.status.is_success() {
6135                        let mut json_err = String::new();
6136                        res.read_to_string(&mut json_err).unwrap();
6137                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
6138                                                              json::from_str(&json_err).ok(),
6139                                                              json::from_str(&json_err).ok()) {
6140                            sleep(d);
6141                            continue;
6142                        }
6143                        dlg.finished(false);
6144                        return match json::from_str::<ErrorResponse>(&json_err){
6145                            Err(_) => Err(Error::Failure(res)),
6146                            Ok(serr) => Err(Error::BadRequest(serr))
6147                        }
6148                    }
6149                    let result_value = res;
6150
6151                    dlg.finished(true);
6152                    return Ok(result_value)
6153                }
6154            }
6155        }
6156    }
6157
6158
6159    /// Email or immutable ID of the user
6160    ///
6161    /// Sets the *user key* path property to the given value.
6162    ///
6163    /// Even though the property as already been set when instantiating this call,
6164    /// we provide this method for API completeness.
6165    pub fn user_key(mut self, new_value: &str) -> VerificationCodeInvalidateCall<'a, C, A> {
6166        self._user_key = new_value.to_string();
6167        self
6168    }
6169    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6170    /// while executing the actual API request.
6171    /// 
6172    /// It should be used to handle progress information, and to implement a certain level of resilience.
6173    ///
6174    /// Sets the *delegate* property to the given value.
6175    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> VerificationCodeInvalidateCall<'a, C, A> {
6176        self._delegate = Some(new_value);
6177        self
6178    }
6179
6180    /// Set any additional parameter of the query string used in the request.
6181    /// It should be used to set parameters which are not yet available through their own
6182    /// setters.
6183    ///
6184    /// Please note that this method must not be used to set any of the known parameters
6185    /// which have their own setter method. If done anyway, the request will fail.
6186    ///
6187    /// # Additional Parameters
6188    ///
6189    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6190    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6191    /// * *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.
6192    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6193    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6194    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6195    /// * *alt* (query-string) - Data format for the response.
6196    pub fn param<T>(mut self, name: T, value: T) -> VerificationCodeInvalidateCall<'a, C, A>
6197                                                        where T: AsRef<str> {
6198        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
6199        self
6200    }
6201
6202    /// Identifies the authorization scope for the method you are building.
6203    ///
6204    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
6205    /// `Scope::DirectoryUserSecurity`.
6206    ///
6207    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6208    /// tokens for more than one scope.
6209    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
6210    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
6211    /// function for details).
6212    ///
6213    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6214    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6215    /// sufficient, a read-write scope will do as well.
6216    pub fn add_scope<T, S>(mut self, scope: T) -> VerificationCodeInvalidateCall<'a, C, A>
6217                                                        where T: Into<Option<S>>,
6218                                                              S: AsRef<str> {
6219        match scope.into() {
6220          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
6221          None => None,
6222        };
6223        self
6224    }
6225}
6226
6227
6228/// Returns the current set of valid backup verification codes for the specified user.
6229///
6230/// A builder for the *list* method supported by a *verificationCode* resource.
6231/// It is not used directly, but through a `VerificationCodeMethods` instance.
6232///
6233/// # Example
6234///
6235/// Instantiate a resource method builder
6236///
6237/// ```test_harness,no_run
6238/// # extern crate hyper;
6239/// # extern crate hyper_rustls;
6240/// # extern crate yup_oauth2 as oauth2;
6241/// # extern crate google_admin1_directory as admin1_directory;
6242/// # #[test] fn egal() {
6243/// # use std::default::Default;
6244/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
6245/// # use admin1_directory::Directory;
6246/// 
6247/// # let secret: ApplicationSecret = Default::default();
6248/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
6249/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
6250/// #                               <MemoryStorage as Default>::default(), None);
6251/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
6252/// // You can configure optional parameters by calling the respective setters at will, and
6253/// // execute the final call using `doit()`.
6254/// // Values shown here are possibly random and not representative !
6255/// let result = hub.verification_codes().list("userKey")
6256///              .doit();
6257/// # }
6258/// ```
6259pub struct VerificationCodeListCall<'a, C, A>
6260    where C: 'a, A: 'a {
6261
6262    hub: &'a Directory<C, A>,
6263    _user_key: String,
6264    _delegate: Option<&'a mut dyn Delegate>,
6265    _additional_params: HashMap<String, String>,
6266    _scopes: BTreeMap<String, ()>
6267}
6268
6269impl<'a, C, A> CallBuilder for VerificationCodeListCall<'a, C, A> {}
6270
6271impl<'a, C, A> VerificationCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
6272
6273
6274    /// Perform the operation you have build so far.
6275    pub fn doit(mut self) -> Result<(hyper::client::Response, VerificationCodes)> {
6276        use std::io::{Read, Seek};
6277        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
6278        let mut dd = DefaultDelegate;
6279        let mut dlg: &mut dyn Delegate = match self._delegate {
6280            Some(d) => d,
6281            None => &mut dd
6282        };
6283        dlg.begin(MethodInfo { id: "directory.verificationCodes.list",
6284                               http_method: hyper::method::Method::Get });
6285        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
6286        params.push(("userKey", self._user_key.to_string()));
6287        for &field in ["alt", "userKey"].iter() {
6288            if self._additional_params.contains_key(field) {
6289                dlg.finished(false);
6290                return Err(Error::FieldClash(field));
6291            }
6292        }
6293        for (name, value) in self._additional_params.iter() {
6294            params.push((&name, value.clone()));
6295        }
6296
6297        params.push(("alt", "json".to_string()));
6298
6299        let mut url = self.hub._base_url.clone() + "users/{userKey}/verificationCodes";
6300        if self._scopes.len() == 0 {
6301            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
6302        }
6303
6304        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
6305            let mut replace_with: Option<&str> = None;
6306            for &(name, ref value) in params.iter() {
6307                if name == param_name {
6308                    replace_with = Some(value);
6309                    break;
6310                }
6311            }
6312            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
6313        }
6314        {
6315            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
6316            for param_name in ["userKey"].iter() {
6317                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
6318                    indices_for_removal.push(index);
6319                }
6320            }
6321            for &index in indices_for_removal.iter() {
6322                params.remove(index);
6323            }
6324        }
6325
6326        let url = hyper::Url::parse_with_params(&url, params).unwrap();
6327
6328
6329
6330        loop {
6331            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
6332                Ok(token) => token,
6333                Err(err) => {
6334                    match  dlg.token(&*err) {
6335                        Some(token) => token,
6336                        None => {
6337                            dlg.finished(false);
6338                            return Err(Error::MissingToken(err))
6339                        }
6340                    }
6341                }
6342            };
6343            let auth_header = Authorization(Bearer { token: token.access_token });
6344            let mut req_result = {
6345                let mut client = &mut *self.hub.client.borrow_mut();
6346                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
6347                    .header(UserAgent(self.hub._user_agent.clone()))
6348                    .header(auth_header.clone());
6349
6350                dlg.pre_request();
6351                req.send()
6352            };
6353
6354            match req_result {
6355                Err(err) => {
6356                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
6357                        sleep(d);
6358                        continue;
6359                    }
6360                    dlg.finished(false);
6361                    return Err(Error::HttpError(err))
6362                }
6363                Ok(mut res) => {
6364                    if !res.status.is_success() {
6365                        let mut json_err = String::new();
6366                        res.read_to_string(&mut json_err).unwrap();
6367                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
6368                                                              json::from_str(&json_err).ok(),
6369                                                              json::from_str(&json_err).ok()) {
6370                            sleep(d);
6371                            continue;
6372                        }
6373                        dlg.finished(false);
6374                        return match json::from_str::<ErrorResponse>(&json_err){
6375                            Err(_) => Err(Error::Failure(res)),
6376                            Ok(serr) => Err(Error::BadRequest(serr))
6377                        }
6378                    }
6379                    let result_value = {
6380                        let mut json_response = String::new();
6381                        res.read_to_string(&mut json_response).unwrap();
6382                        match json::from_str(&json_response) {
6383                            Ok(decoded) => (res, decoded),
6384                            Err(err) => {
6385                                dlg.response_json_decode_error(&json_response, &err);
6386                                return Err(Error::JsonDecodeError(json_response, err));
6387                            }
6388                        }
6389                    };
6390
6391                    dlg.finished(true);
6392                    return Ok(result_value)
6393                }
6394            }
6395        }
6396    }
6397
6398
6399    /// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
6400    ///
6401    /// Sets the *user key* path property to the given value.
6402    ///
6403    /// Even though the property as already been set when instantiating this call,
6404    /// we provide this method for API completeness.
6405    pub fn user_key(mut self, new_value: &str) -> VerificationCodeListCall<'a, C, A> {
6406        self._user_key = new_value.to_string();
6407        self
6408    }
6409    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6410    /// while executing the actual API request.
6411    /// 
6412    /// It should be used to handle progress information, and to implement a certain level of resilience.
6413    ///
6414    /// Sets the *delegate* property to the given value.
6415    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> VerificationCodeListCall<'a, C, A> {
6416        self._delegate = Some(new_value);
6417        self
6418    }
6419
6420    /// Set any additional parameter of the query string used in the request.
6421    /// It should be used to set parameters which are not yet available through their own
6422    /// setters.
6423    ///
6424    /// Please note that this method must not be used to set any of the known parameters
6425    /// which have their own setter method. If done anyway, the request will fail.
6426    ///
6427    /// # Additional Parameters
6428    ///
6429    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6430    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6431    /// * *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.
6432    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6433    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6434    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6435    /// * *alt* (query-string) - Data format for the response.
6436    pub fn param<T>(mut self, name: T, value: T) -> VerificationCodeListCall<'a, C, A>
6437                                                        where T: AsRef<str> {
6438        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
6439        self
6440    }
6441
6442    /// Identifies the authorization scope for the method you are building.
6443    ///
6444    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
6445    /// `Scope::DirectoryUserSecurity`.
6446    ///
6447    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6448    /// tokens for more than one scope.
6449    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
6450    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
6451    /// function for details).
6452    ///
6453    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6454    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6455    /// sufficient, a read-write scope will do as well.
6456    pub fn add_scope<T, S>(mut self, scope: T) -> VerificationCodeListCall<'a, C, A>
6457                                                        where T: Into<Option<S>>,
6458                                                              S: AsRef<str> {
6459        match scope.into() {
6460          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
6461          None => None,
6462        };
6463        self
6464    }
6465}
6466
6467
6468/// Updates a customer. This method supports patch semantics.
6469///
6470/// A builder for the *patch* method supported by a *customer* resource.
6471/// It is not used directly, but through a `CustomerMethods` instance.
6472///
6473/// # Example
6474///
6475/// Instantiate a resource method builder
6476///
6477/// ```test_harness,no_run
6478/// # extern crate hyper;
6479/// # extern crate hyper_rustls;
6480/// # extern crate yup_oauth2 as oauth2;
6481/// # extern crate google_admin1_directory as admin1_directory;
6482/// use admin1_directory::Customer;
6483/// # #[test] fn egal() {
6484/// # use std::default::Default;
6485/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
6486/// # use admin1_directory::Directory;
6487/// 
6488/// # let secret: ApplicationSecret = Default::default();
6489/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
6490/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
6491/// #                               <MemoryStorage as Default>::default(), None);
6492/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
6493/// // As the method needs a request, you would usually fill it with the desired information
6494/// // into the respective structure. Some of the parts shown here might not be applicable !
6495/// // Values shown here are possibly random and not representative !
6496/// let mut req = Customer::default();
6497/// 
6498/// // You can configure optional parameters by calling the respective setters at will, and
6499/// // execute the final call using `doit()`.
6500/// // Values shown here are possibly random and not representative !
6501/// let result = hub.customers().patch(req, "customerKey")
6502///              .doit();
6503/// # }
6504/// ```
6505pub struct CustomerPatchCall<'a, C, A>
6506    where C: 'a, A: 'a {
6507
6508    hub: &'a Directory<C, A>,
6509    _request: Customer,
6510    _customer_key: String,
6511    _delegate: Option<&'a mut dyn Delegate>,
6512    _additional_params: HashMap<String, String>,
6513    _scopes: BTreeMap<String, ()>
6514}
6515
6516impl<'a, C, A> CallBuilder for CustomerPatchCall<'a, C, A> {}
6517
6518impl<'a, C, A> CustomerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
6519
6520
6521    /// Perform the operation you have build so far.
6522    pub fn doit(mut self) -> Result<(hyper::client::Response, Customer)> {
6523        use std::io::{Read, Seek};
6524        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
6525        let mut dd = DefaultDelegate;
6526        let mut dlg: &mut dyn Delegate = match self._delegate {
6527            Some(d) => d,
6528            None => &mut dd
6529        };
6530        dlg.begin(MethodInfo { id: "directory.customers.patch",
6531                               http_method: hyper::method::Method::Patch });
6532        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
6533        params.push(("customerKey", self._customer_key.to_string()));
6534        for &field in ["alt", "customerKey"].iter() {
6535            if self._additional_params.contains_key(field) {
6536                dlg.finished(false);
6537                return Err(Error::FieldClash(field));
6538            }
6539        }
6540        for (name, value) in self._additional_params.iter() {
6541            params.push((&name, value.clone()));
6542        }
6543
6544        params.push(("alt", "json".to_string()));
6545
6546        let mut url = self.hub._base_url.clone() + "customers/{customerKey}";
6547        if self._scopes.len() == 0 {
6548            self._scopes.insert(Scope::DirectoryCustomer.as_ref().to_string(), ());
6549        }
6550
6551        for &(find_this, param_name) in [("{customerKey}", "customerKey")].iter() {
6552            let mut replace_with: Option<&str> = None;
6553            for &(name, ref value) in params.iter() {
6554                if name == param_name {
6555                    replace_with = Some(value);
6556                    break;
6557                }
6558            }
6559            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
6560        }
6561        {
6562            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
6563            for param_name in ["customerKey"].iter() {
6564                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
6565                    indices_for_removal.push(index);
6566                }
6567            }
6568            for &index in indices_for_removal.iter() {
6569                params.remove(index);
6570            }
6571        }
6572
6573        let url = hyper::Url::parse_with_params(&url, params).unwrap();
6574
6575        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
6576        let mut request_value_reader =
6577            {
6578                let mut value = json::value::to_value(&self._request).expect("serde to work");
6579                remove_json_null_values(&mut value);
6580                let mut dst = io::Cursor::new(Vec::with_capacity(128));
6581                json::to_writer(&mut dst, &value).unwrap();
6582                dst
6583            };
6584        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
6585        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
6586
6587
6588        loop {
6589            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
6590                Ok(token) => token,
6591                Err(err) => {
6592                    match  dlg.token(&*err) {
6593                        Some(token) => token,
6594                        None => {
6595                            dlg.finished(false);
6596                            return Err(Error::MissingToken(err))
6597                        }
6598                    }
6599                }
6600            };
6601            let auth_header = Authorization(Bearer { token: token.access_token });
6602            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
6603            let mut req_result = {
6604                let mut client = &mut *self.hub.client.borrow_mut();
6605                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
6606                    .header(UserAgent(self.hub._user_agent.clone()))
6607                    .header(auth_header.clone())
6608                    .header(ContentType(json_mime_type.clone()))
6609                    .header(ContentLength(request_size as u64))
6610                    .body(&mut request_value_reader);
6611
6612                dlg.pre_request();
6613                req.send()
6614            };
6615
6616            match req_result {
6617                Err(err) => {
6618                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
6619                        sleep(d);
6620                        continue;
6621                    }
6622                    dlg.finished(false);
6623                    return Err(Error::HttpError(err))
6624                }
6625                Ok(mut res) => {
6626                    if !res.status.is_success() {
6627                        let mut json_err = String::new();
6628                        res.read_to_string(&mut json_err).unwrap();
6629                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
6630                                                              json::from_str(&json_err).ok(),
6631                                                              json::from_str(&json_err).ok()) {
6632                            sleep(d);
6633                            continue;
6634                        }
6635                        dlg.finished(false);
6636                        return match json::from_str::<ErrorResponse>(&json_err){
6637                            Err(_) => Err(Error::Failure(res)),
6638                            Ok(serr) => Err(Error::BadRequest(serr))
6639                        }
6640                    }
6641                    let result_value = {
6642                        let mut json_response = String::new();
6643                        res.read_to_string(&mut json_response).unwrap();
6644                        match json::from_str(&json_response) {
6645                            Ok(decoded) => (res, decoded),
6646                            Err(err) => {
6647                                dlg.response_json_decode_error(&json_response, &err);
6648                                return Err(Error::JsonDecodeError(json_response, err));
6649                            }
6650                        }
6651                    };
6652
6653                    dlg.finished(true);
6654                    return Ok(result_value)
6655                }
6656            }
6657        }
6658    }
6659
6660
6661    ///
6662    /// Sets the *request* property to the given value.
6663    ///
6664    /// Even though the property as already been set when instantiating this call,
6665    /// we provide this method for API completeness.
6666    pub fn request(mut self, new_value: Customer) -> CustomerPatchCall<'a, C, A> {
6667        self._request = new_value;
6668        self
6669    }
6670    /// Id of the customer to be updated
6671    ///
6672    /// Sets the *customer key* path property to the given value.
6673    ///
6674    /// Even though the property as already been set when instantiating this call,
6675    /// we provide this method for API completeness.
6676    pub fn customer_key(mut self, new_value: &str) -> CustomerPatchCall<'a, C, A> {
6677        self._customer_key = new_value.to_string();
6678        self
6679    }
6680    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6681    /// while executing the actual API request.
6682    /// 
6683    /// It should be used to handle progress information, and to implement a certain level of resilience.
6684    ///
6685    /// Sets the *delegate* property to the given value.
6686    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> CustomerPatchCall<'a, C, A> {
6687        self._delegate = Some(new_value);
6688        self
6689    }
6690
6691    /// Set any additional parameter of the query string used in the request.
6692    /// It should be used to set parameters which are not yet available through their own
6693    /// setters.
6694    ///
6695    /// Please note that this method must not be used to set any of the known parameters
6696    /// which have their own setter method. If done anyway, the request will fail.
6697    ///
6698    /// # Additional Parameters
6699    ///
6700    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6701    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6702    /// * *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.
6703    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6704    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6705    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6706    /// * *alt* (query-string) - Data format for the response.
6707    pub fn param<T>(mut self, name: T, value: T) -> CustomerPatchCall<'a, C, A>
6708                                                        where T: AsRef<str> {
6709        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
6710        self
6711    }
6712
6713    /// Identifies the authorization scope for the method you are building.
6714    ///
6715    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
6716    /// `Scope::DirectoryCustomer`.
6717    ///
6718    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6719    /// tokens for more than one scope.
6720    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
6721    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
6722    /// function for details).
6723    ///
6724    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6725    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6726    /// sufficient, a read-write scope will do as well.
6727    pub fn add_scope<T, S>(mut self, scope: T) -> CustomerPatchCall<'a, C, A>
6728                                                        where T: Into<Option<S>>,
6729                                                              S: AsRef<str> {
6730        match scope.into() {
6731          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
6732          None => None,
6733        };
6734        self
6735    }
6736}
6737
6738
6739/// Retrieves a customer.
6740///
6741/// A builder for the *get* method supported by a *customer* resource.
6742/// It is not used directly, but through a `CustomerMethods` instance.
6743///
6744/// # Example
6745///
6746/// Instantiate a resource method builder
6747///
6748/// ```test_harness,no_run
6749/// # extern crate hyper;
6750/// # extern crate hyper_rustls;
6751/// # extern crate yup_oauth2 as oauth2;
6752/// # extern crate google_admin1_directory as admin1_directory;
6753/// # #[test] fn egal() {
6754/// # use std::default::Default;
6755/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
6756/// # use admin1_directory::Directory;
6757/// 
6758/// # let secret: ApplicationSecret = Default::default();
6759/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
6760/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
6761/// #                               <MemoryStorage as Default>::default(), None);
6762/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
6763/// // You can configure optional parameters by calling the respective setters at will, and
6764/// // execute the final call using `doit()`.
6765/// // Values shown here are possibly random and not representative !
6766/// let result = hub.customers().get("customerKey")
6767///              .doit();
6768/// # }
6769/// ```
6770pub struct CustomerGetCall<'a, C, A>
6771    where C: 'a, A: 'a {
6772
6773    hub: &'a Directory<C, A>,
6774    _customer_key: String,
6775    _delegate: Option<&'a mut dyn Delegate>,
6776    _additional_params: HashMap<String, String>,
6777    _scopes: BTreeMap<String, ()>
6778}
6779
6780impl<'a, C, A> CallBuilder for CustomerGetCall<'a, C, A> {}
6781
6782impl<'a, C, A> CustomerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
6783
6784
6785    /// Perform the operation you have build so far.
6786    pub fn doit(mut self) -> Result<(hyper::client::Response, Customer)> {
6787        use std::io::{Read, Seek};
6788        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
6789        let mut dd = DefaultDelegate;
6790        let mut dlg: &mut dyn Delegate = match self._delegate {
6791            Some(d) => d,
6792            None => &mut dd
6793        };
6794        dlg.begin(MethodInfo { id: "directory.customers.get",
6795                               http_method: hyper::method::Method::Get });
6796        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
6797        params.push(("customerKey", self._customer_key.to_string()));
6798        for &field in ["alt", "customerKey"].iter() {
6799            if self._additional_params.contains_key(field) {
6800                dlg.finished(false);
6801                return Err(Error::FieldClash(field));
6802            }
6803        }
6804        for (name, value) in self._additional_params.iter() {
6805            params.push((&name, value.clone()));
6806        }
6807
6808        params.push(("alt", "json".to_string()));
6809
6810        let mut url = self.hub._base_url.clone() + "customers/{customerKey}";
6811        if self._scopes.len() == 0 {
6812            self._scopes.insert(Scope::DirectoryCustomerReadonly.as_ref().to_string(), ());
6813        }
6814
6815        for &(find_this, param_name) in [("{customerKey}", "customerKey")].iter() {
6816            let mut replace_with: Option<&str> = None;
6817            for &(name, ref value) in params.iter() {
6818                if name == param_name {
6819                    replace_with = Some(value);
6820                    break;
6821                }
6822            }
6823            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
6824        }
6825        {
6826            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
6827            for param_name in ["customerKey"].iter() {
6828                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
6829                    indices_for_removal.push(index);
6830                }
6831            }
6832            for &index in indices_for_removal.iter() {
6833                params.remove(index);
6834            }
6835        }
6836
6837        let url = hyper::Url::parse_with_params(&url, params).unwrap();
6838
6839
6840
6841        loop {
6842            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
6843                Ok(token) => token,
6844                Err(err) => {
6845                    match  dlg.token(&*err) {
6846                        Some(token) => token,
6847                        None => {
6848                            dlg.finished(false);
6849                            return Err(Error::MissingToken(err))
6850                        }
6851                    }
6852                }
6853            };
6854            let auth_header = Authorization(Bearer { token: token.access_token });
6855            let mut req_result = {
6856                let mut client = &mut *self.hub.client.borrow_mut();
6857                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
6858                    .header(UserAgent(self.hub._user_agent.clone()))
6859                    .header(auth_header.clone());
6860
6861                dlg.pre_request();
6862                req.send()
6863            };
6864
6865            match req_result {
6866                Err(err) => {
6867                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
6868                        sleep(d);
6869                        continue;
6870                    }
6871                    dlg.finished(false);
6872                    return Err(Error::HttpError(err))
6873                }
6874                Ok(mut res) => {
6875                    if !res.status.is_success() {
6876                        let mut json_err = String::new();
6877                        res.read_to_string(&mut json_err).unwrap();
6878                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
6879                                                              json::from_str(&json_err).ok(),
6880                                                              json::from_str(&json_err).ok()) {
6881                            sleep(d);
6882                            continue;
6883                        }
6884                        dlg.finished(false);
6885                        return match json::from_str::<ErrorResponse>(&json_err){
6886                            Err(_) => Err(Error::Failure(res)),
6887                            Ok(serr) => Err(Error::BadRequest(serr))
6888                        }
6889                    }
6890                    let result_value = {
6891                        let mut json_response = String::new();
6892                        res.read_to_string(&mut json_response).unwrap();
6893                        match json::from_str(&json_response) {
6894                            Ok(decoded) => (res, decoded),
6895                            Err(err) => {
6896                                dlg.response_json_decode_error(&json_response, &err);
6897                                return Err(Error::JsonDecodeError(json_response, err));
6898                            }
6899                        }
6900                    };
6901
6902                    dlg.finished(true);
6903                    return Ok(result_value)
6904                }
6905            }
6906        }
6907    }
6908
6909
6910    /// Id of the customer to be retrieved
6911    ///
6912    /// Sets the *customer key* path property to the given value.
6913    ///
6914    /// Even though the property as already been set when instantiating this call,
6915    /// we provide this method for API completeness.
6916    pub fn customer_key(mut self, new_value: &str) -> CustomerGetCall<'a, C, A> {
6917        self._customer_key = new_value.to_string();
6918        self
6919    }
6920    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6921    /// while executing the actual API request.
6922    /// 
6923    /// It should be used to handle progress information, and to implement a certain level of resilience.
6924    ///
6925    /// Sets the *delegate* property to the given value.
6926    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> CustomerGetCall<'a, C, A> {
6927        self._delegate = Some(new_value);
6928        self
6929    }
6930
6931    /// Set any additional parameter of the query string used in the request.
6932    /// It should be used to set parameters which are not yet available through their own
6933    /// setters.
6934    ///
6935    /// Please note that this method must not be used to set any of the known parameters
6936    /// which have their own setter method. If done anyway, the request will fail.
6937    ///
6938    /// # Additional Parameters
6939    ///
6940    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6941    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6942    /// * *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.
6943    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6944    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6945    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6946    /// * *alt* (query-string) - Data format for the response.
6947    pub fn param<T>(mut self, name: T, value: T) -> CustomerGetCall<'a, C, A>
6948                                                        where T: AsRef<str> {
6949        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
6950        self
6951    }
6952
6953    /// Identifies the authorization scope for the method you are building.
6954    ///
6955    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
6956    /// `Scope::DirectoryCustomerReadonly`.
6957    ///
6958    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6959    /// tokens for more than one scope.
6960    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
6961    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
6962    /// function for details).
6963    ///
6964    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6965    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6966    /// sufficient, a read-write scope will do as well.
6967    pub fn add_scope<T, S>(mut self, scope: T) -> CustomerGetCall<'a, C, A>
6968                                                        where T: Into<Option<S>>,
6969                                                              S: AsRef<str> {
6970        match scope.into() {
6971          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
6972          None => None,
6973        };
6974        self
6975    }
6976}
6977
6978
6979/// Updates a customer.
6980///
6981/// A builder for the *update* method supported by a *customer* resource.
6982/// It is not used directly, but through a `CustomerMethods` instance.
6983///
6984/// # Example
6985///
6986/// Instantiate a resource method builder
6987///
6988/// ```test_harness,no_run
6989/// # extern crate hyper;
6990/// # extern crate hyper_rustls;
6991/// # extern crate yup_oauth2 as oauth2;
6992/// # extern crate google_admin1_directory as admin1_directory;
6993/// use admin1_directory::Customer;
6994/// # #[test] fn egal() {
6995/// # use std::default::Default;
6996/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
6997/// # use admin1_directory::Directory;
6998/// 
6999/// # let secret: ApplicationSecret = Default::default();
7000/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
7001/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
7002/// #                               <MemoryStorage as Default>::default(), None);
7003/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
7004/// // As the method needs a request, you would usually fill it with the desired information
7005/// // into the respective structure. Some of the parts shown here might not be applicable !
7006/// // Values shown here are possibly random and not representative !
7007/// let mut req = Customer::default();
7008/// 
7009/// // You can configure optional parameters by calling the respective setters at will, and
7010/// // execute the final call using `doit()`.
7011/// // Values shown here are possibly random and not representative !
7012/// let result = hub.customers().update(req, "customerKey")
7013///              .doit();
7014/// # }
7015/// ```
7016pub struct CustomerUpdateCall<'a, C, A>
7017    where C: 'a, A: 'a {
7018
7019    hub: &'a Directory<C, A>,
7020    _request: Customer,
7021    _customer_key: String,
7022    _delegate: Option<&'a mut dyn Delegate>,
7023    _additional_params: HashMap<String, String>,
7024    _scopes: BTreeMap<String, ()>
7025}
7026
7027impl<'a, C, A> CallBuilder for CustomerUpdateCall<'a, C, A> {}
7028
7029impl<'a, C, A> CustomerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
7030
7031
7032    /// Perform the operation you have build so far.
7033    pub fn doit(mut self) -> Result<(hyper::client::Response, Customer)> {
7034        use std::io::{Read, Seek};
7035        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
7036        let mut dd = DefaultDelegate;
7037        let mut dlg: &mut dyn Delegate = match self._delegate {
7038            Some(d) => d,
7039            None => &mut dd
7040        };
7041        dlg.begin(MethodInfo { id: "directory.customers.update",
7042                               http_method: hyper::method::Method::Put });
7043        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
7044        params.push(("customerKey", self._customer_key.to_string()));
7045        for &field in ["alt", "customerKey"].iter() {
7046            if self._additional_params.contains_key(field) {
7047                dlg.finished(false);
7048                return Err(Error::FieldClash(field));
7049            }
7050        }
7051        for (name, value) in self._additional_params.iter() {
7052            params.push((&name, value.clone()));
7053        }
7054
7055        params.push(("alt", "json".to_string()));
7056
7057        let mut url = self.hub._base_url.clone() + "customers/{customerKey}";
7058        if self._scopes.len() == 0 {
7059            self._scopes.insert(Scope::DirectoryCustomer.as_ref().to_string(), ());
7060        }
7061
7062        for &(find_this, param_name) in [("{customerKey}", "customerKey")].iter() {
7063            let mut replace_with: Option<&str> = None;
7064            for &(name, ref value) in params.iter() {
7065                if name == param_name {
7066                    replace_with = Some(value);
7067                    break;
7068                }
7069            }
7070            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
7071        }
7072        {
7073            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
7074            for param_name in ["customerKey"].iter() {
7075                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
7076                    indices_for_removal.push(index);
7077                }
7078            }
7079            for &index in indices_for_removal.iter() {
7080                params.remove(index);
7081            }
7082        }
7083
7084        let url = hyper::Url::parse_with_params(&url, params).unwrap();
7085
7086        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
7087        let mut request_value_reader =
7088            {
7089                let mut value = json::value::to_value(&self._request).expect("serde to work");
7090                remove_json_null_values(&mut value);
7091                let mut dst = io::Cursor::new(Vec::with_capacity(128));
7092                json::to_writer(&mut dst, &value).unwrap();
7093                dst
7094            };
7095        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
7096        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
7097
7098
7099        loop {
7100            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
7101                Ok(token) => token,
7102                Err(err) => {
7103                    match  dlg.token(&*err) {
7104                        Some(token) => token,
7105                        None => {
7106                            dlg.finished(false);
7107                            return Err(Error::MissingToken(err))
7108                        }
7109                    }
7110                }
7111            };
7112            let auth_header = Authorization(Bearer { token: token.access_token });
7113            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
7114            let mut req_result = {
7115                let mut client = &mut *self.hub.client.borrow_mut();
7116                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
7117                    .header(UserAgent(self.hub._user_agent.clone()))
7118                    .header(auth_header.clone())
7119                    .header(ContentType(json_mime_type.clone()))
7120                    .header(ContentLength(request_size as u64))
7121                    .body(&mut request_value_reader);
7122
7123                dlg.pre_request();
7124                req.send()
7125            };
7126
7127            match req_result {
7128                Err(err) => {
7129                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
7130                        sleep(d);
7131                        continue;
7132                    }
7133                    dlg.finished(false);
7134                    return Err(Error::HttpError(err))
7135                }
7136                Ok(mut res) => {
7137                    if !res.status.is_success() {
7138                        let mut json_err = String::new();
7139                        res.read_to_string(&mut json_err).unwrap();
7140                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
7141                                                              json::from_str(&json_err).ok(),
7142                                                              json::from_str(&json_err).ok()) {
7143                            sleep(d);
7144                            continue;
7145                        }
7146                        dlg.finished(false);
7147                        return match json::from_str::<ErrorResponse>(&json_err){
7148                            Err(_) => Err(Error::Failure(res)),
7149                            Ok(serr) => Err(Error::BadRequest(serr))
7150                        }
7151                    }
7152                    let result_value = {
7153                        let mut json_response = String::new();
7154                        res.read_to_string(&mut json_response).unwrap();
7155                        match json::from_str(&json_response) {
7156                            Ok(decoded) => (res, decoded),
7157                            Err(err) => {
7158                                dlg.response_json_decode_error(&json_response, &err);
7159                                return Err(Error::JsonDecodeError(json_response, err));
7160                            }
7161                        }
7162                    };
7163
7164                    dlg.finished(true);
7165                    return Ok(result_value)
7166                }
7167            }
7168        }
7169    }
7170
7171
7172    ///
7173    /// Sets the *request* property to the given value.
7174    ///
7175    /// Even though the property as already been set when instantiating this call,
7176    /// we provide this method for API completeness.
7177    pub fn request(mut self, new_value: Customer) -> CustomerUpdateCall<'a, C, A> {
7178        self._request = new_value;
7179        self
7180    }
7181    /// Id of the customer to be updated
7182    ///
7183    /// Sets the *customer key* path property to the given value.
7184    ///
7185    /// Even though the property as already been set when instantiating this call,
7186    /// we provide this method for API completeness.
7187    pub fn customer_key(mut self, new_value: &str) -> CustomerUpdateCall<'a, C, A> {
7188        self._customer_key = new_value.to_string();
7189        self
7190    }
7191    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7192    /// while executing the actual API request.
7193    /// 
7194    /// It should be used to handle progress information, and to implement a certain level of resilience.
7195    ///
7196    /// Sets the *delegate* property to the given value.
7197    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> CustomerUpdateCall<'a, C, A> {
7198        self._delegate = Some(new_value);
7199        self
7200    }
7201
7202    /// Set any additional parameter of the query string used in the request.
7203    /// It should be used to set parameters which are not yet available through their own
7204    /// setters.
7205    ///
7206    /// Please note that this method must not be used to set any of the known parameters
7207    /// which have their own setter method. If done anyway, the request will fail.
7208    ///
7209    /// # Additional Parameters
7210    ///
7211    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7212    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7213    /// * *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.
7214    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7215    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7216    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7217    /// * *alt* (query-string) - Data format for the response.
7218    pub fn param<T>(mut self, name: T, value: T) -> CustomerUpdateCall<'a, C, A>
7219                                                        where T: AsRef<str> {
7220        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
7221        self
7222    }
7223
7224    /// Identifies the authorization scope for the method you are building.
7225    ///
7226    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
7227    /// `Scope::DirectoryCustomer`.
7228    ///
7229    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7230    /// tokens for more than one scope.
7231    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
7232    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
7233    /// function for details).
7234    ///
7235    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7236    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7237    /// sufficient, a read-write scope will do as well.
7238    pub fn add_scope<T, S>(mut self, scope: T) -> CustomerUpdateCall<'a, C, A>
7239                                                        where T: Into<Option<S>>,
7240                                                              S: AsRef<str> {
7241        match scope.into() {
7242          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
7243          None => None,
7244        };
7245        self
7246    }
7247}
7248
7249
7250/// Retrieve all organizational units
7251///
7252/// A builder for the *list* method supported by a *orgunit* resource.
7253/// It is not used directly, but through a `OrgunitMethods` instance.
7254///
7255/// # Example
7256///
7257/// Instantiate a resource method builder
7258///
7259/// ```test_harness,no_run
7260/// # extern crate hyper;
7261/// # extern crate hyper_rustls;
7262/// # extern crate yup_oauth2 as oauth2;
7263/// # extern crate google_admin1_directory as admin1_directory;
7264/// # #[test] fn egal() {
7265/// # use std::default::Default;
7266/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
7267/// # use admin1_directory::Directory;
7268/// 
7269/// # let secret: ApplicationSecret = Default::default();
7270/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
7271/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
7272/// #                               <MemoryStorage as Default>::default(), None);
7273/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
7274/// // You can configure optional parameters by calling the respective setters at will, and
7275/// // execute the final call using `doit()`.
7276/// // Values shown here are possibly random and not representative !
7277/// let result = hub.orgunits().list("customerId")
7278///              .type_("dolore")
7279///              .org_unit_path("invidunt")
7280///              .doit();
7281/// # }
7282/// ```
7283pub struct OrgunitListCall<'a, C, A>
7284    where C: 'a, A: 'a {
7285
7286    hub: &'a Directory<C, A>,
7287    _customer_id: String,
7288    _type_: Option<String>,
7289    _org_unit_path: Option<String>,
7290    _delegate: Option<&'a mut dyn Delegate>,
7291    _additional_params: HashMap<String, String>,
7292    _scopes: BTreeMap<String, ()>
7293}
7294
7295impl<'a, C, A> CallBuilder for OrgunitListCall<'a, C, A> {}
7296
7297impl<'a, C, A> OrgunitListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
7298
7299
7300    /// Perform the operation you have build so far.
7301    pub fn doit(mut self) -> Result<(hyper::client::Response, OrgUnits)> {
7302        use std::io::{Read, Seek};
7303        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
7304        let mut dd = DefaultDelegate;
7305        let mut dlg: &mut dyn Delegate = match self._delegate {
7306            Some(d) => d,
7307            None => &mut dd
7308        };
7309        dlg.begin(MethodInfo { id: "directory.orgunits.list",
7310                               http_method: hyper::method::Method::Get });
7311        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
7312        params.push(("customerId", self._customer_id.to_string()));
7313        if let Some(value) = self._type_ {
7314            params.push(("type", value.to_string()));
7315        }
7316        if let Some(value) = self._org_unit_path {
7317            params.push(("orgUnitPath", value.to_string()));
7318        }
7319        for &field in ["alt", "customerId", "type", "orgUnitPath"].iter() {
7320            if self._additional_params.contains_key(field) {
7321                dlg.finished(false);
7322                return Err(Error::FieldClash(field));
7323            }
7324        }
7325        for (name, value) in self._additional_params.iter() {
7326            params.push((&name, value.clone()));
7327        }
7328
7329        params.push(("alt", "json".to_string()));
7330
7331        let mut url = self.hub._base_url.clone() + "customer/{customerId}/orgunits";
7332        if self._scopes.len() == 0 {
7333            self._scopes.insert(Scope::DirectoryOrgunitReadonly.as_ref().to_string(), ());
7334        }
7335
7336        for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
7337            let mut replace_with: Option<&str> = None;
7338            for &(name, ref value) in params.iter() {
7339                if name == param_name {
7340                    replace_with = Some(value);
7341                    break;
7342                }
7343            }
7344            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
7345        }
7346        {
7347            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
7348            for param_name in ["customerId"].iter() {
7349                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
7350                    indices_for_removal.push(index);
7351                }
7352            }
7353            for &index in indices_for_removal.iter() {
7354                params.remove(index);
7355            }
7356        }
7357
7358        let url = hyper::Url::parse_with_params(&url, params).unwrap();
7359
7360
7361
7362        loop {
7363            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
7364                Ok(token) => token,
7365                Err(err) => {
7366                    match  dlg.token(&*err) {
7367                        Some(token) => token,
7368                        None => {
7369                            dlg.finished(false);
7370                            return Err(Error::MissingToken(err))
7371                        }
7372                    }
7373                }
7374            };
7375            let auth_header = Authorization(Bearer { token: token.access_token });
7376            let mut req_result = {
7377                let mut client = &mut *self.hub.client.borrow_mut();
7378                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
7379                    .header(UserAgent(self.hub._user_agent.clone()))
7380                    .header(auth_header.clone());
7381
7382                dlg.pre_request();
7383                req.send()
7384            };
7385
7386            match req_result {
7387                Err(err) => {
7388                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
7389                        sleep(d);
7390                        continue;
7391                    }
7392                    dlg.finished(false);
7393                    return Err(Error::HttpError(err))
7394                }
7395                Ok(mut res) => {
7396                    if !res.status.is_success() {
7397                        let mut json_err = String::new();
7398                        res.read_to_string(&mut json_err).unwrap();
7399                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
7400                                                              json::from_str(&json_err).ok(),
7401                                                              json::from_str(&json_err).ok()) {
7402                            sleep(d);
7403                            continue;
7404                        }
7405                        dlg.finished(false);
7406                        return match json::from_str::<ErrorResponse>(&json_err){
7407                            Err(_) => Err(Error::Failure(res)),
7408                            Ok(serr) => Err(Error::BadRequest(serr))
7409                        }
7410                    }
7411                    let result_value = {
7412                        let mut json_response = String::new();
7413                        res.read_to_string(&mut json_response).unwrap();
7414                        match json::from_str(&json_response) {
7415                            Ok(decoded) => (res, decoded),
7416                            Err(err) => {
7417                                dlg.response_json_decode_error(&json_response, &err);
7418                                return Err(Error::JsonDecodeError(json_response, err));
7419                            }
7420                        }
7421                    };
7422
7423                    dlg.finished(true);
7424                    return Ok(result_value)
7425                }
7426            }
7427        }
7428    }
7429
7430
7431    /// Immutable ID of the G Suite account
7432    ///
7433    /// Sets the *customer id* path property to the given value.
7434    ///
7435    /// Even though the property as already been set when instantiating this call,
7436    /// we provide this method for API completeness.
7437    pub fn customer_id(mut self, new_value: &str) -> OrgunitListCall<'a, C, A> {
7438        self._customer_id = new_value.to_string();
7439        self
7440    }
7441    /// Whether to return all sub-organizations or just immediate children
7442    ///
7443    /// Sets the *type* query property to the given value.
7444    pub fn type_(mut self, new_value: &str) -> OrgunitListCall<'a, C, A> {
7445        self._type_ = Some(new_value.to_string());
7446        self
7447    }
7448    /// the URL-encoded organizational unit's path or its ID
7449    ///
7450    /// Sets the *org unit path* query property to the given value.
7451    pub fn org_unit_path(mut self, new_value: &str) -> OrgunitListCall<'a, C, A> {
7452        self._org_unit_path = Some(new_value.to_string());
7453        self
7454    }
7455    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7456    /// while executing the actual API request.
7457    /// 
7458    /// It should be used to handle progress information, and to implement a certain level of resilience.
7459    ///
7460    /// Sets the *delegate* property to the given value.
7461    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OrgunitListCall<'a, C, A> {
7462        self._delegate = Some(new_value);
7463        self
7464    }
7465
7466    /// Set any additional parameter of the query string used in the request.
7467    /// It should be used to set parameters which are not yet available through their own
7468    /// setters.
7469    ///
7470    /// Please note that this method must not be used to set any of the known parameters
7471    /// which have their own setter method. If done anyway, the request will fail.
7472    ///
7473    /// # Additional Parameters
7474    ///
7475    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7476    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7477    /// * *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.
7478    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7479    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7480    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7481    /// * *alt* (query-string) - Data format for the response.
7482    pub fn param<T>(mut self, name: T, value: T) -> OrgunitListCall<'a, C, A>
7483                                                        where T: AsRef<str> {
7484        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
7485        self
7486    }
7487
7488    /// Identifies the authorization scope for the method you are building.
7489    ///
7490    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
7491    /// `Scope::DirectoryOrgunitReadonly`.
7492    ///
7493    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7494    /// tokens for more than one scope.
7495    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
7496    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
7497    /// function for details).
7498    ///
7499    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7500    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7501    /// sufficient, a read-write scope will do as well.
7502    pub fn add_scope<T, S>(mut self, scope: T) -> OrgunitListCall<'a, C, A>
7503                                                        where T: Into<Option<S>>,
7504                                                              S: AsRef<str> {
7505        match scope.into() {
7506          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
7507          None => None,
7508        };
7509        self
7510    }
7511}
7512
7513
7514/// Add organizational unit
7515///
7516/// A builder for the *insert* method supported by a *orgunit* resource.
7517/// It is not used directly, but through a `OrgunitMethods` instance.
7518///
7519/// # Example
7520///
7521/// Instantiate a resource method builder
7522///
7523/// ```test_harness,no_run
7524/// # extern crate hyper;
7525/// # extern crate hyper_rustls;
7526/// # extern crate yup_oauth2 as oauth2;
7527/// # extern crate google_admin1_directory as admin1_directory;
7528/// use admin1_directory::OrgUnit;
7529/// # #[test] fn egal() {
7530/// # use std::default::Default;
7531/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
7532/// # use admin1_directory::Directory;
7533/// 
7534/// # let secret: ApplicationSecret = Default::default();
7535/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
7536/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
7537/// #                               <MemoryStorage as Default>::default(), None);
7538/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
7539/// // As the method needs a request, you would usually fill it with the desired information
7540/// // into the respective structure. Some of the parts shown here might not be applicable !
7541/// // Values shown here are possibly random and not representative !
7542/// let mut req = OrgUnit::default();
7543/// 
7544/// // You can configure optional parameters by calling the respective setters at will, and
7545/// // execute the final call using `doit()`.
7546/// // Values shown here are possibly random and not representative !
7547/// let result = hub.orgunits().insert(req, "customerId")
7548///              .doit();
7549/// # }
7550/// ```
7551pub struct OrgunitInsertCall<'a, C, A>
7552    where C: 'a, A: 'a {
7553
7554    hub: &'a Directory<C, A>,
7555    _request: OrgUnit,
7556    _customer_id: String,
7557    _delegate: Option<&'a mut dyn Delegate>,
7558    _additional_params: HashMap<String, String>,
7559    _scopes: BTreeMap<String, ()>
7560}
7561
7562impl<'a, C, A> CallBuilder for OrgunitInsertCall<'a, C, A> {}
7563
7564impl<'a, C, A> OrgunitInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
7565
7566
7567    /// Perform the operation you have build so far.
7568    pub fn doit(mut self) -> Result<(hyper::client::Response, OrgUnit)> {
7569        use std::io::{Read, Seek};
7570        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
7571        let mut dd = DefaultDelegate;
7572        let mut dlg: &mut dyn Delegate = match self._delegate {
7573            Some(d) => d,
7574            None => &mut dd
7575        };
7576        dlg.begin(MethodInfo { id: "directory.orgunits.insert",
7577                               http_method: hyper::method::Method::Post });
7578        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
7579        params.push(("customerId", self._customer_id.to_string()));
7580        for &field in ["alt", "customerId"].iter() {
7581            if self._additional_params.contains_key(field) {
7582                dlg.finished(false);
7583                return Err(Error::FieldClash(field));
7584            }
7585        }
7586        for (name, value) in self._additional_params.iter() {
7587            params.push((&name, value.clone()));
7588        }
7589
7590        params.push(("alt", "json".to_string()));
7591
7592        let mut url = self.hub._base_url.clone() + "customer/{customerId}/orgunits";
7593        if self._scopes.len() == 0 {
7594            self._scopes.insert(Scope::DirectoryOrgunit.as_ref().to_string(), ());
7595        }
7596
7597        for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
7598            let mut replace_with: Option<&str> = None;
7599            for &(name, ref value) in params.iter() {
7600                if name == param_name {
7601                    replace_with = Some(value);
7602                    break;
7603                }
7604            }
7605            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
7606        }
7607        {
7608            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
7609            for param_name in ["customerId"].iter() {
7610                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
7611                    indices_for_removal.push(index);
7612                }
7613            }
7614            for &index in indices_for_removal.iter() {
7615                params.remove(index);
7616            }
7617        }
7618
7619        let url = hyper::Url::parse_with_params(&url, params).unwrap();
7620
7621        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
7622        let mut request_value_reader =
7623            {
7624                let mut value = json::value::to_value(&self._request).expect("serde to work");
7625                remove_json_null_values(&mut value);
7626                let mut dst = io::Cursor::new(Vec::with_capacity(128));
7627                json::to_writer(&mut dst, &value).unwrap();
7628                dst
7629            };
7630        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
7631        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
7632
7633
7634        loop {
7635            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
7636                Ok(token) => token,
7637                Err(err) => {
7638                    match  dlg.token(&*err) {
7639                        Some(token) => token,
7640                        None => {
7641                            dlg.finished(false);
7642                            return Err(Error::MissingToken(err))
7643                        }
7644                    }
7645                }
7646            };
7647            let auth_header = Authorization(Bearer { token: token.access_token });
7648            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
7649            let mut req_result = {
7650                let mut client = &mut *self.hub.client.borrow_mut();
7651                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
7652                    .header(UserAgent(self.hub._user_agent.clone()))
7653                    .header(auth_header.clone())
7654                    .header(ContentType(json_mime_type.clone()))
7655                    .header(ContentLength(request_size as u64))
7656                    .body(&mut request_value_reader);
7657
7658                dlg.pre_request();
7659                req.send()
7660            };
7661
7662            match req_result {
7663                Err(err) => {
7664                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
7665                        sleep(d);
7666                        continue;
7667                    }
7668                    dlg.finished(false);
7669                    return Err(Error::HttpError(err))
7670                }
7671                Ok(mut res) => {
7672                    if !res.status.is_success() {
7673                        let mut json_err = String::new();
7674                        res.read_to_string(&mut json_err).unwrap();
7675                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
7676                                                              json::from_str(&json_err).ok(),
7677                                                              json::from_str(&json_err).ok()) {
7678                            sleep(d);
7679                            continue;
7680                        }
7681                        dlg.finished(false);
7682                        return match json::from_str::<ErrorResponse>(&json_err){
7683                            Err(_) => Err(Error::Failure(res)),
7684                            Ok(serr) => Err(Error::BadRequest(serr))
7685                        }
7686                    }
7687                    let result_value = {
7688                        let mut json_response = String::new();
7689                        res.read_to_string(&mut json_response).unwrap();
7690                        match json::from_str(&json_response) {
7691                            Ok(decoded) => (res, decoded),
7692                            Err(err) => {
7693                                dlg.response_json_decode_error(&json_response, &err);
7694                                return Err(Error::JsonDecodeError(json_response, err));
7695                            }
7696                        }
7697                    };
7698
7699                    dlg.finished(true);
7700                    return Ok(result_value)
7701                }
7702            }
7703        }
7704    }
7705
7706
7707    ///
7708    /// Sets the *request* property to the given value.
7709    ///
7710    /// Even though the property as already been set when instantiating this call,
7711    /// we provide this method for API completeness.
7712    pub fn request(mut self, new_value: OrgUnit) -> OrgunitInsertCall<'a, C, A> {
7713        self._request = new_value;
7714        self
7715    }
7716    /// Immutable ID of the G Suite account
7717    ///
7718    /// Sets the *customer id* path property to the given value.
7719    ///
7720    /// Even though the property as already been set when instantiating this call,
7721    /// we provide this method for API completeness.
7722    pub fn customer_id(mut self, new_value: &str) -> OrgunitInsertCall<'a, C, A> {
7723        self._customer_id = new_value.to_string();
7724        self
7725    }
7726    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7727    /// while executing the actual API request.
7728    /// 
7729    /// It should be used to handle progress information, and to implement a certain level of resilience.
7730    ///
7731    /// Sets the *delegate* property to the given value.
7732    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OrgunitInsertCall<'a, C, A> {
7733        self._delegate = Some(new_value);
7734        self
7735    }
7736
7737    /// Set any additional parameter of the query string used in the request.
7738    /// It should be used to set parameters which are not yet available through their own
7739    /// setters.
7740    ///
7741    /// Please note that this method must not be used to set any of the known parameters
7742    /// which have their own setter method. If done anyway, the request will fail.
7743    ///
7744    /// # Additional Parameters
7745    ///
7746    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7747    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7748    /// * *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.
7749    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7750    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7751    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7752    /// * *alt* (query-string) - Data format for the response.
7753    pub fn param<T>(mut self, name: T, value: T) -> OrgunitInsertCall<'a, C, A>
7754                                                        where T: AsRef<str> {
7755        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
7756        self
7757    }
7758
7759    /// Identifies the authorization scope for the method you are building.
7760    ///
7761    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
7762    /// `Scope::DirectoryOrgunit`.
7763    ///
7764    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7765    /// tokens for more than one scope.
7766    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
7767    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
7768    /// function for details).
7769    ///
7770    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7771    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7772    /// sufficient, a read-write scope will do as well.
7773    pub fn add_scope<T, S>(mut self, scope: T) -> OrgunitInsertCall<'a, C, A>
7774                                                        where T: Into<Option<S>>,
7775                                                              S: AsRef<str> {
7776        match scope.into() {
7777          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
7778          None => None,
7779        };
7780        self
7781    }
7782}
7783
7784
7785/// Update organizational unit
7786///
7787/// A builder for the *update* method supported by a *orgunit* resource.
7788/// It is not used directly, but through a `OrgunitMethods` instance.
7789///
7790/// # Example
7791///
7792/// Instantiate a resource method builder
7793///
7794/// ```test_harness,no_run
7795/// # extern crate hyper;
7796/// # extern crate hyper_rustls;
7797/// # extern crate yup_oauth2 as oauth2;
7798/// # extern crate google_admin1_directory as admin1_directory;
7799/// use admin1_directory::OrgUnit;
7800/// # #[test] fn egal() {
7801/// # use std::default::Default;
7802/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
7803/// # use admin1_directory::Directory;
7804/// 
7805/// # let secret: ApplicationSecret = Default::default();
7806/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
7807/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
7808/// #                               <MemoryStorage as Default>::default(), None);
7809/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
7810/// // As the method needs a request, you would usually fill it with the desired information
7811/// // into the respective structure. Some of the parts shown here might not be applicable !
7812/// // Values shown here are possibly random and not representative !
7813/// let mut req = OrgUnit::default();
7814/// 
7815/// // You can configure optional parameters by calling the respective setters at will, and
7816/// // execute the final call using `doit()`.
7817/// // Values shown here are possibly random and not representative !
7818/// let result = hub.orgunits().update(req, "customerId", "orgUnitPath")
7819///              .doit();
7820/// # }
7821/// ```
7822pub struct OrgunitUpdateCall<'a, C, A>
7823    where C: 'a, A: 'a {
7824
7825    hub: &'a Directory<C, A>,
7826    _request: OrgUnit,
7827    _customer_id: String,
7828    _org_unit_path: Vec<String>,
7829    _delegate: Option<&'a mut dyn Delegate>,
7830    _additional_params: HashMap<String, String>,
7831    _scopes: BTreeMap<String, ()>
7832}
7833
7834impl<'a, C, A> CallBuilder for OrgunitUpdateCall<'a, C, A> {}
7835
7836impl<'a, C, A> OrgunitUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
7837
7838
7839    /// Perform the operation you have build so far.
7840    pub fn doit(mut self) -> Result<(hyper::client::Response, OrgUnit)> {
7841        use std::io::{Read, Seek};
7842        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
7843        let mut dd = DefaultDelegate;
7844        let mut dlg: &mut dyn Delegate = match self._delegate {
7845            Some(d) => d,
7846            None => &mut dd
7847        };
7848        dlg.begin(MethodInfo { id: "directory.orgunits.update",
7849                               http_method: hyper::method::Method::Put });
7850        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
7851        params.push(("customerId", self._customer_id.to_string()));
7852        if self._org_unit_path.len() > 0 {
7853            for f in self._org_unit_path.iter() {
7854                params.push(("orgUnitPath", f.to_string()));
7855            }
7856        }
7857        for &field in ["alt", "customerId", "orgUnitPath"].iter() {
7858            if self._additional_params.contains_key(field) {
7859                dlg.finished(false);
7860                return Err(Error::FieldClash(field));
7861            }
7862        }
7863        for (name, value) in self._additional_params.iter() {
7864            params.push((&name, value.clone()));
7865        }
7866
7867        params.push(("alt", "json".to_string()));
7868
7869        let mut url = self.hub._base_url.clone() + "customer/{customerId}/orgunits{/orgUnitPath*}";
7870        if self._scopes.len() == 0 {
7871            self._scopes.insert(Scope::DirectoryOrgunit.as_ref().to_string(), ());
7872        }
7873
7874        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
7875            let mut replace_with: Option<&str> = None;
7876            for &(name, ref value) in params.iter() {
7877                if name == param_name {
7878                    replace_with = Some(value);
7879                    break;
7880                }
7881            }
7882            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
7883        }
7884        {
7885            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
7886            for param_name in ["orgUnitPath", "customerId"].iter() {
7887                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
7888                    indices_for_removal.push(index);
7889                }
7890            }
7891            for &index in indices_for_removal.iter() {
7892                params.remove(index);
7893            }
7894        }
7895
7896        let url = hyper::Url::parse_with_params(&url, params).unwrap();
7897
7898        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
7899        let mut request_value_reader =
7900            {
7901                let mut value = json::value::to_value(&self._request).expect("serde to work");
7902                remove_json_null_values(&mut value);
7903                let mut dst = io::Cursor::new(Vec::with_capacity(128));
7904                json::to_writer(&mut dst, &value).unwrap();
7905                dst
7906            };
7907        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
7908        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
7909
7910
7911        loop {
7912            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
7913                Ok(token) => token,
7914                Err(err) => {
7915                    match  dlg.token(&*err) {
7916                        Some(token) => token,
7917                        None => {
7918                            dlg.finished(false);
7919                            return Err(Error::MissingToken(err))
7920                        }
7921                    }
7922                }
7923            };
7924            let auth_header = Authorization(Bearer { token: token.access_token });
7925            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
7926            let mut req_result = {
7927                let mut client = &mut *self.hub.client.borrow_mut();
7928                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
7929                    .header(UserAgent(self.hub._user_agent.clone()))
7930                    .header(auth_header.clone())
7931                    .header(ContentType(json_mime_type.clone()))
7932                    .header(ContentLength(request_size as u64))
7933                    .body(&mut request_value_reader);
7934
7935                dlg.pre_request();
7936                req.send()
7937            };
7938
7939            match req_result {
7940                Err(err) => {
7941                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
7942                        sleep(d);
7943                        continue;
7944                    }
7945                    dlg.finished(false);
7946                    return Err(Error::HttpError(err))
7947                }
7948                Ok(mut res) => {
7949                    if !res.status.is_success() {
7950                        let mut json_err = String::new();
7951                        res.read_to_string(&mut json_err).unwrap();
7952                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
7953                                                              json::from_str(&json_err).ok(),
7954                                                              json::from_str(&json_err).ok()) {
7955                            sleep(d);
7956                            continue;
7957                        }
7958                        dlg.finished(false);
7959                        return match json::from_str::<ErrorResponse>(&json_err){
7960                            Err(_) => Err(Error::Failure(res)),
7961                            Ok(serr) => Err(Error::BadRequest(serr))
7962                        }
7963                    }
7964                    let result_value = {
7965                        let mut json_response = String::new();
7966                        res.read_to_string(&mut json_response).unwrap();
7967                        match json::from_str(&json_response) {
7968                            Ok(decoded) => (res, decoded),
7969                            Err(err) => {
7970                                dlg.response_json_decode_error(&json_response, &err);
7971                                return Err(Error::JsonDecodeError(json_response, err));
7972                            }
7973                        }
7974                    };
7975
7976                    dlg.finished(true);
7977                    return Ok(result_value)
7978                }
7979            }
7980        }
7981    }
7982
7983
7984    ///
7985    /// Sets the *request* property to the given value.
7986    ///
7987    /// Even though the property as already been set when instantiating this call,
7988    /// we provide this method for API completeness.
7989    pub fn request(mut self, new_value: OrgUnit) -> OrgunitUpdateCall<'a, C, A> {
7990        self._request = new_value;
7991        self
7992    }
7993    /// Immutable ID of the G Suite account
7994    ///
7995    /// Sets the *customer id* path property to the given value.
7996    ///
7997    /// Even though the property as already been set when instantiating this call,
7998    /// we provide this method for API completeness.
7999    pub fn customer_id(mut self, new_value: &str) -> OrgunitUpdateCall<'a, C, A> {
8000        self._customer_id = new_value.to_string();
8001        self
8002    }
8003    /// Full path of the organizational unit or its ID
8004    ///
8005    /// Append the given value to the *org unit path* path property.
8006    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8007    ///
8008    /// Even though the property as already been set when instantiating this call,
8009    /// we provide this method for API completeness.
8010    pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitUpdateCall<'a, C, A> {
8011        self._org_unit_path.push(new_value.to_string());
8012        self
8013    }
8014    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8015    /// while executing the actual API request.
8016    /// 
8017    /// It should be used to handle progress information, and to implement a certain level of resilience.
8018    ///
8019    /// Sets the *delegate* property to the given value.
8020    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OrgunitUpdateCall<'a, C, A> {
8021        self._delegate = Some(new_value);
8022        self
8023    }
8024
8025    /// Set any additional parameter of the query string used in the request.
8026    /// It should be used to set parameters which are not yet available through their own
8027    /// setters.
8028    ///
8029    /// Please note that this method must not be used to set any of the known parameters
8030    /// which have their own setter method. If done anyway, the request will fail.
8031    ///
8032    /// # Additional Parameters
8033    ///
8034    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8035    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8036    /// * *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.
8037    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8038    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8039    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8040    /// * *alt* (query-string) - Data format for the response.
8041    pub fn param<T>(mut self, name: T, value: T) -> OrgunitUpdateCall<'a, C, A>
8042                                                        where T: AsRef<str> {
8043        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
8044        self
8045    }
8046
8047    /// Identifies the authorization scope for the method you are building.
8048    ///
8049    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
8050    /// `Scope::DirectoryOrgunit`.
8051    ///
8052    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8053    /// tokens for more than one scope.
8054    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
8055    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
8056    /// function for details).
8057    ///
8058    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8059    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8060    /// sufficient, a read-write scope will do as well.
8061    pub fn add_scope<T, S>(mut self, scope: T) -> OrgunitUpdateCall<'a, C, A>
8062                                                        where T: Into<Option<S>>,
8063                                                              S: AsRef<str> {
8064        match scope.into() {
8065          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
8066          None => None,
8067        };
8068        self
8069    }
8070}
8071
8072
8073/// Retrieve organizational unit
8074///
8075/// A builder for the *get* method supported by a *orgunit* resource.
8076/// It is not used directly, but through a `OrgunitMethods` instance.
8077///
8078/// # Example
8079///
8080/// Instantiate a resource method builder
8081///
8082/// ```test_harness,no_run
8083/// # extern crate hyper;
8084/// # extern crate hyper_rustls;
8085/// # extern crate yup_oauth2 as oauth2;
8086/// # extern crate google_admin1_directory as admin1_directory;
8087/// # #[test] fn egal() {
8088/// # use std::default::Default;
8089/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
8090/// # use admin1_directory::Directory;
8091/// 
8092/// # let secret: ApplicationSecret = Default::default();
8093/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
8094/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
8095/// #                               <MemoryStorage as Default>::default(), None);
8096/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
8097/// // You can configure optional parameters by calling the respective setters at will, and
8098/// // execute the final call using `doit()`.
8099/// // Values shown here are possibly random and not representative !
8100/// let result = hub.orgunits().get("customerId", "orgUnitPath")
8101///              .doit();
8102/// # }
8103/// ```
8104pub struct OrgunitGetCall<'a, C, A>
8105    where C: 'a, A: 'a {
8106
8107    hub: &'a Directory<C, A>,
8108    _customer_id: String,
8109    _org_unit_path: Vec<String>,
8110    _delegate: Option<&'a mut dyn Delegate>,
8111    _additional_params: HashMap<String, String>,
8112    _scopes: BTreeMap<String, ()>
8113}
8114
8115impl<'a, C, A> CallBuilder for OrgunitGetCall<'a, C, A> {}
8116
8117impl<'a, C, A> OrgunitGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
8118
8119
8120    /// Perform the operation you have build so far.
8121    pub fn doit(mut self) -> Result<(hyper::client::Response, OrgUnit)> {
8122        use std::io::{Read, Seek};
8123        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
8124        let mut dd = DefaultDelegate;
8125        let mut dlg: &mut dyn Delegate = match self._delegate {
8126            Some(d) => d,
8127            None => &mut dd
8128        };
8129        dlg.begin(MethodInfo { id: "directory.orgunits.get",
8130                               http_method: hyper::method::Method::Get });
8131        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
8132        params.push(("customerId", self._customer_id.to_string()));
8133        if self._org_unit_path.len() > 0 {
8134            for f in self._org_unit_path.iter() {
8135                params.push(("orgUnitPath", f.to_string()));
8136            }
8137        }
8138        for &field in ["alt", "customerId", "orgUnitPath"].iter() {
8139            if self._additional_params.contains_key(field) {
8140                dlg.finished(false);
8141                return Err(Error::FieldClash(field));
8142            }
8143        }
8144        for (name, value) in self._additional_params.iter() {
8145            params.push((&name, value.clone()));
8146        }
8147
8148        params.push(("alt", "json".to_string()));
8149
8150        let mut url = self.hub._base_url.clone() + "customer/{customerId}/orgunits{/orgUnitPath*}";
8151        if self._scopes.len() == 0 {
8152            self._scopes.insert(Scope::DirectoryOrgunitReadonly.as_ref().to_string(), ());
8153        }
8154
8155        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
8156            let mut replace_with: Option<&str> = None;
8157            for &(name, ref value) in params.iter() {
8158                if name == param_name {
8159                    replace_with = Some(value);
8160                    break;
8161                }
8162            }
8163            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
8164        }
8165        {
8166            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
8167            for param_name in ["orgUnitPath", "customerId"].iter() {
8168                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
8169                    indices_for_removal.push(index);
8170                }
8171            }
8172            for &index in indices_for_removal.iter() {
8173                params.remove(index);
8174            }
8175        }
8176
8177        let url = hyper::Url::parse_with_params(&url, params).unwrap();
8178
8179
8180
8181        loop {
8182            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
8183                Ok(token) => token,
8184                Err(err) => {
8185                    match  dlg.token(&*err) {
8186                        Some(token) => token,
8187                        None => {
8188                            dlg.finished(false);
8189                            return Err(Error::MissingToken(err))
8190                        }
8191                    }
8192                }
8193            };
8194            let auth_header = Authorization(Bearer { token: token.access_token });
8195            let mut req_result = {
8196                let mut client = &mut *self.hub.client.borrow_mut();
8197                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
8198                    .header(UserAgent(self.hub._user_agent.clone()))
8199                    .header(auth_header.clone());
8200
8201                dlg.pre_request();
8202                req.send()
8203            };
8204
8205            match req_result {
8206                Err(err) => {
8207                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
8208                        sleep(d);
8209                        continue;
8210                    }
8211                    dlg.finished(false);
8212                    return Err(Error::HttpError(err))
8213                }
8214                Ok(mut res) => {
8215                    if !res.status.is_success() {
8216                        let mut json_err = String::new();
8217                        res.read_to_string(&mut json_err).unwrap();
8218                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
8219                                                              json::from_str(&json_err).ok(),
8220                                                              json::from_str(&json_err).ok()) {
8221                            sleep(d);
8222                            continue;
8223                        }
8224                        dlg.finished(false);
8225                        return match json::from_str::<ErrorResponse>(&json_err){
8226                            Err(_) => Err(Error::Failure(res)),
8227                            Ok(serr) => Err(Error::BadRequest(serr))
8228                        }
8229                    }
8230                    let result_value = {
8231                        let mut json_response = String::new();
8232                        res.read_to_string(&mut json_response).unwrap();
8233                        match json::from_str(&json_response) {
8234                            Ok(decoded) => (res, decoded),
8235                            Err(err) => {
8236                                dlg.response_json_decode_error(&json_response, &err);
8237                                return Err(Error::JsonDecodeError(json_response, err));
8238                            }
8239                        }
8240                    };
8241
8242                    dlg.finished(true);
8243                    return Ok(result_value)
8244                }
8245            }
8246        }
8247    }
8248
8249
8250    /// Immutable ID of the G Suite account
8251    ///
8252    /// Sets the *customer id* path property to the given value.
8253    ///
8254    /// Even though the property as already been set when instantiating this call,
8255    /// we provide this method for API completeness.
8256    pub fn customer_id(mut self, new_value: &str) -> OrgunitGetCall<'a, C, A> {
8257        self._customer_id = new_value.to_string();
8258        self
8259    }
8260    /// Full path of the organizational unit or its ID
8261    ///
8262    /// Append the given value to the *org unit path* path property.
8263    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8264    ///
8265    /// Even though the property as already been set when instantiating this call,
8266    /// we provide this method for API completeness.
8267    pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitGetCall<'a, C, A> {
8268        self._org_unit_path.push(new_value.to_string());
8269        self
8270    }
8271    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8272    /// while executing the actual API request.
8273    /// 
8274    /// It should be used to handle progress information, and to implement a certain level of resilience.
8275    ///
8276    /// Sets the *delegate* property to the given value.
8277    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OrgunitGetCall<'a, C, A> {
8278        self._delegate = Some(new_value);
8279        self
8280    }
8281
8282    /// Set any additional parameter of the query string used in the request.
8283    /// It should be used to set parameters which are not yet available through their own
8284    /// setters.
8285    ///
8286    /// Please note that this method must not be used to set any of the known parameters
8287    /// which have their own setter method. If done anyway, the request will fail.
8288    ///
8289    /// # Additional Parameters
8290    ///
8291    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8292    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8293    /// * *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.
8294    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8295    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8296    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8297    /// * *alt* (query-string) - Data format for the response.
8298    pub fn param<T>(mut self, name: T, value: T) -> OrgunitGetCall<'a, C, A>
8299                                                        where T: AsRef<str> {
8300        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
8301        self
8302    }
8303
8304    /// Identifies the authorization scope for the method you are building.
8305    ///
8306    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
8307    /// `Scope::DirectoryOrgunitReadonly`.
8308    ///
8309    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8310    /// tokens for more than one scope.
8311    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
8312    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
8313    /// function for details).
8314    ///
8315    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8316    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8317    /// sufficient, a read-write scope will do as well.
8318    pub fn add_scope<T, S>(mut self, scope: T) -> OrgunitGetCall<'a, C, A>
8319                                                        where T: Into<Option<S>>,
8320                                                              S: AsRef<str> {
8321        match scope.into() {
8322          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
8323          None => None,
8324        };
8325        self
8326    }
8327}
8328
8329
8330/// Remove organizational unit
8331///
8332/// A builder for the *delete* method supported by a *orgunit* resource.
8333/// It is not used directly, but through a `OrgunitMethods` instance.
8334///
8335/// # Example
8336///
8337/// Instantiate a resource method builder
8338///
8339/// ```test_harness,no_run
8340/// # extern crate hyper;
8341/// # extern crate hyper_rustls;
8342/// # extern crate yup_oauth2 as oauth2;
8343/// # extern crate google_admin1_directory as admin1_directory;
8344/// # #[test] fn egal() {
8345/// # use std::default::Default;
8346/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
8347/// # use admin1_directory::Directory;
8348/// 
8349/// # let secret: ApplicationSecret = Default::default();
8350/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
8351/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
8352/// #                               <MemoryStorage as Default>::default(), None);
8353/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
8354/// // You can configure optional parameters by calling the respective setters at will, and
8355/// // execute the final call using `doit()`.
8356/// // Values shown here are possibly random and not representative !
8357/// let result = hub.orgunits().delete("customerId", "orgUnitPath")
8358///              .doit();
8359/// # }
8360/// ```
8361pub struct OrgunitDeleteCall<'a, C, A>
8362    where C: 'a, A: 'a {
8363
8364    hub: &'a Directory<C, A>,
8365    _customer_id: String,
8366    _org_unit_path: Vec<String>,
8367    _delegate: Option<&'a mut dyn Delegate>,
8368    _additional_params: HashMap<String, String>,
8369    _scopes: BTreeMap<String, ()>
8370}
8371
8372impl<'a, C, A> CallBuilder for OrgunitDeleteCall<'a, C, A> {}
8373
8374impl<'a, C, A> OrgunitDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
8375
8376
8377    /// Perform the operation you have build so far.
8378    pub fn doit(mut self) -> Result<hyper::client::Response> {
8379        use std::io::{Read, Seek};
8380        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
8381        let mut dd = DefaultDelegate;
8382        let mut dlg: &mut dyn Delegate = match self._delegate {
8383            Some(d) => d,
8384            None => &mut dd
8385        };
8386        dlg.begin(MethodInfo { id: "directory.orgunits.delete",
8387                               http_method: hyper::method::Method::Delete });
8388        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
8389        params.push(("customerId", self._customer_id.to_string()));
8390        if self._org_unit_path.len() > 0 {
8391            for f in self._org_unit_path.iter() {
8392                params.push(("orgUnitPath", f.to_string()));
8393            }
8394        }
8395        for &field in ["customerId", "orgUnitPath"].iter() {
8396            if self._additional_params.contains_key(field) {
8397                dlg.finished(false);
8398                return Err(Error::FieldClash(field));
8399            }
8400        }
8401        for (name, value) in self._additional_params.iter() {
8402            params.push((&name, value.clone()));
8403        }
8404
8405
8406        let mut url = self.hub._base_url.clone() + "customer/{customerId}/orgunits{/orgUnitPath*}";
8407        if self._scopes.len() == 0 {
8408            self._scopes.insert(Scope::DirectoryOrgunit.as_ref().to_string(), ());
8409        }
8410
8411        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
8412            let mut replace_with: Option<&str> = None;
8413            for &(name, ref value) in params.iter() {
8414                if name == param_name {
8415                    replace_with = Some(value);
8416                    break;
8417                }
8418            }
8419            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
8420        }
8421        {
8422            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
8423            for param_name in ["orgUnitPath", "customerId"].iter() {
8424                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
8425                    indices_for_removal.push(index);
8426                }
8427            }
8428            for &index in indices_for_removal.iter() {
8429                params.remove(index);
8430            }
8431        }
8432
8433        let url = hyper::Url::parse_with_params(&url, params).unwrap();
8434
8435
8436
8437        loop {
8438            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
8439                Ok(token) => token,
8440                Err(err) => {
8441                    match  dlg.token(&*err) {
8442                        Some(token) => token,
8443                        None => {
8444                            dlg.finished(false);
8445                            return Err(Error::MissingToken(err))
8446                        }
8447                    }
8448                }
8449            };
8450            let auth_header = Authorization(Bearer { token: token.access_token });
8451            let mut req_result = {
8452                let mut client = &mut *self.hub.client.borrow_mut();
8453                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
8454                    .header(UserAgent(self.hub._user_agent.clone()))
8455                    .header(auth_header.clone());
8456
8457                dlg.pre_request();
8458                req.send()
8459            };
8460
8461            match req_result {
8462                Err(err) => {
8463                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
8464                        sleep(d);
8465                        continue;
8466                    }
8467                    dlg.finished(false);
8468                    return Err(Error::HttpError(err))
8469                }
8470                Ok(mut res) => {
8471                    if !res.status.is_success() {
8472                        let mut json_err = String::new();
8473                        res.read_to_string(&mut json_err).unwrap();
8474                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
8475                                                              json::from_str(&json_err).ok(),
8476                                                              json::from_str(&json_err).ok()) {
8477                            sleep(d);
8478                            continue;
8479                        }
8480                        dlg.finished(false);
8481                        return match json::from_str::<ErrorResponse>(&json_err){
8482                            Err(_) => Err(Error::Failure(res)),
8483                            Ok(serr) => Err(Error::BadRequest(serr))
8484                        }
8485                    }
8486                    let result_value = res;
8487
8488                    dlg.finished(true);
8489                    return Ok(result_value)
8490                }
8491            }
8492        }
8493    }
8494
8495
8496    /// Immutable ID of the G Suite account
8497    ///
8498    /// Sets the *customer id* path property to the given value.
8499    ///
8500    /// Even though the property as already been set when instantiating this call,
8501    /// we provide this method for API completeness.
8502    pub fn customer_id(mut self, new_value: &str) -> OrgunitDeleteCall<'a, C, A> {
8503        self._customer_id = new_value.to_string();
8504        self
8505    }
8506    /// Full path of the organizational unit or its ID
8507    ///
8508    /// Append the given value to the *org unit path* path property.
8509    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8510    ///
8511    /// Even though the property as already been set when instantiating this call,
8512    /// we provide this method for API completeness.
8513    pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitDeleteCall<'a, C, A> {
8514        self._org_unit_path.push(new_value.to_string());
8515        self
8516    }
8517    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8518    /// while executing the actual API request.
8519    /// 
8520    /// It should be used to handle progress information, and to implement a certain level of resilience.
8521    ///
8522    /// Sets the *delegate* property to the given value.
8523    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OrgunitDeleteCall<'a, C, A> {
8524        self._delegate = Some(new_value);
8525        self
8526    }
8527
8528    /// Set any additional parameter of the query string used in the request.
8529    /// It should be used to set parameters which are not yet available through their own
8530    /// setters.
8531    ///
8532    /// Please note that this method must not be used to set any of the known parameters
8533    /// which have their own setter method. If done anyway, the request will fail.
8534    ///
8535    /// # Additional Parameters
8536    ///
8537    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8538    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8539    /// * *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.
8540    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8541    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8542    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8543    /// * *alt* (query-string) - Data format for the response.
8544    pub fn param<T>(mut self, name: T, value: T) -> OrgunitDeleteCall<'a, C, A>
8545                                                        where T: AsRef<str> {
8546        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
8547        self
8548    }
8549
8550    /// Identifies the authorization scope for the method you are building.
8551    ///
8552    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
8553    /// `Scope::DirectoryOrgunit`.
8554    ///
8555    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8556    /// tokens for more than one scope.
8557    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
8558    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
8559    /// function for details).
8560    ///
8561    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8562    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8563    /// sufficient, a read-write scope will do as well.
8564    pub fn add_scope<T, S>(mut self, scope: T) -> OrgunitDeleteCall<'a, C, A>
8565                                                        where T: Into<Option<S>>,
8566                                                              S: AsRef<str> {
8567        match scope.into() {
8568          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
8569          None => None,
8570        };
8571        self
8572    }
8573}
8574
8575
8576/// Update organizational unit. This method supports patch semantics.
8577///
8578/// A builder for the *patch* method supported by a *orgunit* resource.
8579/// It is not used directly, but through a `OrgunitMethods` instance.
8580///
8581/// # Example
8582///
8583/// Instantiate a resource method builder
8584///
8585/// ```test_harness,no_run
8586/// # extern crate hyper;
8587/// # extern crate hyper_rustls;
8588/// # extern crate yup_oauth2 as oauth2;
8589/// # extern crate google_admin1_directory as admin1_directory;
8590/// use admin1_directory::OrgUnit;
8591/// # #[test] fn egal() {
8592/// # use std::default::Default;
8593/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
8594/// # use admin1_directory::Directory;
8595/// 
8596/// # let secret: ApplicationSecret = Default::default();
8597/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
8598/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
8599/// #                               <MemoryStorage as Default>::default(), None);
8600/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
8601/// // As the method needs a request, you would usually fill it with the desired information
8602/// // into the respective structure. Some of the parts shown here might not be applicable !
8603/// // Values shown here are possibly random and not representative !
8604/// let mut req = OrgUnit::default();
8605/// 
8606/// // You can configure optional parameters by calling the respective setters at will, and
8607/// // execute the final call using `doit()`.
8608/// // Values shown here are possibly random and not representative !
8609/// let result = hub.orgunits().patch(req, "customerId", "orgUnitPath")
8610///              .doit();
8611/// # }
8612/// ```
8613pub struct OrgunitPatchCall<'a, C, A>
8614    where C: 'a, A: 'a {
8615
8616    hub: &'a Directory<C, A>,
8617    _request: OrgUnit,
8618    _customer_id: String,
8619    _org_unit_path: Vec<String>,
8620    _delegate: Option<&'a mut dyn Delegate>,
8621    _additional_params: HashMap<String, String>,
8622    _scopes: BTreeMap<String, ()>
8623}
8624
8625impl<'a, C, A> CallBuilder for OrgunitPatchCall<'a, C, A> {}
8626
8627impl<'a, C, A> OrgunitPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
8628
8629
8630    /// Perform the operation you have build so far.
8631    pub fn doit(mut self) -> Result<(hyper::client::Response, OrgUnit)> {
8632        use std::io::{Read, Seek};
8633        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
8634        let mut dd = DefaultDelegate;
8635        let mut dlg: &mut dyn Delegate = match self._delegate {
8636            Some(d) => d,
8637            None => &mut dd
8638        };
8639        dlg.begin(MethodInfo { id: "directory.orgunits.patch",
8640                               http_method: hyper::method::Method::Patch });
8641        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
8642        params.push(("customerId", self._customer_id.to_string()));
8643        if self._org_unit_path.len() > 0 {
8644            for f in self._org_unit_path.iter() {
8645                params.push(("orgUnitPath", f.to_string()));
8646            }
8647        }
8648        for &field in ["alt", "customerId", "orgUnitPath"].iter() {
8649            if self._additional_params.contains_key(field) {
8650                dlg.finished(false);
8651                return Err(Error::FieldClash(field));
8652            }
8653        }
8654        for (name, value) in self._additional_params.iter() {
8655            params.push((&name, value.clone()));
8656        }
8657
8658        params.push(("alt", "json".to_string()));
8659
8660        let mut url = self.hub._base_url.clone() + "customer/{customerId}/orgunits{/orgUnitPath*}";
8661        if self._scopes.len() == 0 {
8662            self._scopes.insert(Scope::DirectoryOrgunit.as_ref().to_string(), ());
8663        }
8664
8665        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{/orgUnitPath*}", "orgUnitPath")].iter() {
8666            let mut replace_with: Option<&str> = None;
8667            for &(name, ref value) in params.iter() {
8668                if name == param_name {
8669                    replace_with = Some(value);
8670                    break;
8671                }
8672            }
8673            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
8674        }
8675        {
8676            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
8677            for param_name in ["orgUnitPath", "customerId"].iter() {
8678                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
8679                    indices_for_removal.push(index);
8680                }
8681            }
8682            for &index in indices_for_removal.iter() {
8683                params.remove(index);
8684            }
8685        }
8686
8687        let url = hyper::Url::parse_with_params(&url, params).unwrap();
8688
8689        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
8690        let mut request_value_reader =
8691            {
8692                let mut value = json::value::to_value(&self._request).expect("serde to work");
8693                remove_json_null_values(&mut value);
8694                let mut dst = io::Cursor::new(Vec::with_capacity(128));
8695                json::to_writer(&mut dst, &value).unwrap();
8696                dst
8697            };
8698        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
8699        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8700
8701
8702        loop {
8703            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
8704                Ok(token) => token,
8705                Err(err) => {
8706                    match  dlg.token(&*err) {
8707                        Some(token) => token,
8708                        None => {
8709                            dlg.finished(false);
8710                            return Err(Error::MissingToken(err))
8711                        }
8712                    }
8713                }
8714            };
8715            let auth_header = Authorization(Bearer { token: token.access_token });
8716            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8717            let mut req_result = {
8718                let mut client = &mut *self.hub.client.borrow_mut();
8719                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
8720                    .header(UserAgent(self.hub._user_agent.clone()))
8721                    .header(auth_header.clone())
8722                    .header(ContentType(json_mime_type.clone()))
8723                    .header(ContentLength(request_size as u64))
8724                    .body(&mut request_value_reader);
8725
8726                dlg.pre_request();
8727                req.send()
8728            };
8729
8730            match req_result {
8731                Err(err) => {
8732                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
8733                        sleep(d);
8734                        continue;
8735                    }
8736                    dlg.finished(false);
8737                    return Err(Error::HttpError(err))
8738                }
8739                Ok(mut res) => {
8740                    if !res.status.is_success() {
8741                        let mut json_err = String::new();
8742                        res.read_to_string(&mut json_err).unwrap();
8743                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
8744                                                              json::from_str(&json_err).ok(),
8745                                                              json::from_str(&json_err).ok()) {
8746                            sleep(d);
8747                            continue;
8748                        }
8749                        dlg.finished(false);
8750                        return match json::from_str::<ErrorResponse>(&json_err){
8751                            Err(_) => Err(Error::Failure(res)),
8752                            Ok(serr) => Err(Error::BadRequest(serr))
8753                        }
8754                    }
8755                    let result_value = {
8756                        let mut json_response = String::new();
8757                        res.read_to_string(&mut json_response).unwrap();
8758                        match json::from_str(&json_response) {
8759                            Ok(decoded) => (res, decoded),
8760                            Err(err) => {
8761                                dlg.response_json_decode_error(&json_response, &err);
8762                                return Err(Error::JsonDecodeError(json_response, err));
8763                            }
8764                        }
8765                    };
8766
8767                    dlg.finished(true);
8768                    return Ok(result_value)
8769                }
8770            }
8771        }
8772    }
8773
8774
8775    ///
8776    /// Sets the *request* property to the given value.
8777    ///
8778    /// Even though the property as already been set when instantiating this call,
8779    /// we provide this method for API completeness.
8780    pub fn request(mut self, new_value: OrgUnit) -> OrgunitPatchCall<'a, C, A> {
8781        self._request = new_value;
8782        self
8783    }
8784    /// Immutable ID of the G Suite account
8785    ///
8786    /// Sets the *customer id* path property to the given value.
8787    ///
8788    /// Even though the property as already been set when instantiating this call,
8789    /// we provide this method for API completeness.
8790    pub fn customer_id(mut self, new_value: &str) -> OrgunitPatchCall<'a, C, A> {
8791        self._customer_id = new_value.to_string();
8792        self
8793    }
8794    /// Full path of the organizational unit or its ID
8795    ///
8796    /// Append the given value to the *org unit path* path property.
8797    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8798    ///
8799    /// Even though the property as already been set when instantiating this call,
8800    /// we provide this method for API completeness.
8801    pub fn add_org_unit_path(mut self, new_value: &str) -> OrgunitPatchCall<'a, C, A> {
8802        self._org_unit_path.push(new_value.to_string());
8803        self
8804    }
8805    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8806    /// while executing the actual API request.
8807    /// 
8808    /// It should be used to handle progress information, and to implement a certain level of resilience.
8809    ///
8810    /// Sets the *delegate* property to the given value.
8811    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OrgunitPatchCall<'a, C, A> {
8812        self._delegate = Some(new_value);
8813        self
8814    }
8815
8816    /// Set any additional parameter of the query string used in the request.
8817    /// It should be used to set parameters which are not yet available through their own
8818    /// setters.
8819    ///
8820    /// Please note that this method must not be used to set any of the known parameters
8821    /// which have their own setter method. If done anyway, the request will fail.
8822    ///
8823    /// # Additional Parameters
8824    ///
8825    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8827    /// * *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.
8828    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8829    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8830    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8831    /// * *alt* (query-string) - Data format for the response.
8832    pub fn param<T>(mut self, name: T, value: T) -> OrgunitPatchCall<'a, C, A>
8833                                                        where T: AsRef<str> {
8834        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
8835        self
8836    }
8837
8838    /// Identifies the authorization scope for the method you are building.
8839    ///
8840    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
8841    /// `Scope::DirectoryOrgunit`.
8842    ///
8843    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8844    /// tokens for more than one scope.
8845    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
8846    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
8847    /// function for details).
8848    ///
8849    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8850    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8851    /// sufficient, a read-write scope will do as well.
8852    pub fn add_scope<T, S>(mut self, scope: T) -> OrgunitPatchCall<'a, C, A>
8853                                                        where T: Into<Option<S>>,
8854                                                              S: AsRef<str> {
8855        match scope.into() {
8856          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
8857          None => None,
8858        };
8859        self
8860    }
8861}
8862
8863
8864/// Delete Group
8865///
8866/// A builder for the *delete* method supported by a *group* resource.
8867/// It is not used directly, but through a `GroupMethods` instance.
8868///
8869/// # Example
8870///
8871/// Instantiate a resource method builder
8872///
8873/// ```test_harness,no_run
8874/// # extern crate hyper;
8875/// # extern crate hyper_rustls;
8876/// # extern crate yup_oauth2 as oauth2;
8877/// # extern crate google_admin1_directory as admin1_directory;
8878/// # #[test] fn egal() {
8879/// # use std::default::Default;
8880/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
8881/// # use admin1_directory::Directory;
8882/// 
8883/// # let secret: ApplicationSecret = Default::default();
8884/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
8885/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
8886/// #                               <MemoryStorage as Default>::default(), None);
8887/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
8888/// // You can configure optional parameters by calling the respective setters at will, and
8889/// // execute the final call using `doit()`.
8890/// // Values shown here are possibly random and not representative !
8891/// let result = hub.groups().delete("groupKey")
8892///              .doit();
8893/// # }
8894/// ```
8895pub struct GroupDeleteCall<'a, C, A>
8896    where C: 'a, A: 'a {
8897
8898    hub: &'a Directory<C, A>,
8899    _group_key: String,
8900    _delegate: Option<&'a mut dyn Delegate>,
8901    _additional_params: HashMap<String, String>,
8902    _scopes: BTreeMap<String, ()>
8903}
8904
8905impl<'a, C, A> CallBuilder for GroupDeleteCall<'a, C, A> {}
8906
8907impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
8908
8909
8910    /// Perform the operation you have build so far.
8911    pub fn doit(mut self) -> Result<hyper::client::Response> {
8912        use std::io::{Read, Seek};
8913        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
8914        let mut dd = DefaultDelegate;
8915        let mut dlg: &mut dyn Delegate = match self._delegate {
8916            Some(d) => d,
8917            None => &mut dd
8918        };
8919        dlg.begin(MethodInfo { id: "directory.groups.delete",
8920                               http_method: hyper::method::Method::Delete });
8921        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
8922        params.push(("groupKey", self._group_key.to_string()));
8923        for &field in ["groupKey"].iter() {
8924            if self._additional_params.contains_key(field) {
8925                dlg.finished(false);
8926                return Err(Error::FieldClash(field));
8927            }
8928        }
8929        for (name, value) in self._additional_params.iter() {
8930            params.push((&name, value.clone()));
8931        }
8932
8933
8934        let mut url = self.hub._base_url.clone() + "groups/{groupKey}";
8935        if self._scopes.len() == 0 {
8936            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
8937        }
8938
8939        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
8940            let mut replace_with: Option<&str> = None;
8941            for &(name, ref value) in params.iter() {
8942                if name == param_name {
8943                    replace_with = Some(value);
8944                    break;
8945                }
8946            }
8947            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
8948        }
8949        {
8950            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
8951            for param_name in ["groupKey"].iter() {
8952                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
8953                    indices_for_removal.push(index);
8954                }
8955            }
8956            for &index in indices_for_removal.iter() {
8957                params.remove(index);
8958            }
8959        }
8960
8961        let url = hyper::Url::parse_with_params(&url, params).unwrap();
8962
8963
8964
8965        loop {
8966            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
8967                Ok(token) => token,
8968                Err(err) => {
8969                    match  dlg.token(&*err) {
8970                        Some(token) => token,
8971                        None => {
8972                            dlg.finished(false);
8973                            return Err(Error::MissingToken(err))
8974                        }
8975                    }
8976                }
8977            };
8978            let auth_header = Authorization(Bearer { token: token.access_token });
8979            let mut req_result = {
8980                let mut client = &mut *self.hub.client.borrow_mut();
8981                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
8982                    .header(UserAgent(self.hub._user_agent.clone()))
8983                    .header(auth_header.clone());
8984
8985                dlg.pre_request();
8986                req.send()
8987            };
8988
8989            match req_result {
8990                Err(err) => {
8991                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
8992                        sleep(d);
8993                        continue;
8994                    }
8995                    dlg.finished(false);
8996                    return Err(Error::HttpError(err))
8997                }
8998                Ok(mut res) => {
8999                    if !res.status.is_success() {
9000                        let mut json_err = String::new();
9001                        res.read_to_string(&mut json_err).unwrap();
9002                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
9003                                                              json::from_str(&json_err).ok(),
9004                                                              json::from_str(&json_err).ok()) {
9005                            sleep(d);
9006                            continue;
9007                        }
9008                        dlg.finished(false);
9009                        return match json::from_str::<ErrorResponse>(&json_err){
9010                            Err(_) => Err(Error::Failure(res)),
9011                            Ok(serr) => Err(Error::BadRequest(serr))
9012                        }
9013                    }
9014                    let result_value = res;
9015
9016                    dlg.finished(true);
9017                    return Ok(result_value)
9018                }
9019            }
9020        }
9021    }
9022
9023
9024    /// Email or immutable ID of the group
9025    ///
9026    /// Sets the *group key* path property to the given value.
9027    ///
9028    /// Even though the property as already been set when instantiating this call,
9029    /// we provide this method for API completeness.
9030    pub fn group_key(mut self, new_value: &str) -> GroupDeleteCall<'a, C, A> {
9031        self._group_key = new_value.to_string();
9032        self
9033    }
9034    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9035    /// while executing the actual API request.
9036    /// 
9037    /// It should be used to handle progress information, and to implement a certain level of resilience.
9038    ///
9039    /// Sets the *delegate* property to the given value.
9040    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupDeleteCall<'a, C, A> {
9041        self._delegate = Some(new_value);
9042        self
9043    }
9044
9045    /// Set any additional parameter of the query string used in the request.
9046    /// It should be used to set parameters which are not yet available through their own
9047    /// setters.
9048    ///
9049    /// Please note that this method must not be used to set any of the known parameters
9050    /// which have their own setter method. If done anyway, the request will fail.
9051    ///
9052    /// # Additional Parameters
9053    ///
9054    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9055    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9056    /// * *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.
9057    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9058    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9059    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9060    /// * *alt* (query-string) - Data format for the response.
9061    pub fn param<T>(mut self, name: T, value: T) -> GroupDeleteCall<'a, C, A>
9062                                                        where T: AsRef<str> {
9063        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
9064        self
9065    }
9066
9067    /// Identifies the authorization scope for the method you are building.
9068    ///
9069    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9070    /// `Scope::DirectoryGroup`.
9071    ///
9072    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9073    /// tokens for more than one scope.
9074    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9075    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9076    /// function for details).
9077    ///
9078    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9079    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9080    /// sufficient, a read-write scope will do as well.
9081    pub fn add_scope<T, S>(mut self, scope: T) -> GroupDeleteCall<'a, C, A>
9082                                                        where T: Into<Option<S>>,
9083                                                              S: AsRef<str> {
9084        match scope.into() {
9085          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9086          None => None,
9087        };
9088        self
9089    }
9090}
9091
9092
9093/// Retrieve all groups of a domain or of a user given a userKey (paginated)
9094///
9095/// A builder for the *list* method supported by a *group* resource.
9096/// It is not used directly, but through a `GroupMethods` instance.
9097///
9098/// # Example
9099///
9100/// Instantiate a resource method builder
9101///
9102/// ```test_harness,no_run
9103/// # extern crate hyper;
9104/// # extern crate hyper_rustls;
9105/// # extern crate yup_oauth2 as oauth2;
9106/// # extern crate google_admin1_directory as admin1_directory;
9107/// # #[test] fn egal() {
9108/// # use std::default::Default;
9109/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
9110/// # use admin1_directory::Directory;
9111/// 
9112/// # let secret: ApplicationSecret = Default::default();
9113/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
9114/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
9115/// #                               <MemoryStorage as Default>::default(), None);
9116/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
9117/// // You can configure optional parameters by calling the respective setters at will, and
9118/// // execute the final call using `doit()`.
9119/// // Values shown here are possibly random and not representative !
9120/// let result = hub.groups().list()
9121///              .user_key("amet")
9122///              .sort_order("et")
9123///              .query("consetetur")
9124///              .page_token("ut")
9125///              .order_by("ea")
9126///              .max_results(-80)
9127///              .domain("dolor")
9128///              .customer("dolor")
9129///              .doit();
9130/// # }
9131/// ```
9132pub struct GroupListCall<'a, C, A>
9133    where C: 'a, A: 'a {
9134
9135    hub: &'a Directory<C, A>,
9136    _user_key: Option<String>,
9137    _sort_order: Option<String>,
9138    _query: Option<String>,
9139    _page_token: Option<String>,
9140    _order_by: Option<String>,
9141    _max_results: Option<i32>,
9142    _domain: Option<String>,
9143    _customer: Option<String>,
9144    _delegate: Option<&'a mut dyn Delegate>,
9145    _additional_params: HashMap<String, String>,
9146    _scopes: BTreeMap<String, ()>
9147}
9148
9149impl<'a, C, A> CallBuilder for GroupListCall<'a, C, A> {}
9150
9151impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
9152
9153
9154    /// Perform the operation you have build so far.
9155    pub fn doit(mut self) -> Result<(hyper::client::Response, Groups)> {
9156        use std::io::{Read, Seek};
9157        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
9158        let mut dd = DefaultDelegate;
9159        let mut dlg: &mut dyn Delegate = match self._delegate {
9160            Some(d) => d,
9161            None => &mut dd
9162        };
9163        dlg.begin(MethodInfo { id: "directory.groups.list",
9164                               http_method: hyper::method::Method::Get });
9165        let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len());
9166        if let Some(value) = self._user_key {
9167            params.push(("userKey", value.to_string()));
9168        }
9169        if let Some(value) = self._sort_order {
9170            params.push(("sortOrder", value.to_string()));
9171        }
9172        if let Some(value) = self._query {
9173            params.push(("query", value.to_string()));
9174        }
9175        if let Some(value) = self._page_token {
9176            params.push(("pageToken", value.to_string()));
9177        }
9178        if let Some(value) = self._order_by {
9179            params.push(("orderBy", value.to_string()));
9180        }
9181        if let Some(value) = self._max_results {
9182            params.push(("maxResults", value.to_string()));
9183        }
9184        if let Some(value) = self._domain {
9185            params.push(("domain", value.to_string()));
9186        }
9187        if let Some(value) = self._customer {
9188            params.push(("customer", value.to_string()));
9189        }
9190        for &field in ["alt", "userKey", "sortOrder", "query", "pageToken", "orderBy", "maxResults", "domain", "customer"].iter() {
9191            if self._additional_params.contains_key(field) {
9192                dlg.finished(false);
9193                return Err(Error::FieldClash(field));
9194            }
9195        }
9196        for (name, value) in self._additional_params.iter() {
9197            params.push((&name, value.clone()));
9198        }
9199
9200        params.push(("alt", "json".to_string()));
9201
9202        let mut url = self.hub._base_url.clone() + "groups";
9203        if self._scopes.len() == 0 {
9204            self._scopes.insert(Scope::DirectoryGroupReadonly.as_ref().to_string(), ());
9205        }
9206
9207
9208        let url = hyper::Url::parse_with_params(&url, params).unwrap();
9209
9210
9211
9212        loop {
9213            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
9214                Ok(token) => token,
9215                Err(err) => {
9216                    match  dlg.token(&*err) {
9217                        Some(token) => token,
9218                        None => {
9219                            dlg.finished(false);
9220                            return Err(Error::MissingToken(err))
9221                        }
9222                    }
9223                }
9224            };
9225            let auth_header = Authorization(Bearer { token: token.access_token });
9226            let mut req_result = {
9227                let mut client = &mut *self.hub.client.borrow_mut();
9228                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
9229                    .header(UserAgent(self.hub._user_agent.clone()))
9230                    .header(auth_header.clone());
9231
9232                dlg.pre_request();
9233                req.send()
9234            };
9235
9236            match req_result {
9237                Err(err) => {
9238                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
9239                        sleep(d);
9240                        continue;
9241                    }
9242                    dlg.finished(false);
9243                    return Err(Error::HttpError(err))
9244                }
9245                Ok(mut res) => {
9246                    if !res.status.is_success() {
9247                        let mut json_err = String::new();
9248                        res.read_to_string(&mut json_err).unwrap();
9249                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
9250                                                              json::from_str(&json_err).ok(),
9251                                                              json::from_str(&json_err).ok()) {
9252                            sleep(d);
9253                            continue;
9254                        }
9255                        dlg.finished(false);
9256                        return match json::from_str::<ErrorResponse>(&json_err){
9257                            Err(_) => Err(Error::Failure(res)),
9258                            Ok(serr) => Err(Error::BadRequest(serr))
9259                        }
9260                    }
9261                    let result_value = {
9262                        let mut json_response = String::new();
9263                        res.read_to_string(&mut json_response).unwrap();
9264                        match json::from_str(&json_response) {
9265                            Ok(decoded) => (res, decoded),
9266                            Err(err) => {
9267                                dlg.response_json_decode_error(&json_response, &err);
9268                                return Err(Error::JsonDecodeError(json_response, err));
9269                            }
9270                        }
9271                    };
9272
9273                    dlg.finished(true);
9274                    return Ok(result_value)
9275                }
9276            }
9277        }
9278    }
9279
9280
9281    /// Email or immutable ID of the user if only those groups are to be listed, the given user is a member of. If it's an ID, it should match with the ID of the user object.
9282    ///
9283    /// Sets the *user key* query property to the given value.
9284    pub fn user_key(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
9285        self._user_key = Some(new_value.to_string());
9286        self
9287    }
9288    /// Whether to return results in ascending or descending order. Only of use when orderBy is also used
9289    ///
9290    /// Sets the *sort order* query property to the given value.
9291    pub fn sort_order(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
9292        self._sort_order = Some(new_value.to_string());
9293        self
9294    }
9295    /// Query string search. Should be of the form "". Complete documentation is at https://developers.google.com/admin-sdk/directory/v1/guides/search-groups
9296    ///
9297    /// Sets the *query* query property to the given value.
9298    pub fn query(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
9299        self._query = Some(new_value.to_string());
9300        self
9301    }
9302    /// Token to specify next page in the list
9303    ///
9304    /// Sets the *page token* query property to the given value.
9305    pub fn page_token(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
9306        self._page_token = Some(new_value.to_string());
9307        self
9308    }
9309    /// Column to use for sorting results
9310    ///
9311    /// Sets the *order by* query property to the given value.
9312    pub fn order_by(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
9313        self._order_by = Some(new_value.to_string());
9314        self
9315    }
9316    /// Maximum number of results to return. Max allowed value is 200.
9317    ///
9318    /// Sets the *max results* query property to the given value.
9319    pub fn max_results(mut self, new_value: i32) -> GroupListCall<'a, C, A> {
9320        self._max_results = Some(new_value);
9321        self
9322    }
9323    /// 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.
9324    ///
9325    /// Sets the *domain* query property to the given value.
9326    pub fn domain(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
9327        self._domain = Some(new_value.to_string());
9328        self
9329    }
9330    /// Immutable ID of the G Suite account. In case of multi-domain, to fetch all groups for a customer, fill this field instead of domain.
9331    ///
9332    /// Sets the *customer* query property to the given value.
9333    pub fn customer(mut self, new_value: &str) -> GroupListCall<'a, C, A> {
9334        self._customer = Some(new_value.to_string());
9335        self
9336    }
9337    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9338    /// while executing the actual API request.
9339    /// 
9340    /// It should be used to handle progress information, and to implement a certain level of resilience.
9341    ///
9342    /// Sets the *delegate* property to the given value.
9343    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupListCall<'a, C, A> {
9344        self._delegate = Some(new_value);
9345        self
9346    }
9347
9348    /// Set any additional parameter of the query string used in the request.
9349    /// It should be used to set parameters which are not yet available through their own
9350    /// setters.
9351    ///
9352    /// Please note that this method must not be used to set any of the known parameters
9353    /// which have their own setter method. If done anyway, the request will fail.
9354    ///
9355    /// # Additional Parameters
9356    ///
9357    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9358    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9359    /// * *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.
9360    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9361    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9362    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9363    /// * *alt* (query-string) - Data format for the response.
9364    pub fn param<T>(mut self, name: T, value: T) -> GroupListCall<'a, C, A>
9365                                                        where T: AsRef<str> {
9366        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
9367        self
9368    }
9369
9370    /// Identifies the authorization scope for the method you are building.
9371    ///
9372    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9373    /// `Scope::DirectoryGroupReadonly`.
9374    ///
9375    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9376    /// tokens for more than one scope.
9377    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9378    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9379    /// function for details).
9380    ///
9381    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9382    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9383    /// sufficient, a read-write scope will do as well.
9384    pub fn add_scope<T, S>(mut self, scope: T) -> GroupListCall<'a, C, A>
9385                                                        where T: Into<Option<S>>,
9386                                                              S: AsRef<str> {
9387        match scope.into() {
9388          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9389          None => None,
9390        };
9391        self
9392    }
9393}
9394
9395
9396/// Update Group
9397///
9398/// A builder for the *update* method supported by a *group* resource.
9399/// It is not used directly, but through a `GroupMethods` instance.
9400///
9401/// # Example
9402///
9403/// Instantiate a resource method builder
9404///
9405/// ```test_harness,no_run
9406/// # extern crate hyper;
9407/// # extern crate hyper_rustls;
9408/// # extern crate yup_oauth2 as oauth2;
9409/// # extern crate google_admin1_directory as admin1_directory;
9410/// use admin1_directory::Group;
9411/// # #[test] fn egal() {
9412/// # use std::default::Default;
9413/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
9414/// # use admin1_directory::Directory;
9415/// 
9416/// # let secret: ApplicationSecret = Default::default();
9417/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
9418/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
9419/// #                               <MemoryStorage as Default>::default(), None);
9420/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
9421/// // As the method needs a request, you would usually fill it with the desired information
9422/// // into the respective structure. Some of the parts shown here might not be applicable !
9423/// // Values shown here are possibly random and not representative !
9424/// let mut req = Group::default();
9425/// 
9426/// // You can configure optional parameters by calling the respective setters at will, and
9427/// // execute the final call using `doit()`.
9428/// // Values shown here are possibly random and not representative !
9429/// let result = hub.groups().update(req, "groupKey")
9430///              .doit();
9431/// # }
9432/// ```
9433pub struct GroupUpdateCall<'a, C, A>
9434    where C: 'a, A: 'a {
9435
9436    hub: &'a Directory<C, A>,
9437    _request: Group,
9438    _group_key: String,
9439    _delegate: Option<&'a mut dyn Delegate>,
9440    _additional_params: HashMap<String, String>,
9441    _scopes: BTreeMap<String, ()>
9442}
9443
9444impl<'a, C, A> CallBuilder for GroupUpdateCall<'a, C, A> {}
9445
9446impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
9447
9448
9449    /// Perform the operation you have build so far.
9450    pub fn doit(mut self) -> Result<(hyper::client::Response, Group)> {
9451        use std::io::{Read, Seek};
9452        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
9453        let mut dd = DefaultDelegate;
9454        let mut dlg: &mut dyn Delegate = match self._delegate {
9455            Some(d) => d,
9456            None => &mut dd
9457        };
9458        dlg.begin(MethodInfo { id: "directory.groups.update",
9459                               http_method: hyper::method::Method::Put });
9460        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
9461        params.push(("groupKey", self._group_key.to_string()));
9462        for &field in ["alt", "groupKey"].iter() {
9463            if self._additional_params.contains_key(field) {
9464                dlg.finished(false);
9465                return Err(Error::FieldClash(field));
9466            }
9467        }
9468        for (name, value) in self._additional_params.iter() {
9469            params.push((&name, value.clone()));
9470        }
9471
9472        params.push(("alt", "json".to_string()));
9473
9474        let mut url = self.hub._base_url.clone() + "groups/{groupKey}";
9475        if self._scopes.len() == 0 {
9476            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
9477        }
9478
9479        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
9480            let mut replace_with: Option<&str> = None;
9481            for &(name, ref value) in params.iter() {
9482                if name == param_name {
9483                    replace_with = Some(value);
9484                    break;
9485                }
9486            }
9487            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
9488        }
9489        {
9490            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
9491            for param_name in ["groupKey"].iter() {
9492                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
9493                    indices_for_removal.push(index);
9494                }
9495            }
9496            for &index in indices_for_removal.iter() {
9497                params.remove(index);
9498            }
9499        }
9500
9501        let url = hyper::Url::parse_with_params(&url, params).unwrap();
9502
9503        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
9504        let mut request_value_reader =
9505            {
9506                let mut value = json::value::to_value(&self._request).expect("serde to work");
9507                remove_json_null_values(&mut value);
9508                let mut dst = io::Cursor::new(Vec::with_capacity(128));
9509                json::to_writer(&mut dst, &value).unwrap();
9510                dst
9511            };
9512        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
9513        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
9514
9515
9516        loop {
9517            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
9518                Ok(token) => token,
9519                Err(err) => {
9520                    match  dlg.token(&*err) {
9521                        Some(token) => token,
9522                        None => {
9523                            dlg.finished(false);
9524                            return Err(Error::MissingToken(err))
9525                        }
9526                    }
9527                }
9528            };
9529            let auth_header = Authorization(Bearer { token: token.access_token });
9530            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
9531            let mut req_result = {
9532                let mut client = &mut *self.hub.client.borrow_mut();
9533                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
9534                    .header(UserAgent(self.hub._user_agent.clone()))
9535                    .header(auth_header.clone())
9536                    .header(ContentType(json_mime_type.clone()))
9537                    .header(ContentLength(request_size as u64))
9538                    .body(&mut request_value_reader);
9539
9540                dlg.pre_request();
9541                req.send()
9542            };
9543
9544            match req_result {
9545                Err(err) => {
9546                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
9547                        sleep(d);
9548                        continue;
9549                    }
9550                    dlg.finished(false);
9551                    return Err(Error::HttpError(err))
9552                }
9553                Ok(mut res) => {
9554                    if !res.status.is_success() {
9555                        let mut json_err = String::new();
9556                        res.read_to_string(&mut json_err).unwrap();
9557                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
9558                                                              json::from_str(&json_err).ok(),
9559                                                              json::from_str(&json_err).ok()) {
9560                            sleep(d);
9561                            continue;
9562                        }
9563                        dlg.finished(false);
9564                        return match json::from_str::<ErrorResponse>(&json_err){
9565                            Err(_) => Err(Error::Failure(res)),
9566                            Ok(serr) => Err(Error::BadRequest(serr))
9567                        }
9568                    }
9569                    let result_value = {
9570                        let mut json_response = String::new();
9571                        res.read_to_string(&mut json_response).unwrap();
9572                        match json::from_str(&json_response) {
9573                            Ok(decoded) => (res, decoded),
9574                            Err(err) => {
9575                                dlg.response_json_decode_error(&json_response, &err);
9576                                return Err(Error::JsonDecodeError(json_response, err));
9577                            }
9578                        }
9579                    };
9580
9581                    dlg.finished(true);
9582                    return Ok(result_value)
9583                }
9584            }
9585        }
9586    }
9587
9588
9589    ///
9590    /// Sets the *request* property to the given value.
9591    ///
9592    /// Even though the property as already been set when instantiating this call,
9593    /// we provide this method for API completeness.
9594    pub fn request(mut self, new_value: Group) -> GroupUpdateCall<'a, C, A> {
9595        self._request = new_value;
9596        self
9597    }
9598    /// Email or immutable ID of the group. If ID, it should match with id of group object
9599    ///
9600    /// Sets the *group key* path property to the given value.
9601    ///
9602    /// Even though the property as already been set when instantiating this call,
9603    /// we provide this method for API completeness.
9604    pub fn group_key(mut self, new_value: &str) -> GroupUpdateCall<'a, C, A> {
9605        self._group_key = new_value.to_string();
9606        self
9607    }
9608    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9609    /// while executing the actual API request.
9610    /// 
9611    /// It should be used to handle progress information, and to implement a certain level of resilience.
9612    ///
9613    /// Sets the *delegate* property to the given value.
9614    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupUpdateCall<'a, C, A> {
9615        self._delegate = Some(new_value);
9616        self
9617    }
9618
9619    /// Set any additional parameter of the query string used in the request.
9620    /// It should be used to set parameters which are not yet available through their own
9621    /// setters.
9622    ///
9623    /// Please note that this method must not be used to set any of the known parameters
9624    /// which have their own setter method. If done anyway, the request will fail.
9625    ///
9626    /// # Additional Parameters
9627    ///
9628    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9629    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9630    /// * *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.
9631    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9632    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9633    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9634    /// * *alt* (query-string) - Data format for the response.
9635    pub fn param<T>(mut self, name: T, value: T) -> GroupUpdateCall<'a, C, A>
9636                                                        where T: AsRef<str> {
9637        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
9638        self
9639    }
9640
9641    /// Identifies the authorization scope for the method you are building.
9642    ///
9643    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9644    /// `Scope::DirectoryGroup`.
9645    ///
9646    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9647    /// tokens for more than one scope.
9648    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9649    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9650    /// function for details).
9651    ///
9652    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9653    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9654    /// sufficient, a read-write scope will do as well.
9655    pub fn add_scope<T, S>(mut self, scope: T) -> GroupUpdateCall<'a, C, A>
9656                                                        where T: Into<Option<S>>,
9657                                                              S: AsRef<str> {
9658        match scope.into() {
9659          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9660          None => None,
9661        };
9662        self
9663    }
9664}
9665
9666
9667/// Create Group
9668///
9669/// A builder for the *insert* method supported by a *group* resource.
9670/// It is not used directly, but through a `GroupMethods` instance.
9671///
9672/// # Example
9673///
9674/// Instantiate a resource method builder
9675///
9676/// ```test_harness,no_run
9677/// # extern crate hyper;
9678/// # extern crate hyper_rustls;
9679/// # extern crate yup_oauth2 as oauth2;
9680/// # extern crate google_admin1_directory as admin1_directory;
9681/// use admin1_directory::Group;
9682/// # #[test] fn egal() {
9683/// # use std::default::Default;
9684/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
9685/// # use admin1_directory::Directory;
9686/// 
9687/// # let secret: ApplicationSecret = Default::default();
9688/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
9689/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
9690/// #                               <MemoryStorage as Default>::default(), None);
9691/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
9692/// // As the method needs a request, you would usually fill it with the desired information
9693/// // into the respective structure. Some of the parts shown here might not be applicable !
9694/// // Values shown here are possibly random and not representative !
9695/// let mut req = Group::default();
9696/// 
9697/// // You can configure optional parameters by calling the respective setters at will, and
9698/// // execute the final call using `doit()`.
9699/// // Values shown here are possibly random and not representative !
9700/// let result = hub.groups().insert(req)
9701///              .doit();
9702/// # }
9703/// ```
9704pub struct GroupInsertCall<'a, C, A>
9705    where C: 'a, A: 'a {
9706
9707    hub: &'a Directory<C, A>,
9708    _request: Group,
9709    _delegate: Option<&'a mut dyn Delegate>,
9710    _additional_params: HashMap<String, String>,
9711    _scopes: BTreeMap<String, ()>
9712}
9713
9714impl<'a, C, A> CallBuilder for GroupInsertCall<'a, C, A> {}
9715
9716impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
9717
9718
9719    /// Perform the operation you have build so far.
9720    pub fn doit(mut self) -> Result<(hyper::client::Response, Group)> {
9721        use std::io::{Read, Seek};
9722        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
9723        let mut dd = DefaultDelegate;
9724        let mut dlg: &mut dyn Delegate = match self._delegate {
9725            Some(d) => d,
9726            None => &mut dd
9727        };
9728        dlg.begin(MethodInfo { id: "directory.groups.insert",
9729                               http_method: hyper::method::Method::Post });
9730        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
9731        for &field in ["alt"].iter() {
9732            if self._additional_params.contains_key(field) {
9733                dlg.finished(false);
9734                return Err(Error::FieldClash(field));
9735            }
9736        }
9737        for (name, value) in self._additional_params.iter() {
9738            params.push((&name, value.clone()));
9739        }
9740
9741        params.push(("alt", "json".to_string()));
9742
9743        let mut url = self.hub._base_url.clone() + "groups";
9744        if self._scopes.len() == 0 {
9745            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
9746        }
9747
9748
9749        let url = hyper::Url::parse_with_params(&url, params).unwrap();
9750
9751        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
9752        let mut request_value_reader =
9753            {
9754                let mut value = json::value::to_value(&self._request).expect("serde to work");
9755                remove_json_null_values(&mut value);
9756                let mut dst = io::Cursor::new(Vec::with_capacity(128));
9757                json::to_writer(&mut dst, &value).unwrap();
9758                dst
9759            };
9760        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
9761        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
9762
9763
9764        loop {
9765            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
9766                Ok(token) => token,
9767                Err(err) => {
9768                    match  dlg.token(&*err) {
9769                        Some(token) => token,
9770                        None => {
9771                            dlg.finished(false);
9772                            return Err(Error::MissingToken(err))
9773                        }
9774                    }
9775                }
9776            };
9777            let auth_header = Authorization(Bearer { token: token.access_token });
9778            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
9779            let mut req_result = {
9780                let mut client = &mut *self.hub.client.borrow_mut();
9781                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
9782                    .header(UserAgent(self.hub._user_agent.clone()))
9783                    .header(auth_header.clone())
9784                    .header(ContentType(json_mime_type.clone()))
9785                    .header(ContentLength(request_size as u64))
9786                    .body(&mut request_value_reader);
9787
9788                dlg.pre_request();
9789                req.send()
9790            };
9791
9792            match req_result {
9793                Err(err) => {
9794                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
9795                        sleep(d);
9796                        continue;
9797                    }
9798                    dlg.finished(false);
9799                    return Err(Error::HttpError(err))
9800                }
9801                Ok(mut res) => {
9802                    if !res.status.is_success() {
9803                        let mut json_err = String::new();
9804                        res.read_to_string(&mut json_err).unwrap();
9805                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
9806                                                              json::from_str(&json_err).ok(),
9807                                                              json::from_str(&json_err).ok()) {
9808                            sleep(d);
9809                            continue;
9810                        }
9811                        dlg.finished(false);
9812                        return match json::from_str::<ErrorResponse>(&json_err){
9813                            Err(_) => Err(Error::Failure(res)),
9814                            Ok(serr) => Err(Error::BadRequest(serr))
9815                        }
9816                    }
9817                    let result_value = {
9818                        let mut json_response = String::new();
9819                        res.read_to_string(&mut json_response).unwrap();
9820                        match json::from_str(&json_response) {
9821                            Ok(decoded) => (res, decoded),
9822                            Err(err) => {
9823                                dlg.response_json_decode_error(&json_response, &err);
9824                                return Err(Error::JsonDecodeError(json_response, err));
9825                            }
9826                        }
9827                    };
9828
9829                    dlg.finished(true);
9830                    return Ok(result_value)
9831                }
9832            }
9833        }
9834    }
9835
9836
9837    ///
9838    /// Sets the *request* property to the given value.
9839    ///
9840    /// Even though the property as already been set when instantiating this call,
9841    /// we provide this method for API completeness.
9842    pub fn request(mut self, new_value: Group) -> GroupInsertCall<'a, C, A> {
9843        self._request = new_value;
9844        self
9845    }
9846    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9847    /// while executing the actual API request.
9848    /// 
9849    /// It should be used to handle progress information, and to implement a certain level of resilience.
9850    ///
9851    /// Sets the *delegate* property to the given value.
9852    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupInsertCall<'a, C, A> {
9853        self._delegate = Some(new_value);
9854        self
9855    }
9856
9857    /// Set any additional parameter of the query string used in the request.
9858    /// It should be used to set parameters which are not yet available through their own
9859    /// setters.
9860    ///
9861    /// Please note that this method must not be used to set any of the known parameters
9862    /// which have their own setter method. If done anyway, the request will fail.
9863    ///
9864    /// # Additional Parameters
9865    ///
9866    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9867    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9868    /// * *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.
9869    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9870    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9871    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9872    /// * *alt* (query-string) - Data format for the response.
9873    pub fn param<T>(mut self, name: T, value: T) -> GroupInsertCall<'a, C, A>
9874                                                        where T: AsRef<str> {
9875        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
9876        self
9877    }
9878
9879    /// Identifies the authorization scope for the method you are building.
9880    ///
9881    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9882    /// `Scope::DirectoryGroup`.
9883    ///
9884    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9885    /// tokens for more than one scope.
9886    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9887    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9888    /// function for details).
9889    ///
9890    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9891    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9892    /// sufficient, a read-write scope will do as well.
9893    pub fn add_scope<T, S>(mut self, scope: T) -> GroupInsertCall<'a, C, A>
9894                                                        where T: Into<Option<S>>,
9895                                                              S: AsRef<str> {
9896        match scope.into() {
9897          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9898          None => None,
9899        };
9900        self
9901    }
9902}
9903
9904
9905/// Add a alias for the group
9906///
9907/// A builder for the *aliases.insert* method supported by a *group* resource.
9908/// It is not used directly, but through a `GroupMethods` instance.
9909///
9910/// # Example
9911///
9912/// Instantiate a resource method builder
9913///
9914/// ```test_harness,no_run
9915/// # extern crate hyper;
9916/// # extern crate hyper_rustls;
9917/// # extern crate yup_oauth2 as oauth2;
9918/// # extern crate google_admin1_directory as admin1_directory;
9919/// use admin1_directory::Alias;
9920/// # #[test] fn egal() {
9921/// # use std::default::Default;
9922/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
9923/// # use admin1_directory::Directory;
9924/// 
9925/// # let secret: ApplicationSecret = Default::default();
9926/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
9927/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
9928/// #                               <MemoryStorage as Default>::default(), None);
9929/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
9930/// // As the method needs a request, you would usually fill it with the desired information
9931/// // into the respective structure. Some of the parts shown here might not be applicable !
9932/// // Values shown here are possibly random and not representative !
9933/// let mut req = Alias::default();
9934/// 
9935/// // You can configure optional parameters by calling the respective setters at will, and
9936/// // execute the final call using `doit()`.
9937/// // Values shown here are possibly random and not representative !
9938/// let result = hub.groups().aliases_insert(req, "groupKey")
9939///              .doit();
9940/// # }
9941/// ```
9942pub struct GroupAliaseInsertCall<'a, C, A>
9943    where C: 'a, A: 'a {
9944
9945    hub: &'a Directory<C, A>,
9946    _request: Alias,
9947    _group_key: String,
9948    _delegate: Option<&'a mut dyn Delegate>,
9949    _additional_params: HashMap<String, String>,
9950    _scopes: BTreeMap<String, ()>
9951}
9952
9953impl<'a, C, A> CallBuilder for GroupAliaseInsertCall<'a, C, A> {}
9954
9955impl<'a, C, A> GroupAliaseInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
9956
9957
9958    /// Perform the operation you have build so far.
9959    pub fn doit(mut self) -> Result<(hyper::client::Response, Alias)> {
9960        use std::io::{Read, Seek};
9961        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
9962        let mut dd = DefaultDelegate;
9963        let mut dlg: &mut dyn Delegate = match self._delegate {
9964            Some(d) => d,
9965            None => &mut dd
9966        };
9967        dlg.begin(MethodInfo { id: "directory.groups.aliases.insert",
9968                               http_method: hyper::method::Method::Post });
9969        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
9970        params.push(("groupKey", self._group_key.to_string()));
9971        for &field in ["alt", "groupKey"].iter() {
9972            if self._additional_params.contains_key(field) {
9973                dlg.finished(false);
9974                return Err(Error::FieldClash(field));
9975            }
9976        }
9977        for (name, value) in self._additional_params.iter() {
9978            params.push((&name, value.clone()));
9979        }
9980
9981        params.push(("alt", "json".to_string()));
9982
9983        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/aliases";
9984        if self._scopes.len() == 0 {
9985            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
9986        }
9987
9988        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
9989            let mut replace_with: Option<&str> = None;
9990            for &(name, ref value) in params.iter() {
9991                if name == param_name {
9992                    replace_with = Some(value);
9993                    break;
9994                }
9995            }
9996            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
9997        }
9998        {
9999            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
10000            for param_name in ["groupKey"].iter() {
10001                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
10002                    indices_for_removal.push(index);
10003                }
10004            }
10005            for &index in indices_for_removal.iter() {
10006                params.remove(index);
10007            }
10008        }
10009
10010        let url = hyper::Url::parse_with_params(&url, params).unwrap();
10011
10012        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
10013        let mut request_value_reader =
10014            {
10015                let mut value = json::value::to_value(&self._request).expect("serde to work");
10016                remove_json_null_values(&mut value);
10017                let mut dst = io::Cursor::new(Vec::with_capacity(128));
10018                json::to_writer(&mut dst, &value).unwrap();
10019                dst
10020            };
10021        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
10022        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
10023
10024
10025        loop {
10026            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
10027                Ok(token) => token,
10028                Err(err) => {
10029                    match  dlg.token(&*err) {
10030                        Some(token) => token,
10031                        None => {
10032                            dlg.finished(false);
10033                            return Err(Error::MissingToken(err))
10034                        }
10035                    }
10036                }
10037            };
10038            let auth_header = Authorization(Bearer { token: token.access_token });
10039            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
10040            let mut req_result = {
10041                let mut client = &mut *self.hub.client.borrow_mut();
10042                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
10043                    .header(UserAgent(self.hub._user_agent.clone()))
10044                    .header(auth_header.clone())
10045                    .header(ContentType(json_mime_type.clone()))
10046                    .header(ContentLength(request_size as u64))
10047                    .body(&mut request_value_reader);
10048
10049                dlg.pre_request();
10050                req.send()
10051            };
10052
10053            match req_result {
10054                Err(err) => {
10055                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
10056                        sleep(d);
10057                        continue;
10058                    }
10059                    dlg.finished(false);
10060                    return Err(Error::HttpError(err))
10061                }
10062                Ok(mut res) => {
10063                    if !res.status.is_success() {
10064                        let mut json_err = String::new();
10065                        res.read_to_string(&mut json_err).unwrap();
10066                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
10067                                                              json::from_str(&json_err).ok(),
10068                                                              json::from_str(&json_err).ok()) {
10069                            sleep(d);
10070                            continue;
10071                        }
10072                        dlg.finished(false);
10073                        return match json::from_str::<ErrorResponse>(&json_err){
10074                            Err(_) => Err(Error::Failure(res)),
10075                            Ok(serr) => Err(Error::BadRequest(serr))
10076                        }
10077                    }
10078                    let result_value = {
10079                        let mut json_response = String::new();
10080                        res.read_to_string(&mut json_response).unwrap();
10081                        match json::from_str(&json_response) {
10082                            Ok(decoded) => (res, decoded),
10083                            Err(err) => {
10084                                dlg.response_json_decode_error(&json_response, &err);
10085                                return Err(Error::JsonDecodeError(json_response, err));
10086                            }
10087                        }
10088                    };
10089
10090                    dlg.finished(true);
10091                    return Ok(result_value)
10092                }
10093            }
10094        }
10095    }
10096
10097
10098    ///
10099    /// Sets the *request* property to the given value.
10100    ///
10101    /// Even though the property as already been set when instantiating this call,
10102    /// we provide this method for API completeness.
10103    pub fn request(mut self, new_value: Alias) -> GroupAliaseInsertCall<'a, C, A> {
10104        self._request = new_value;
10105        self
10106    }
10107    /// Email or immutable ID of the group
10108    ///
10109    /// Sets the *group key* path property to the given value.
10110    ///
10111    /// Even though the property as already been set when instantiating this call,
10112    /// we provide this method for API completeness.
10113    pub fn group_key(mut self, new_value: &str) -> GroupAliaseInsertCall<'a, C, A> {
10114        self._group_key = new_value.to_string();
10115        self
10116    }
10117    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10118    /// while executing the actual API request.
10119    /// 
10120    /// It should be used to handle progress information, and to implement a certain level of resilience.
10121    ///
10122    /// Sets the *delegate* property to the given value.
10123    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupAliaseInsertCall<'a, C, A> {
10124        self._delegate = Some(new_value);
10125        self
10126    }
10127
10128    /// Set any additional parameter of the query string used in the request.
10129    /// It should be used to set parameters which are not yet available through their own
10130    /// setters.
10131    ///
10132    /// Please note that this method must not be used to set any of the known parameters
10133    /// which have their own setter method. If done anyway, the request will fail.
10134    ///
10135    /// # Additional Parameters
10136    ///
10137    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10138    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10139    /// * *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.
10140    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10141    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10142    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10143    /// * *alt* (query-string) - Data format for the response.
10144    pub fn param<T>(mut self, name: T, value: T) -> GroupAliaseInsertCall<'a, C, A>
10145                                                        where T: AsRef<str> {
10146        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
10147        self
10148    }
10149
10150    /// Identifies the authorization scope for the method you are building.
10151    ///
10152    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
10153    /// `Scope::DirectoryGroup`.
10154    ///
10155    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10156    /// tokens for more than one scope.
10157    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
10158    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
10159    /// function for details).
10160    ///
10161    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10162    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10163    /// sufficient, a read-write scope will do as well.
10164    pub fn add_scope<T, S>(mut self, scope: T) -> GroupAliaseInsertCall<'a, C, A>
10165                                                        where T: Into<Option<S>>,
10166                                                              S: AsRef<str> {
10167        match scope.into() {
10168          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
10169          None => None,
10170        };
10171        self
10172    }
10173}
10174
10175
10176/// List all aliases for a group
10177///
10178/// A builder for the *aliases.list* method supported by a *group* resource.
10179/// It is not used directly, but through a `GroupMethods` instance.
10180///
10181/// # Example
10182///
10183/// Instantiate a resource method builder
10184///
10185/// ```test_harness,no_run
10186/// # extern crate hyper;
10187/// # extern crate hyper_rustls;
10188/// # extern crate yup_oauth2 as oauth2;
10189/// # extern crate google_admin1_directory as admin1_directory;
10190/// # #[test] fn egal() {
10191/// # use std::default::Default;
10192/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
10193/// # use admin1_directory::Directory;
10194/// 
10195/// # let secret: ApplicationSecret = Default::default();
10196/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
10197/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
10198/// #                               <MemoryStorage as Default>::default(), None);
10199/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
10200/// // You can configure optional parameters by calling the respective setters at will, and
10201/// // execute the final call using `doit()`.
10202/// // Values shown here are possibly random and not representative !
10203/// let result = hub.groups().aliases_list("groupKey")
10204///              .doit();
10205/// # }
10206/// ```
10207pub struct GroupAliaseListCall<'a, C, A>
10208    where C: 'a, A: 'a {
10209
10210    hub: &'a Directory<C, A>,
10211    _group_key: String,
10212    _delegate: Option<&'a mut dyn Delegate>,
10213    _additional_params: HashMap<String, String>,
10214    _scopes: BTreeMap<String, ()>
10215}
10216
10217impl<'a, C, A> CallBuilder for GroupAliaseListCall<'a, C, A> {}
10218
10219impl<'a, C, A> GroupAliaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
10220
10221
10222    /// Perform the operation you have build so far.
10223    pub fn doit(mut self) -> Result<(hyper::client::Response, Aliases)> {
10224        use std::io::{Read, Seek};
10225        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
10226        let mut dd = DefaultDelegate;
10227        let mut dlg: &mut dyn Delegate = match self._delegate {
10228            Some(d) => d,
10229            None => &mut dd
10230        };
10231        dlg.begin(MethodInfo { id: "directory.groups.aliases.list",
10232                               http_method: hyper::method::Method::Get });
10233        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
10234        params.push(("groupKey", self._group_key.to_string()));
10235        for &field in ["alt", "groupKey"].iter() {
10236            if self._additional_params.contains_key(field) {
10237                dlg.finished(false);
10238                return Err(Error::FieldClash(field));
10239            }
10240        }
10241        for (name, value) in self._additional_params.iter() {
10242            params.push((&name, value.clone()));
10243        }
10244
10245        params.push(("alt", "json".to_string()));
10246
10247        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/aliases";
10248        if self._scopes.len() == 0 {
10249            self._scopes.insert(Scope::DirectoryGroupReadonly.as_ref().to_string(), ());
10250        }
10251
10252        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
10253            let mut replace_with: Option<&str> = None;
10254            for &(name, ref value) in params.iter() {
10255                if name == param_name {
10256                    replace_with = Some(value);
10257                    break;
10258                }
10259            }
10260            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
10261        }
10262        {
10263            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
10264            for param_name in ["groupKey"].iter() {
10265                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
10266                    indices_for_removal.push(index);
10267                }
10268            }
10269            for &index in indices_for_removal.iter() {
10270                params.remove(index);
10271            }
10272        }
10273
10274        let url = hyper::Url::parse_with_params(&url, params).unwrap();
10275
10276
10277
10278        loop {
10279            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
10280                Ok(token) => token,
10281                Err(err) => {
10282                    match  dlg.token(&*err) {
10283                        Some(token) => token,
10284                        None => {
10285                            dlg.finished(false);
10286                            return Err(Error::MissingToken(err))
10287                        }
10288                    }
10289                }
10290            };
10291            let auth_header = Authorization(Bearer { token: token.access_token });
10292            let mut req_result = {
10293                let mut client = &mut *self.hub.client.borrow_mut();
10294                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
10295                    .header(UserAgent(self.hub._user_agent.clone()))
10296                    .header(auth_header.clone());
10297
10298                dlg.pre_request();
10299                req.send()
10300            };
10301
10302            match req_result {
10303                Err(err) => {
10304                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
10305                        sleep(d);
10306                        continue;
10307                    }
10308                    dlg.finished(false);
10309                    return Err(Error::HttpError(err))
10310                }
10311                Ok(mut res) => {
10312                    if !res.status.is_success() {
10313                        let mut json_err = String::new();
10314                        res.read_to_string(&mut json_err).unwrap();
10315                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
10316                                                              json::from_str(&json_err).ok(),
10317                                                              json::from_str(&json_err).ok()) {
10318                            sleep(d);
10319                            continue;
10320                        }
10321                        dlg.finished(false);
10322                        return match json::from_str::<ErrorResponse>(&json_err){
10323                            Err(_) => Err(Error::Failure(res)),
10324                            Ok(serr) => Err(Error::BadRequest(serr))
10325                        }
10326                    }
10327                    let result_value = {
10328                        let mut json_response = String::new();
10329                        res.read_to_string(&mut json_response).unwrap();
10330                        match json::from_str(&json_response) {
10331                            Ok(decoded) => (res, decoded),
10332                            Err(err) => {
10333                                dlg.response_json_decode_error(&json_response, &err);
10334                                return Err(Error::JsonDecodeError(json_response, err));
10335                            }
10336                        }
10337                    };
10338
10339                    dlg.finished(true);
10340                    return Ok(result_value)
10341                }
10342            }
10343        }
10344    }
10345
10346
10347    /// Email or immutable ID of the group
10348    ///
10349    /// Sets the *group key* path property to the given value.
10350    ///
10351    /// Even though the property as already been set when instantiating this call,
10352    /// we provide this method for API completeness.
10353    pub fn group_key(mut self, new_value: &str) -> GroupAliaseListCall<'a, C, A> {
10354        self._group_key = new_value.to_string();
10355        self
10356    }
10357    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10358    /// while executing the actual API request.
10359    /// 
10360    /// It should be used to handle progress information, and to implement a certain level of resilience.
10361    ///
10362    /// Sets the *delegate* property to the given value.
10363    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupAliaseListCall<'a, C, A> {
10364        self._delegate = Some(new_value);
10365        self
10366    }
10367
10368    /// Set any additional parameter of the query string used in the request.
10369    /// It should be used to set parameters which are not yet available through their own
10370    /// setters.
10371    ///
10372    /// Please note that this method must not be used to set any of the known parameters
10373    /// which have their own setter method. If done anyway, the request will fail.
10374    ///
10375    /// # Additional Parameters
10376    ///
10377    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10378    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10379    /// * *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.
10380    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10381    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10382    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10383    /// * *alt* (query-string) - Data format for the response.
10384    pub fn param<T>(mut self, name: T, value: T) -> GroupAliaseListCall<'a, C, A>
10385                                                        where T: AsRef<str> {
10386        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
10387        self
10388    }
10389
10390    /// Identifies the authorization scope for the method you are building.
10391    ///
10392    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
10393    /// `Scope::DirectoryGroupReadonly`.
10394    ///
10395    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10396    /// tokens for more than one scope.
10397    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
10398    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
10399    /// function for details).
10400    ///
10401    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10402    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10403    /// sufficient, a read-write scope will do as well.
10404    pub fn add_scope<T, S>(mut self, scope: T) -> GroupAliaseListCall<'a, C, A>
10405                                                        where T: Into<Option<S>>,
10406                                                              S: AsRef<str> {
10407        match scope.into() {
10408          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
10409          None => None,
10410        };
10411        self
10412    }
10413}
10414
10415
10416/// Retrieve Group
10417///
10418/// A builder for the *get* method supported by a *group* resource.
10419/// It is not used directly, but through a `GroupMethods` instance.
10420///
10421/// # Example
10422///
10423/// Instantiate a resource method builder
10424///
10425/// ```test_harness,no_run
10426/// # extern crate hyper;
10427/// # extern crate hyper_rustls;
10428/// # extern crate yup_oauth2 as oauth2;
10429/// # extern crate google_admin1_directory as admin1_directory;
10430/// # #[test] fn egal() {
10431/// # use std::default::Default;
10432/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
10433/// # use admin1_directory::Directory;
10434/// 
10435/// # let secret: ApplicationSecret = Default::default();
10436/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
10437/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
10438/// #                               <MemoryStorage as Default>::default(), None);
10439/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
10440/// // You can configure optional parameters by calling the respective setters at will, and
10441/// // execute the final call using `doit()`.
10442/// // Values shown here are possibly random and not representative !
10443/// let result = hub.groups().get("groupKey")
10444///              .doit();
10445/// # }
10446/// ```
10447pub struct GroupGetCall<'a, C, A>
10448    where C: 'a, A: 'a {
10449
10450    hub: &'a Directory<C, A>,
10451    _group_key: String,
10452    _delegate: Option<&'a mut dyn Delegate>,
10453    _additional_params: HashMap<String, String>,
10454    _scopes: BTreeMap<String, ()>
10455}
10456
10457impl<'a, C, A> CallBuilder for GroupGetCall<'a, C, A> {}
10458
10459impl<'a, C, A> GroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
10460
10461
10462    /// Perform the operation you have build so far.
10463    pub fn doit(mut self) -> Result<(hyper::client::Response, Group)> {
10464        use std::io::{Read, Seek};
10465        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
10466        let mut dd = DefaultDelegate;
10467        let mut dlg: &mut dyn Delegate = match self._delegate {
10468            Some(d) => d,
10469            None => &mut dd
10470        };
10471        dlg.begin(MethodInfo { id: "directory.groups.get",
10472                               http_method: hyper::method::Method::Get });
10473        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
10474        params.push(("groupKey", self._group_key.to_string()));
10475        for &field in ["alt", "groupKey"].iter() {
10476            if self._additional_params.contains_key(field) {
10477                dlg.finished(false);
10478                return Err(Error::FieldClash(field));
10479            }
10480        }
10481        for (name, value) in self._additional_params.iter() {
10482            params.push((&name, value.clone()));
10483        }
10484
10485        params.push(("alt", "json".to_string()));
10486
10487        let mut url = self.hub._base_url.clone() + "groups/{groupKey}";
10488        if self._scopes.len() == 0 {
10489            self._scopes.insert(Scope::DirectoryGroupReadonly.as_ref().to_string(), ());
10490        }
10491
10492        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
10493            let mut replace_with: Option<&str> = None;
10494            for &(name, ref value) in params.iter() {
10495                if name == param_name {
10496                    replace_with = Some(value);
10497                    break;
10498                }
10499            }
10500            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
10501        }
10502        {
10503            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
10504            for param_name in ["groupKey"].iter() {
10505                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
10506                    indices_for_removal.push(index);
10507                }
10508            }
10509            for &index in indices_for_removal.iter() {
10510                params.remove(index);
10511            }
10512        }
10513
10514        let url = hyper::Url::parse_with_params(&url, params).unwrap();
10515
10516
10517
10518        loop {
10519            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
10520                Ok(token) => token,
10521                Err(err) => {
10522                    match  dlg.token(&*err) {
10523                        Some(token) => token,
10524                        None => {
10525                            dlg.finished(false);
10526                            return Err(Error::MissingToken(err))
10527                        }
10528                    }
10529                }
10530            };
10531            let auth_header = Authorization(Bearer { token: token.access_token });
10532            let mut req_result = {
10533                let mut client = &mut *self.hub.client.borrow_mut();
10534                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
10535                    .header(UserAgent(self.hub._user_agent.clone()))
10536                    .header(auth_header.clone());
10537
10538                dlg.pre_request();
10539                req.send()
10540            };
10541
10542            match req_result {
10543                Err(err) => {
10544                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
10545                        sleep(d);
10546                        continue;
10547                    }
10548                    dlg.finished(false);
10549                    return Err(Error::HttpError(err))
10550                }
10551                Ok(mut res) => {
10552                    if !res.status.is_success() {
10553                        let mut json_err = String::new();
10554                        res.read_to_string(&mut json_err).unwrap();
10555                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
10556                                                              json::from_str(&json_err).ok(),
10557                                                              json::from_str(&json_err).ok()) {
10558                            sleep(d);
10559                            continue;
10560                        }
10561                        dlg.finished(false);
10562                        return match json::from_str::<ErrorResponse>(&json_err){
10563                            Err(_) => Err(Error::Failure(res)),
10564                            Ok(serr) => Err(Error::BadRequest(serr))
10565                        }
10566                    }
10567                    let result_value = {
10568                        let mut json_response = String::new();
10569                        res.read_to_string(&mut json_response).unwrap();
10570                        match json::from_str(&json_response) {
10571                            Ok(decoded) => (res, decoded),
10572                            Err(err) => {
10573                                dlg.response_json_decode_error(&json_response, &err);
10574                                return Err(Error::JsonDecodeError(json_response, err));
10575                            }
10576                        }
10577                    };
10578
10579                    dlg.finished(true);
10580                    return Ok(result_value)
10581                }
10582            }
10583        }
10584    }
10585
10586
10587    /// Email or immutable ID of the group
10588    ///
10589    /// Sets the *group key* path property to the given value.
10590    ///
10591    /// Even though the property as already been set when instantiating this call,
10592    /// we provide this method for API completeness.
10593    pub fn group_key(mut self, new_value: &str) -> GroupGetCall<'a, C, A> {
10594        self._group_key = new_value.to_string();
10595        self
10596    }
10597    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10598    /// while executing the actual API request.
10599    /// 
10600    /// It should be used to handle progress information, and to implement a certain level of resilience.
10601    ///
10602    /// Sets the *delegate* property to the given value.
10603    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupGetCall<'a, C, A> {
10604        self._delegate = Some(new_value);
10605        self
10606    }
10607
10608    /// Set any additional parameter of the query string used in the request.
10609    /// It should be used to set parameters which are not yet available through their own
10610    /// setters.
10611    ///
10612    /// Please note that this method must not be used to set any of the known parameters
10613    /// which have their own setter method. If done anyway, the request will fail.
10614    ///
10615    /// # Additional Parameters
10616    ///
10617    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10618    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10619    /// * *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.
10620    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10621    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10622    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10623    /// * *alt* (query-string) - Data format for the response.
10624    pub fn param<T>(mut self, name: T, value: T) -> GroupGetCall<'a, C, A>
10625                                                        where T: AsRef<str> {
10626        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
10627        self
10628    }
10629
10630    /// Identifies the authorization scope for the method you are building.
10631    ///
10632    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
10633    /// `Scope::DirectoryGroupReadonly`.
10634    ///
10635    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10636    /// tokens for more than one scope.
10637    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
10638    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
10639    /// function for details).
10640    ///
10641    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10642    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10643    /// sufficient, a read-write scope will do as well.
10644    pub fn add_scope<T, S>(mut self, scope: T) -> GroupGetCall<'a, C, A>
10645                                                        where T: Into<Option<S>>,
10646                                                              S: AsRef<str> {
10647        match scope.into() {
10648          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
10649          None => None,
10650        };
10651        self
10652    }
10653}
10654
10655
10656/// Update Group. This method supports patch semantics.
10657///
10658/// A builder for the *patch* method supported by a *group* resource.
10659/// It is not used directly, but through a `GroupMethods` instance.
10660///
10661/// # Example
10662///
10663/// Instantiate a resource method builder
10664///
10665/// ```test_harness,no_run
10666/// # extern crate hyper;
10667/// # extern crate hyper_rustls;
10668/// # extern crate yup_oauth2 as oauth2;
10669/// # extern crate google_admin1_directory as admin1_directory;
10670/// use admin1_directory::Group;
10671/// # #[test] fn egal() {
10672/// # use std::default::Default;
10673/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
10674/// # use admin1_directory::Directory;
10675/// 
10676/// # let secret: ApplicationSecret = Default::default();
10677/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
10678/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
10679/// #                               <MemoryStorage as Default>::default(), None);
10680/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
10681/// // As the method needs a request, you would usually fill it with the desired information
10682/// // into the respective structure. Some of the parts shown here might not be applicable !
10683/// // Values shown here are possibly random and not representative !
10684/// let mut req = Group::default();
10685/// 
10686/// // You can configure optional parameters by calling the respective setters at will, and
10687/// // execute the final call using `doit()`.
10688/// // Values shown here are possibly random and not representative !
10689/// let result = hub.groups().patch(req, "groupKey")
10690///              .doit();
10691/// # }
10692/// ```
10693pub struct GroupPatchCall<'a, C, A>
10694    where C: 'a, A: 'a {
10695
10696    hub: &'a Directory<C, A>,
10697    _request: Group,
10698    _group_key: String,
10699    _delegate: Option<&'a mut dyn Delegate>,
10700    _additional_params: HashMap<String, String>,
10701    _scopes: BTreeMap<String, ()>
10702}
10703
10704impl<'a, C, A> CallBuilder for GroupPatchCall<'a, C, A> {}
10705
10706impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
10707
10708
10709    /// Perform the operation you have build so far.
10710    pub fn doit(mut self) -> Result<(hyper::client::Response, Group)> {
10711        use std::io::{Read, Seek};
10712        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
10713        let mut dd = DefaultDelegate;
10714        let mut dlg: &mut dyn Delegate = match self._delegate {
10715            Some(d) => d,
10716            None => &mut dd
10717        };
10718        dlg.begin(MethodInfo { id: "directory.groups.patch",
10719                               http_method: hyper::method::Method::Patch });
10720        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
10721        params.push(("groupKey", self._group_key.to_string()));
10722        for &field in ["alt", "groupKey"].iter() {
10723            if self._additional_params.contains_key(field) {
10724                dlg.finished(false);
10725                return Err(Error::FieldClash(field));
10726            }
10727        }
10728        for (name, value) in self._additional_params.iter() {
10729            params.push((&name, value.clone()));
10730        }
10731
10732        params.push(("alt", "json".to_string()));
10733
10734        let mut url = self.hub._base_url.clone() + "groups/{groupKey}";
10735        if self._scopes.len() == 0 {
10736            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
10737        }
10738
10739        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
10740            let mut replace_with: Option<&str> = None;
10741            for &(name, ref value) in params.iter() {
10742                if name == param_name {
10743                    replace_with = Some(value);
10744                    break;
10745                }
10746            }
10747            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
10748        }
10749        {
10750            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
10751            for param_name in ["groupKey"].iter() {
10752                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
10753                    indices_for_removal.push(index);
10754                }
10755            }
10756            for &index in indices_for_removal.iter() {
10757                params.remove(index);
10758            }
10759        }
10760
10761        let url = hyper::Url::parse_with_params(&url, params).unwrap();
10762
10763        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
10764        let mut request_value_reader =
10765            {
10766                let mut value = json::value::to_value(&self._request).expect("serde to work");
10767                remove_json_null_values(&mut value);
10768                let mut dst = io::Cursor::new(Vec::with_capacity(128));
10769                json::to_writer(&mut dst, &value).unwrap();
10770                dst
10771            };
10772        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
10773        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
10774
10775
10776        loop {
10777            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
10778                Ok(token) => token,
10779                Err(err) => {
10780                    match  dlg.token(&*err) {
10781                        Some(token) => token,
10782                        None => {
10783                            dlg.finished(false);
10784                            return Err(Error::MissingToken(err))
10785                        }
10786                    }
10787                }
10788            };
10789            let auth_header = Authorization(Bearer { token: token.access_token });
10790            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
10791            let mut req_result = {
10792                let mut client = &mut *self.hub.client.borrow_mut();
10793                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
10794                    .header(UserAgent(self.hub._user_agent.clone()))
10795                    .header(auth_header.clone())
10796                    .header(ContentType(json_mime_type.clone()))
10797                    .header(ContentLength(request_size as u64))
10798                    .body(&mut request_value_reader);
10799
10800                dlg.pre_request();
10801                req.send()
10802            };
10803
10804            match req_result {
10805                Err(err) => {
10806                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
10807                        sleep(d);
10808                        continue;
10809                    }
10810                    dlg.finished(false);
10811                    return Err(Error::HttpError(err))
10812                }
10813                Ok(mut res) => {
10814                    if !res.status.is_success() {
10815                        let mut json_err = String::new();
10816                        res.read_to_string(&mut json_err).unwrap();
10817                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
10818                                                              json::from_str(&json_err).ok(),
10819                                                              json::from_str(&json_err).ok()) {
10820                            sleep(d);
10821                            continue;
10822                        }
10823                        dlg.finished(false);
10824                        return match json::from_str::<ErrorResponse>(&json_err){
10825                            Err(_) => Err(Error::Failure(res)),
10826                            Ok(serr) => Err(Error::BadRequest(serr))
10827                        }
10828                    }
10829                    let result_value = {
10830                        let mut json_response = String::new();
10831                        res.read_to_string(&mut json_response).unwrap();
10832                        match json::from_str(&json_response) {
10833                            Ok(decoded) => (res, decoded),
10834                            Err(err) => {
10835                                dlg.response_json_decode_error(&json_response, &err);
10836                                return Err(Error::JsonDecodeError(json_response, err));
10837                            }
10838                        }
10839                    };
10840
10841                    dlg.finished(true);
10842                    return Ok(result_value)
10843                }
10844            }
10845        }
10846    }
10847
10848
10849    ///
10850    /// Sets the *request* property to the given value.
10851    ///
10852    /// Even though the property as already been set when instantiating this call,
10853    /// we provide this method for API completeness.
10854    pub fn request(mut self, new_value: Group) -> GroupPatchCall<'a, C, A> {
10855        self._request = new_value;
10856        self
10857    }
10858    /// Email or immutable ID of the group. If ID, it should match with id of group object
10859    ///
10860    /// Sets the *group key* path property to the given value.
10861    ///
10862    /// Even though the property as already been set when instantiating this call,
10863    /// we provide this method for API completeness.
10864    pub fn group_key(mut self, new_value: &str) -> GroupPatchCall<'a, C, A> {
10865        self._group_key = new_value.to_string();
10866        self
10867    }
10868    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10869    /// while executing the actual API request.
10870    /// 
10871    /// It should be used to handle progress information, and to implement a certain level of resilience.
10872    ///
10873    /// Sets the *delegate* property to the given value.
10874    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupPatchCall<'a, C, A> {
10875        self._delegate = Some(new_value);
10876        self
10877    }
10878
10879    /// Set any additional parameter of the query string used in the request.
10880    /// It should be used to set parameters which are not yet available through their own
10881    /// setters.
10882    ///
10883    /// Please note that this method must not be used to set any of the known parameters
10884    /// which have their own setter method. If done anyway, the request will fail.
10885    ///
10886    /// # Additional Parameters
10887    ///
10888    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10889    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10890    /// * *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.
10891    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10892    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10893    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10894    /// * *alt* (query-string) - Data format for the response.
10895    pub fn param<T>(mut self, name: T, value: T) -> GroupPatchCall<'a, C, A>
10896                                                        where T: AsRef<str> {
10897        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
10898        self
10899    }
10900
10901    /// Identifies the authorization scope for the method you are building.
10902    ///
10903    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
10904    /// `Scope::DirectoryGroup`.
10905    ///
10906    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10907    /// tokens for more than one scope.
10908    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
10909    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
10910    /// function for details).
10911    ///
10912    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10913    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10914    /// sufficient, a read-write scope will do as well.
10915    pub fn add_scope<T, S>(mut self, scope: T) -> GroupPatchCall<'a, C, A>
10916                                                        where T: Into<Option<S>>,
10917                                                              S: AsRef<str> {
10918        match scope.into() {
10919          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
10920          None => None,
10921        };
10922        self
10923    }
10924}
10925
10926
10927/// Remove a alias for the group
10928///
10929/// A builder for the *aliases.delete* method supported by a *group* resource.
10930/// It is not used directly, but through a `GroupMethods` instance.
10931///
10932/// # Example
10933///
10934/// Instantiate a resource method builder
10935///
10936/// ```test_harness,no_run
10937/// # extern crate hyper;
10938/// # extern crate hyper_rustls;
10939/// # extern crate yup_oauth2 as oauth2;
10940/// # extern crate google_admin1_directory as admin1_directory;
10941/// # #[test] fn egal() {
10942/// # use std::default::Default;
10943/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
10944/// # use admin1_directory::Directory;
10945/// 
10946/// # let secret: ApplicationSecret = Default::default();
10947/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
10948/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
10949/// #                               <MemoryStorage as Default>::default(), None);
10950/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
10951/// // You can configure optional parameters by calling the respective setters at will, and
10952/// // execute the final call using `doit()`.
10953/// // Values shown here are possibly random and not representative !
10954/// let result = hub.groups().aliases_delete("groupKey", "alias")
10955///              .doit();
10956/// # }
10957/// ```
10958pub struct GroupAliaseDeleteCall<'a, C, A>
10959    where C: 'a, A: 'a {
10960
10961    hub: &'a Directory<C, A>,
10962    _group_key: String,
10963    _alias: String,
10964    _delegate: Option<&'a mut dyn Delegate>,
10965    _additional_params: HashMap<String, String>,
10966    _scopes: BTreeMap<String, ()>
10967}
10968
10969impl<'a, C, A> CallBuilder for GroupAliaseDeleteCall<'a, C, A> {}
10970
10971impl<'a, C, A> GroupAliaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
10972
10973
10974    /// Perform the operation you have build so far.
10975    pub fn doit(mut self) -> Result<hyper::client::Response> {
10976        use std::io::{Read, Seek};
10977        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
10978        let mut dd = DefaultDelegate;
10979        let mut dlg: &mut dyn Delegate = match self._delegate {
10980            Some(d) => d,
10981            None => &mut dd
10982        };
10983        dlg.begin(MethodInfo { id: "directory.groups.aliases.delete",
10984                               http_method: hyper::method::Method::Delete });
10985        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
10986        params.push(("groupKey", self._group_key.to_string()));
10987        params.push(("alias", self._alias.to_string()));
10988        for &field in ["groupKey", "alias"].iter() {
10989            if self._additional_params.contains_key(field) {
10990                dlg.finished(false);
10991                return Err(Error::FieldClash(field));
10992            }
10993        }
10994        for (name, value) in self._additional_params.iter() {
10995            params.push((&name, value.clone()));
10996        }
10997
10998
10999        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/aliases/{alias}";
11000        if self._scopes.len() == 0 {
11001            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
11002        }
11003
11004        for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{alias}", "alias")].iter() {
11005            let mut replace_with: Option<&str> = None;
11006            for &(name, ref value) in params.iter() {
11007                if name == param_name {
11008                    replace_with = Some(value);
11009                    break;
11010                }
11011            }
11012            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
11013        }
11014        {
11015            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
11016            for param_name in ["alias", "groupKey"].iter() {
11017                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
11018                    indices_for_removal.push(index);
11019                }
11020            }
11021            for &index in indices_for_removal.iter() {
11022                params.remove(index);
11023            }
11024        }
11025
11026        let url = hyper::Url::parse_with_params(&url, params).unwrap();
11027
11028
11029
11030        loop {
11031            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
11032                Ok(token) => token,
11033                Err(err) => {
11034                    match  dlg.token(&*err) {
11035                        Some(token) => token,
11036                        None => {
11037                            dlg.finished(false);
11038                            return Err(Error::MissingToken(err))
11039                        }
11040                    }
11041                }
11042            };
11043            let auth_header = Authorization(Bearer { token: token.access_token });
11044            let mut req_result = {
11045                let mut client = &mut *self.hub.client.borrow_mut();
11046                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
11047                    .header(UserAgent(self.hub._user_agent.clone()))
11048                    .header(auth_header.clone());
11049
11050                dlg.pre_request();
11051                req.send()
11052            };
11053
11054            match req_result {
11055                Err(err) => {
11056                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
11057                        sleep(d);
11058                        continue;
11059                    }
11060                    dlg.finished(false);
11061                    return Err(Error::HttpError(err))
11062                }
11063                Ok(mut res) => {
11064                    if !res.status.is_success() {
11065                        let mut json_err = String::new();
11066                        res.read_to_string(&mut json_err).unwrap();
11067                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
11068                                                              json::from_str(&json_err).ok(),
11069                                                              json::from_str(&json_err).ok()) {
11070                            sleep(d);
11071                            continue;
11072                        }
11073                        dlg.finished(false);
11074                        return match json::from_str::<ErrorResponse>(&json_err){
11075                            Err(_) => Err(Error::Failure(res)),
11076                            Ok(serr) => Err(Error::BadRequest(serr))
11077                        }
11078                    }
11079                    let result_value = res;
11080
11081                    dlg.finished(true);
11082                    return Ok(result_value)
11083                }
11084            }
11085        }
11086    }
11087
11088
11089    /// Email or immutable ID of the group
11090    ///
11091    /// Sets the *group key* path property to the given value.
11092    ///
11093    /// Even though the property as already been set when instantiating this call,
11094    /// we provide this method for API completeness.
11095    pub fn group_key(mut self, new_value: &str) -> GroupAliaseDeleteCall<'a, C, A> {
11096        self._group_key = new_value.to_string();
11097        self
11098    }
11099    /// The alias to be removed
11100    ///
11101    /// Sets the *alias* path property to the given value.
11102    ///
11103    /// Even though the property as already been set when instantiating this call,
11104    /// we provide this method for API completeness.
11105    pub fn alias(mut self, new_value: &str) -> GroupAliaseDeleteCall<'a, C, A> {
11106        self._alias = new_value.to_string();
11107        self
11108    }
11109    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11110    /// while executing the actual API request.
11111    /// 
11112    /// It should be used to handle progress information, and to implement a certain level of resilience.
11113    ///
11114    /// Sets the *delegate* property to the given value.
11115    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> GroupAliaseDeleteCall<'a, C, A> {
11116        self._delegate = Some(new_value);
11117        self
11118    }
11119
11120    /// Set any additional parameter of the query string used in the request.
11121    /// It should be used to set parameters which are not yet available through their own
11122    /// setters.
11123    ///
11124    /// Please note that this method must not be used to set any of the known parameters
11125    /// which have their own setter method. If done anyway, the request will fail.
11126    ///
11127    /// # Additional Parameters
11128    ///
11129    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11130    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11131    /// * *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.
11132    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11133    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11134    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11135    /// * *alt* (query-string) - Data format for the response.
11136    pub fn param<T>(mut self, name: T, value: T) -> GroupAliaseDeleteCall<'a, C, A>
11137                                                        where T: AsRef<str> {
11138        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
11139        self
11140    }
11141
11142    /// Identifies the authorization scope for the method you are building.
11143    ///
11144    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
11145    /// `Scope::DirectoryGroup`.
11146    ///
11147    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11148    /// tokens for more than one scope.
11149    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
11150    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
11151    /// function for details).
11152    ///
11153    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11154    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11155    /// sufficient, a read-write scope will do as well.
11156    pub fn add_scope<T, S>(mut self, scope: T) -> GroupAliaseDeleteCall<'a, C, A>
11157                                                        where T: Into<Option<S>>,
11158                                                              S: AsRef<str> {
11159        match scope.into() {
11160          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
11161          None => None,
11162        };
11163        self
11164    }
11165}
11166
11167
11168/// Updates a role.
11169///
11170/// A builder for the *update* method supported by a *role* resource.
11171/// It is not used directly, but through a `RoleMethods` instance.
11172///
11173/// # Example
11174///
11175/// Instantiate a resource method builder
11176///
11177/// ```test_harness,no_run
11178/// # extern crate hyper;
11179/// # extern crate hyper_rustls;
11180/// # extern crate yup_oauth2 as oauth2;
11181/// # extern crate google_admin1_directory as admin1_directory;
11182/// use admin1_directory::Role;
11183/// # #[test] fn egal() {
11184/// # use std::default::Default;
11185/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
11186/// # use admin1_directory::Directory;
11187/// 
11188/// # let secret: ApplicationSecret = Default::default();
11189/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
11190/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
11191/// #                               <MemoryStorage as Default>::default(), None);
11192/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
11193/// // As the method needs a request, you would usually fill it with the desired information
11194/// // into the respective structure. Some of the parts shown here might not be applicable !
11195/// // Values shown here are possibly random and not representative !
11196/// let mut req = Role::default();
11197/// 
11198/// // You can configure optional parameters by calling the respective setters at will, and
11199/// // execute the final call using `doit()`.
11200/// // Values shown here are possibly random and not representative !
11201/// let result = hub.roles().update(req, "customer", "roleId")
11202///              .doit();
11203/// # }
11204/// ```
11205pub struct RoleUpdateCall<'a, C, A>
11206    where C: 'a, A: 'a {
11207
11208    hub: &'a Directory<C, A>,
11209    _request: Role,
11210    _customer: String,
11211    _role_id: String,
11212    _delegate: Option<&'a mut dyn Delegate>,
11213    _additional_params: HashMap<String, String>,
11214    _scopes: BTreeMap<String, ()>
11215}
11216
11217impl<'a, C, A> CallBuilder for RoleUpdateCall<'a, C, A> {}
11218
11219impl<'a, C, A> RoleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
11220
11221
11222    /// Perform the operation you have build so far.
11223    pub fn doit(mut self) -> Result<(hyper::client::Response, Role)> {
11224        use std::io::{Read, Seek};
11225        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
11226        let mut dd = DefaultDelegate;
11227        let mut dlg: &mut dyn Delegate = match self._delegate {
11228            Some(d) => d,
11229            None => &mut dd
11230        };
11231        dlg.begin(MethodInfo { id: "directory.roles.update",
11232                               http_method: hyper::method::Method::Put });
11233        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
11234        params.push(("customer", self._customer.to_string()));
11235        params.push(("roleId", self._role_id.to_string()));
11236        for &field in ["alt", "customer", "roleId"].iter() {
11237            if self._additional_params.contains_key(field) {
11238                dlg.finished(false);
11239                return Err(Error::FieldClash(field));
11240            }
11241        }
11242        for (name, value) in self._additional_params.iter() {
11243            params.push((&name, value.clone()));
11244        }
11245
11246        params.push(("alt", "json".to_string()));
11247
11248        let mut url = self.hub._base_url.clone() + "customer/{customer}/roles/{roleId}";
11249        if self._scopes.len() == 0 {
11250            self._scopes.insert(Scope::DirectoryRolemanagement.as_ref().to_string(), ());
11251        }
11252
11253        for &(find_this, param_name) in [("{customer}", "customer"), ("{roleId}", "roleId")].iter() {
11254            let mut replace_with: Option<&str> = None;
11255            for &(name, ref value) in params.iter() {
11256                if name == param_name {
11257                    replace_with = Some(value);
11258                    break;
11259                }
11260            }
11261            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
11262        }
11263        {
11264            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
11265            for param_name in ["roleId", "customer"].iter() {
11266                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
11267                    indices_for_removal.push(index);
11268                }
11269            }
11270            for &index in indices_for_removal.iter() {
11271                params.remove(index);
11272            }
11273        }
11274
11275        let url = hyper::Url::parse_with_params(&url, params).unwrap();
11276
11277        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
11278        let mut request_value_reader =
11279            {
11280                let mut value = json::value::to_value(&self._request).expect("serde to work");
11281                remove_json_null_values(&mut value);
11282                let mut dst = io::Cursor::new(Vec::with_capacity(128));
11283                json::to_writer(&mut dst, &value).unwrap();
11284                dst
11285            };
11286        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
11287        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11288
11289
11290        loop {
11291            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
11292                Ok(token) => token,
11293                Err(err) => {
11294                    match  dlg.token(&*err) {
11295                        Some(token) => token,
11296                        None => {
11297                            dlg.finished(false);
11298                            return Err(Error::MissingToken(err))
11299                        }
11300                    }
11301                }
11302            };
11303            let auth_header = Authorization(Bearer { token: token.access_token });
11304            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11305            let mut req_result = {
11306                let mut client = &mut *self.hub.client.borrow_mut();
11307                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
11308                    .header(UserAgent(self.hub._user_agent.clone()))
11309                    .header(auth_header.clone())
11310                    .header(ContentType(json_mime_type.clone()))
11311                    .header(ContentLength(request_size as u64))
11312                    .body(&mut request_value_reader);
11313
11314                dlg.pre_request();
11315                req.send()
11316            };
11317
11318            match req_result {
11319                Err(err) => {
11320                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
11321                        sleep(d);
11322                        continue;
11323                    }
11324                    dlg.finished(false);
11325                    return Err(Error::HttpError(err))
11326                }
11327                Ok(mut res) => {
11328                    if !res.status.is_success() {
11329                        let mut json_err = String::new();
11330                        res.read_to_string(&mut json_err).unwrap();
11331                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
11332                                                              json::from_str(&json_err).ok(),
11333                                                              json::from_str(&json_err).ok()) {
11334                            sleep(d);
11335                            continue;
11336                        }
11337                        dlg.finished(false);
11338                        return match json::from_str::<ErrorResponse>(&json_err){
11339                            Err(_) => Err(Error::Failure(res)),
11340                            Ok(serr) => Err(Error::BadRequest(serr))
11341                        }
11342                    }
11343                    let result_value = {
11344                        let mut json_response = String::new();
11345                        res.read_to_string(&mut json_response).unwrap();
11346                        match json::from_str(&json_response) {
11347                            Ok(decoded) => (res, decoded),
11348                            Err(err) => {
11349                                dlg.response_json_decode_error(&json_response, &err);
11350                                return Err(Error::JsonDecodeError(json_response, err));
11351                            }
11352                        }
11353                    };
11354
11355                    dlg.finished(true);
11356                    return Ok(result_value)
11357                }
11358            }
11359        }
11360    }
11361
11362
11363    ///
11364    /// Sets the *request* property to the given value.
11365    ///
11366    /// Even though the property as already been set when instantiating this call,
11367    /// we provide this method for API completeness.
11368    pub fn request(mut self, new_value: Role) -> RoleUpdateCall<'a, C, A> {
11369        self._request = new_value;
11370        self
11371    }
11372    /// Immutable ID of the G Suite account.
11373    ///
11374    /// Sets the *customer* path property to the given value.
11375    ///
11376    /// Even though the property as already been set when instantiating this call,
11377    /// we provide this method for API completeness.
11378    pub fn customer(mut self, new_value: &str) -> RoleUpdateCall<'a, C, A> {
11379        self._customer = new_value.to_string();
11380        self
11381    }
11382    /// Immutable ID of the role.
11383    ///
11384    /// Sets the *role id* path property to the given value.
11385    ///
11386    /// Even though the property as already been set when instantiating this call,
11387    /// we provide this method for API completeness.
11388    pub fn role_id(mut self, new_value: &str) -> RoleUpdateCall<'a, C, A> {
11389        self._role_id = new_value.to_string();
11390        self
11391    }
11392    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11393    /// while executing the actual API request.
11394    /// 
11395    /// It should be used to handle progress information, and to implement a certain level of resilience.
11396    ///
11397    /// Sets the *delegate* property to the given value.
11398    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleUpdateCall<'a, C, A> {
11399        self._delegate = Some(new_value);
11400        self
11401    }
11402
11403    /// Set any additional parameter of the query string used in the request.
11404    /// It should be used to set parameters which are not yet available through their own
11405    /// setters.
11406    ///
11407    /// Please note that this method must not be used to set any of the known parameters
11408    /// which have their own setter method. If done anyway, the request will fail.
11409    ///
11410    /// # Additional Parameters
11411    ///
11412    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11413    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11414    /// * *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.
11415    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11416    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11417    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11418    /// * *alt* (query-string) - Data format for the response.
11419    pub fn param<T>(mut self, name: T, value: T) -> RoleUpdateCall<'a, C, A>
11420                                                        where T: AsRef<str> {
11421        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
11422        self
11423    }
11424
11425    /// Identifies the authorization scope for the method you are building.
11426    ///
11427    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
11428    /// `Scope::DirectoryRolemanagement`.
11429    ///
11430    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11431    /// tokens for more than one scope.
11432    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
11433    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
11434    /// function for details).
11435    ///
11436    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11437    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11438    /// sufficient, a read-write scope will do as well.
11439    pub fn add_scope<T, S>(mut self, scope: T) -> RoleUpdateCall<'a, C, A>
11440                                                        where T: Into<Option<S>>,
11441                                                              S: AsRef<str> {
11442        match scope.into() {
11443          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
11444          None => None,
11445        };
11446        self
11447    }
11448}
11449
11450
11451/// Retrieves a role.
11452///
11453/// A builder for the *get* method supported by a *role* resource.
11454/// It is not used directly, but through a `RoleMethods` instance.
11455///
11456/// # Example
11457///
11458/// Instantiate a resource method builder
11459///
11460/// ```test_harness,no_run
11461/// # extern crate hyper;
11462/// # extern crate hyper_rustls;
11463/// # extern crate yup_oauth2 as oauth2;
11464/// # extern crate google_admin1_directory as admin1_directory;
11465/// # #[test] fn egal() {
11466/// # use std::default::Default;
11467/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
11468/// # use admin1_directory::Directory;
11469/// 
11470/// # let secret: ApplicationSecret = Default::default();
11471/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
11472/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
11473/// #                               <MemoryStorage as Default>::default(), None);
11474/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
11475/// // You can configure optional parameters by calling the respective setters at will, and
11476/// // execute the final call using `doit()`.
11477/// // Values shown here are possibly random and not representative !
11478/// let result = hub.roles().get("customer", "roleId")
11479///              .doit();
11480/// # }
11481/// ```
11482pub struct RoleGetCall<'a, C, A>
11483    where C: 'a, A: 'a {
11484
11485    hub: &'a Directory<C, A>,
11486    _customer: String,
11487    _role_id: String,
11488    _delegate: Option<&'a mut dyn Delegate>,
11489    _additional_params: HashMap<String, String>,
11490    _scopes: BTreeMap<String, ()>
11491}
11492
11493impl<'a, C, A> CallBuilder for RoleGetCall<'a, C, A> {}
11494
11495impl<'a, C, A> RoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
11496
11497
11498    /// Perform the operation you have build so far.
11499    pub fn doit(mut self) -> Result<(hyper::client::Response, Role)> {
11500        use std::io::{Read, Seek};
11501        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
11502        let mut dd = DefaultDelegate;
11503        let mut dlg: &mut dyn Delegate = match self._delegate {
11504            Some(d) => d,
11505            None => &mut dd
11506        };
11507        dlg.begin(MethodInfo { id: "directory.roles.get",
11508                               http_method: hyper::method::Method::Get });
11509        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
11510        params.push(("customer", self._customer.to_string()));
11511        params.push(("roleId", self._role_id.to_string()));
11512        for &field in ["alt", "customer", "roleId"].iter() {
11513            if self._additional_params.contains_key(field) {
11514                dlg.finished(false);
11515                return Err(Error::FieldClash(field));
11516            }
11517        }
11518        for (name, value) in self._additional_params.iter() {
11519            params.push((&name, value.clone()));
11520        }
11521
11522        params.push(("alt", "json".to_string()));
11523
11524        let mut url = self.hub._base_url.clone() + "customer/{customer}/roles/{roleId}";
11525        if self._scopes.len() == 0 {
11526            self._scopes.insert(Scope::DirectoryRolemanagementReadonly.as_ref().to_string(), ());
11527        }
11528
11529        for &(find_this, param_name) in [("{customer}", "customer"), ("{roleId}", "roleId")].iter() {
11530            let mut replace_with: Option<&str> = None;
11531            for &(name, ref value) in params.iter() {
11532                if name == param_name {
11533                    replace_with = Some(value);
11534                    break;
11535                }
11536            }
11537            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
11538        }
11539        {
11540            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
11541            for param_name in ["roleId", "customer"].iter() {
11542                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
11543                    indices_for_removal.push(index);
11544                }
11545            }
11546            for &index in indices_for_removal.iter() {
11547                params.remove(index);
11548            }
11549        }
11550
11551        let url = hyper::Url::parse_with_params(&url, params).unwrap();
11552
11553
11554
11555        loop {
11556            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
11557                Ok(token) => token,
11558                Err(err) => {
11559                    match  dlg.token(&*err) {
11560                        Some(token) => token,
11561                        None => {
11562                            dlg.finished(false);
11563                            return Err(Error::MissingToken(err))
11564                        }
11565                    }
11566                }
11567            };
11568            let auth_header = Authorization(Bearer { token: token.access_token });
11569            let mut req_result = {
11570                let mut client = &mut *self.hub.client.borrow_mut();
11571                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
11572                    .header(UserAgent(self.hub._user_agent.clone()))
11573                    .header(auth_header.clone());
11574
11575                dlg.pre_request();
11576                req.send()
11577            };
11578
11579            match req_result {
11580                Err(err) => {
11581                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
11582                        sleep(d);
11583                        continue;
11584                    }
11585                    dlg.finished(false);
11586                    return Err(Error::HttpError(err))
11587                }
11588                Ok(mut res) => {
11589                    if !res.status.is_success() {
11590                        let mut json_err = String::new();
11591                        res.read_to_string(&mut json_err).unwrap();
11592                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
11593                                                              json::from_str(&json_err).ok(),
11594                                                              json::from_str(&json_err).ok()) {
11595                            sleep(d);
11596                            continue;
11597                        }
11598                        dlg.finished(false);
11599                        return match json::from_str::<ErrorResponse>(&json_err){
11600                            Err(_) => Err(Error::Failure(res)),
11601                            Ok(serr) => Err(Error::BadRequest(serr))
11602                        }
11603                    }
11604                    let result_value = {
11605                        let mut json_response = String::new();
11606                        res.read_to_string(&mut json_response).unwrap();
11607                        match json::from_str(&json_response) {
11608                            Ok(decoded) => (res, decoded),
11609                            Err(err) => {
11610                                dlg.response_json_decode_error(&json_response, &err);
11611                                return Err(Error::JsonDecodeError(json_response, err));
11612                            }
11613                        }
11614                    };
11615
11616                    dlg.finished(true);
11617                    return Ok(result_value)
11618                }
11619            }
11620        }
11621    }
11622
11623
11624    /// Immutable ID of the G Suite account.
11625    ///
11626    /// Sets the *customer* path property to the given value.
11627    ///
11628    /// Even though the property as already been set when instantiating this call,
11629    /// we provide this method for API completeness.
11630    pub fn customer(mut self, new_value: &str) -> RoleGetCall<'a, C, A> {
11631        self._customer = new_value.to_string();
11632        self
11633    }
11634    /// Immutable ID of the role.
11635    ///
11636    /// Sets the *role id* path property to the given value.
11637    ///
11638    /// Even though the property as already been set when instantiating this call,
11639    /// we provide this method for API completeness.
11640    pub fn role_id(mut self, new_value: &str) -> RoleGetCall<'a, C, A> {
11641        self._role_id = new_value.to_string();
11642        self
11643    }
11644    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11645    /// while executing the actual API request.
11646    /// 
11647    /// It should be used to handle progress information, and to implement a certain level of resilience.
11648    ///
11649    /// Sets the *delegate* property to the given value.
11650    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleGetCall<'a, C, A> {
11651        self._delegate = Some(new_value);
11652        self
11653    }
11654
11655    /// Set any additional parameter of the query string used in the request.
11656    /// It should be used to set parameters which are not yet available through their own
11657    /// setters.
11658    ///
11659    /// Please note that this method must not be used to set any of the known parameters
11660    /// which have their own setter method. If done anyway, the request will fail.
11661    ///
11662    /// # Additional Parameters
11663    ///
11664    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11665    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11666    /// * *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.
11667    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11668    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11669    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11670    /// * *alt* (query-string) - Data format for the response.
11671    pub fn param<T>(mut self, name: T, value: T) -> RoleGetCall<'a, C, A>
11672                                                        where T: AsRef<str> {
11673        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
11674        self
11675    }
11676
11677    /// Identifies the authorization scope for the method you are building.
11678    ///
11679    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
11680    /// `Scope::DirectoryRolemanagementReadonly`.
11681    ///
11682    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11683    /// tokens for more than one scope.
11684    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
11685    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
11686    /// function for details).
11687    ///
11688    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11689    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11690    /// sufficient, a read-write scope will do as well.
11691    pub fn add_scope<T, S>(mut self, scope: T) -> RoleGetCall<'a, C, A>
11692                                                        where T: Into<Option<S>>,
11693                                                              S: AsRef<str> {
11694        match scope.into() {
11695          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
11696          None => None,
11697        };
11698        self
11699    }
11700}
11701
11702
11703/// Deletes a role.
11704///
11705/// A builder for the *delete* method supported by a *role* resource.
11706/// It is not used directly, but through a `RoleMethods` instance.
11707///
11708/// # Example
11709///
11710/// Instantiate a resource method builder
11711///
11712/// ```test_harness,no_run
11713/// # extern crate hyper;
11714/// # extern crate hyper_rustls;
11715/// # extern crate yup_oauth2 as oauth2;
11716/// # extern crate google_admin1_directory as admin1_directory;
11717/// # #[test] fn egal() {
11718/// # use std::default::Default;
11719/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
11720/// # use admin1_directory::Directory;
11721/// 
11722/// # let secret: ApplicationSecret = Default::default();
11723/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
11724/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
11725/// #                               <MemoryStorage as Default>::default(), None);
11726/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
11727/// // You can configure optional parameters by calling the respective setters at will, and
11728/// // execute the final call using `doit()`.
11729/// // Values shown here are possibly random and not representative !
11730/// let result = hub.roles().delete("customer", "roleId")
11731///              .doit();
11732/// # }
11733/// ```
11734pub struct RoleDeleteCall<'a, C, A>
11735    where C: 'a, A: 'a {
11736
11737    hub: &'a Directory<C, A>,
11738    _customer: String,
11739    _role_id: String,
11740    _delegate: Option<&'a mut dyn Delegate>,
11741    _additional_params: HashMap<String, String>,
11742    _scopes: BTreeMap<String, ()>
11743}
11744
11745impl<'a, C, A> CallBuilder for RoleDeleteCall<'a, C, A> {}
11746
11747impl<'a, C, A> RoleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
11748
11749
11750    /// Perform the operation you have build so far.
11751    pub fn doit(mut self) -> Result<hyper::client::Response> {
11752        use std::io::{Read, Seek};
11753        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
11754        let mut dd = DefaultDelegate;
11755        let mut dlg: &mut dyn Delegate = match self._delegate {
11756            Some(d) => d,
11757            None => &mut dd
11758        };
11759        dlg.begin(MethodInfo { id: "directory.roles.delete",
11760                               http_method: hyper::method::Method::Delete });
11761        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
11762        params.push(("customer", self._customer.to_string()));
11763        params.push(("roleId", self._role_id.to_string()));
11764        for &field in ["customer", "roleId"].iter() {
11765            if self._additional_params.contains_key(field) {
11766                dlg.finished(false);
11767                return Err(Error::FieldClash(field));
11768            }
11769        }
11770        for (name, value) in self._additional_params.iter() {
11771            params.push((&name, value.clone()));
11772        }
11773
11774
11775        let mut url = self.hub._base_url.clone() + "customer/{customer}/roles/{roleId}";
11776        if self._scopes.len() == 0 {
11777            self._scopes.insert(Scope::DirectoryRolemanagement.as_ref().to_string(), ());
11778        }
11779
11780        for &(find_this, param_name) in [("{customer}", "customer"), ("{roleId}", "roleId")].iter() {
11781            let mut replace_with: Option<&str> = None;
11782            for &(name, ref value) in params.iter() {
11783                if name == param_name {
11784                    replace_with = Some(value);
11785                    break;
11786                }
11787            }
11788            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
11789        }
11790        {
11791            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
11792            for param_name in ["roleId", "customer"].iter() {
11793                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
11794                    indices_for_removal.push(index);
11795                }
11796            }
11797            for &index in indices_for_removal.iter() {
11798                params.remove(index);
11799            }
11800        }
11801
11802        let url = hyper::Url::parse_with_params(&url, params).unwrap();
11803
11804
11805
11806        loop {
11807            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
11808                Ok(token) => token,
11809                Err(err) => {
11810                    match  dlg.token(&*err) {
11811                        Some(token) => token,
11812                        None => {
11813                            dlg.finished(false);
11814                            return Err(Error::MissingToken(err))
11815                        }
11816                    }
11817                }
11818            };
11819            let auth_header = Authorization(Bearer { token: token.access_token });
11820            let mut req_result = {
11821                let mut client = &mut *self.hub.client.borrow_mut();
11822                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
11823                    .header(UserAgent(self.hub._user_agent.clone()))
11824                    .header(auth_header.clone());
11825
11826                dlg.pre_request();
11827                req.send()
11828            };
11829
11830            match req_result {
11831                Err(err) => {
11832                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
11833                        sleep(d);
11834                        continue;
11835                    }
11836                    dlg.finished(false);
11837                    return Err(Error::HttpError(err))
11838                }
11839                Ok(mut res) => {
11840                    if !res.status.is_success() {
11841                        let mut json_err = String::new();
11842                        res.read_to_string(&mut json_err).unwrap();
11843                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
11844                                                              json::from_str(&json_err).ok(),
11845                                                              json::from_str(&json_err).ok()) {
11846                            sleep(d);
11847                            continue;
11848                        }
11849                        dlg.finished(false);
11850                        return match json::from_str::<ErrorResponse>(&json_err){
11851                            Err(_) => Err(Error::Failure(res)),
11852                            Ok(serr) => Err(Error::BadRequest(serr))
11853                        }
11854                    }
11855                    let result_value = res;
11856
11857                    dlg.finished(true);
11858                    return Ok(result_value)
11859                }
11860            }
11861        }
11862    }
11863
11864
11865    /// Immutable ID of the G Suite account.
11866    ///
11867    /// Sets the *customer* path property to the given value.
11868    ///
11869    /// Even though the property as already been set when instantiating this call,
11870    /// we provide this method for API completeness.
11871    pub fn customer(mut self, new_value: &str) -> RoleDeleteCall<'a, C, A> {
11872        self._customer = new_value.to_string();
11873        self
11874    }
11875    /// Immutable ID of the role.
11876    ///
11877    /// Sets the *role id* path property to the given value.
11878    ///
11879    /// Even though the property as already been set when instantiating this call,
11880    /// we provide this method for API completeness.
11881    pub fn role_id(mut self, new_value: &str) -> RoleDeleteCall<'a, C, A> {
11882        self._role_id = new_value.to_string();
11883        self
11884    }
11885    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11886    /// while executing the actual API request.
11887    /// 
11888    /// It should be used to handle progress information, and to implement a certain level of resilience.
11889    ///
11890    /// Sets the *delegate* property to the given value.
11891    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleDeleteCall<'a, C, A> {
11892        self._delegate = Some(new_value);
11893        self
11894    }
11895
11896    /// Set any additional parameter of the query string used in the request.
11897    /// It should be used to set parameters which are not yet available through their own
11898    /// setters.
11899    ///
11900    /// Please note that this method must not be used to set any of the known parameters
11901    /// which have their own setter method. If done anyway, the request will fail.
11902    ///
11903    /// # Additional Parameters
11904    ///
11905    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11906    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11907    /// * *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.
11908    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11909    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11910    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11911    /// * *alt* (query-string) - Data format for the response.
11912    pub fn param<T>(mut self, name: T, value: T) -> RoleDeleteCall<'a, C, A>
11913                                                        where T: AsRef<str> {
11914        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
11915        self
11916    }
11917
11918    /// Identifies the authorization scope for the method you are building.
11919    ///
11920    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
11921    /// `Scope::DirectoryRolemanagement`.
11922    ///
11923    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11924    /// tokens for more than one scope.
11925    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
11926    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
11927    /// function for details).
11928    ///
11929    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11930    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11931    /// sufficient, a read-write scope will do as well.
11932    pub fn add_scope<T, S>(mut self, scope: T) -> RoleDeleteCall<'a, C, A>
11933                                                        where T: Into<Option<S>>,
11934                                                              S: AsRef<str> {
11935        match scope.into() {
11936          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
11937          None => None,
11938        };
11939        self
11940    }
11941}
11942
11943
11944/// Updates a role. This method supports patch semantics.
11945///
11946/// A builder for the *patch* method supported by a *role* resource.
11947/// It is not used directly, but through a `RoleMethods` instance.
11948///
11949/// # Example
11950///
11951/// Instantiate a resource method builder
11952///
11953/// ```test_harness,no_run
11954/// # extern crate hyper;
11955/// # extern crate hyper_rustls;
11956/// # extern crate yup_oauth2 as oauth2;
11957/// # extern crate google_admin1_directory as admin1_directory;
11958/// use admin1_directory::Role;
11959/// # #[test] fn egal() {
11960/// # use std::default::Default;
11961/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
11962/// # use admin1_directory::Directory;
11963/// 
11964/// # let secret: ApplicationSecret = Default::default();
11965/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
11966/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
11967/// #                               <MemoryStorage as Default>::default(), None);
11968/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
11969/// // As the method needs a request, you would usually fill it with the desired information
11970/// // into the respective structure. Some of the parts shown here might not be applicable !
11971/// // Values shown here are possibly random and not representative !
11972/// let mut req = Role::default();
11973/// 
11974/// // You can configure optional parameters by calling the respective setters at will, and
11975/// // execute the final call using `doit()`.
11976/// // Values shown here are possibly random and not representative !
11977/// let result = hub.roles().patch(req, "customer", "roleId")
11978///              .doit();
11979/// # }
11980/// ```
11981pub struct RolePatchCall<'a, C, A>
11982    where C: 'a, A: 'a {
11983
11984    hub: &'a Directory<C, A>,
11985    _request: Role,
11986    _customer: String,
11987    _role_id: String,
11988    _delegate: Option<&'a mut dyn Delegate>,
11989    _additional_params: HashMap<String, String>,
11990    _scopes: BTreeMap<String, ()>
11991}
11992
11993impl<'a, C, A> CallBuilder for RolePatchCall<'a, C, A> {}
11994
11995impl<'a, C, A> RolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
11996
11997
11998    /// Perform the operation you have build so far.
11999    pub fn doit(mut self) -> Result<(hyper::client::Response, Role)> {
12000        use std::io::{Read, Seek};
12001        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
12002        let mut dd = DefaultDelegate;
12003        let mut dlg: &mut dyn Delegate = match self._delegate {
12004            Some(d) => d,
12005            None => &mut dd
12006        };
12007        dlg.begin(MethodInfo { id: "directory.roles.patch",
12008                               http_method: hyper::method::Method::Patch });
12009        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
12010        params.push(("customer", self._customer.to_string()));
12011        params.push(("roleId", self._role_id.to_string()));
12012        for &field in ["alt", "customer", "roleId"].iter() {
12013            if self._additional_params.contains_key(field) {
12014                dlg.finished(false);
12015                return Err(Error::FieldClash(field));
12016            }
12017        }
12018        for (name, value) in self._additional_params.iter() {
12019            params.push((&name, value.clone()));
12020        }
12021
12022        params.push(("alt", "json".to_string()));
12023
12024        let mut url = self.hub._base_url.clone() + "customer/{customer}/roles/{roleId}";
12025        if self._scopes.len() == 0 {
12026            self._scopes.insert(Scope::DirectoryRolemanagement.as_ref().to_string(), ());
12027        }
12028
12029        for &(find_this, param_name) in [("{customer}", "customer"), ("{roleId}", "roleId")].iter() {
12030            let mut replace_with: Option<&str> = None;
12031            for &(name, ref value) in params.iter() {
12032                if name == param_name {
12033                    replace_with = Some(value);
12034                    break;
12035                }
12036            }
12037            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
12038        }
12039        {
12040            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
12041            for param_name in ["roleId", "customer"].iter() {
12042                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
12043                    indices_for_removal.push(index);
12044                }
12045            }
12046            for &index in indices_for_removal.iter() {
12047                params.remove(index);
12048            }
12049        }
12050
12051        let url = hyper::Url::parse_with_params(&url, params).unwrap();
12052
12053        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
12054        let mut request_value_reader =
12055            {
12056                let mut value = json::value::to_value(&self._request).expect("serde to work");
12057                remove_json_null_values(&mut value);
12058                let mut dst = io::Cursor::new(Vec::with_capacity(128));
12059                json::to_writer(&mut dst, &value).unwrap();
12060                dst
12061            };
12062        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
12063        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
12064
12065
12066        loop {
12067            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
12068                Ok(token) => token,
12069                Err(err) => {
12070                    match  dlg.token(&*err) {
12071                        Some(token) => token,
12072                        None => {
12073                            dlg.finished(false);
12074                            return Err(Error::MissingToken(err))
12075                        }
12076                    }
12077                }
12078            };
12079            let auth_header = Authorization(Bearer { token: token.access_token });
12080            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
12081            let mut req_result = {
12082                let mut client = &mut *self.hub.client.borrow_mut();
12083                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
12084                    .header(UserAgent(self.hub._user_agent.clone()))
12085                    .header(auth_header.clone())
12086                    .header(ContentType(json_mime_type.clone()))
12087                    .header(ContentLength(request_size as u64))
12088                    .body(&mut request_value_reader);
12089
12090                dlg.pre_request();
12091                req.send()
12092            };
12093
12094            match req_result {
12095                Err(err) => {
12096                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
12097                        sleep(d);
12098                        continue;
12099                    }
12100                    dlg.finished(false);
12101                    return Err(Error::HttpError(err))
12102                }
12103                Ok(mut res) => {
12104                    if !res.status.is_success() {
12105                        let mut json_err = String::new();
12106                        res.read_to_string(&mut json_err).unwrap();
12107                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
12108                                                              json::from_str(&json_err).ok(),
12109                                                              json::from_str(&json_err).ok()) {
12110                            sleep(d);
12111                            continue;
12112                        }
12113                        dlg.finished(false);
12114                        return match json::from_str::<ErrorResponse>(&json_err){
12115                            Err(_) => Err(Error::Failure(res)),
12116                            Ok(serr) => Err(Error::BadRequest(serr))
12117                        }
12118                    }
12119                    let result_value = {
12120                        let mut json_response = String::new();
12121                        res.read_to_string(&mut json_response).unwrap();
12122                        match json::from_str(&json_response) {
12123                            Ok(decoded) => (res, decoded),
12124                            Err(err) => {
12125                                dlg.response_json_decode_error(&json_response, &err);
12126                                return Err(Error::JsonDecodeError(json_response, err));
12127                            }
12128                        }
12129                    };
12130
12131                    dlg.finished(true);
12132                    return Ok(result_value)
12133                }
12134            }
12135        }
12136    }
12137
12138
12139    ///
12140    /// Sets the *request* property to the given value.
12141    ///
12142    /// Even though the property as already been set when instantiating this call,
12143    /// we provide this method for API completeness.
12144    pub fn request(mut self, new_value: Role) -> RolePatchCall<'a, C, A> {
12145        self._request = new_value;
12146        self
12147    }
12148    /// Immutable ID of the G Suite account.
12149    ///
12150    /// Sets the *customer* path property to the given value.
12151    ///
12152    /// Even though the property as already been set when instantiating this call,
12153    /// we provide this method for API completeness.
12154    pub fn customer(mut self, new_value: &str) -> RolePatchCall<'a, C, A> {
12155        self._customer = new_value.to_string();
12156        self
12157    }
12158    /// Immutable ID of the role.
12159    ///
12160    /// Sets the *role id* path property to the given value.
12161    ///
12162    /// Even though the property as already been set when instantiating this call,
12163    /// we provide this method for API completeness.
12164    pub fn role_id(mut self, new_value: &str) -> RolePatchCall<'a, C, A> {
12165        self._role_id = new_value.to_string();
12166        self
12167    }
12168    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12169    /// while executing the actual API request.
12170    /// 
12171    /// It should be used to handle progress information, and to implement a certain level of resilience.
12172    ///
12173    /// Sets the *delegate* property to the given value.
12174    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RolePatchCall<'a, C, A> {
12175        self._delegate = Some(new_value);
12176        self
12177    }
12178
12179    /// Set any additional parameter of the query string used in the request.
12180    /// It should be used to set parameters which are not yet available through their own
12181    /// setters.
12182    ///
12183    /// Please note that this method must not be used to set any of the known parameters
12184    /// which have their own setter method. If done anyway, the request will fail.
12185    ///
12186    /// # Additional Parameters
12187    ///
12188    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12189    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12190    /// * *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.
12191    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12192    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12193    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12194    /// * *alt* (query-string) - Data format for the response.
12195    pub fn param<T>(mut self, name: T, value: T) -> RolePatchCall<'a, C, A>
12196                                                        where T: AsRef<str> {
12197        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
12198        self
12199    }
12200
12201    /// Identifies the authorization scope for the method you are building.
12202    ///
12203    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
12204    /// `Scope::DirectoryRolemanagement`.
12205    ///
12206    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12207    /// tokens for more than one scope.
12208    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
12209    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
12210    /// function for details).
12211    ///
12212    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12213    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12214    /// sufficient, a read-write scope will do as well.
12215    pub fn add_scope<T, S>(mut self, scope: T) -> RolePatchCall<'a, C, A>
12216                                                        where T: Into<Option<S>>,
12217                                                              S: AsRef<str> {
12218        match scope.into() {
12219          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
12220          None => None,
12221        };
12222        self
12223    }
12224}
12225
12226
12227/// Creates a role.
12228///
12229/// A builder for the *insert* method supported by a *role* resource.
12230/// It is not used directly, but through a `RoleMethods` instance.
12231///
12232/// # Example
12233///
12234/// Instantiate a resource method builder
12235///
12236/// ```test_harness,no_run
12237/// # extern crate hyper;
12238/// # extern crate hyper_rustls;
12239/// # extern crate yup_oauth2 as oauth2;
12240/// # extern crate google_admin1_directory as admin1_directory;
12241/// use admin1_directory::Role;
12242/// # #[test] fn egal() {
12243/// # use std::default::Default;
12244/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
12245/// # use admin1_directory::Directory;
12246/// 
12247/// # let secret: ApplicationSecret = Default::default();
12248/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
12249/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
12250/// #                               <MemoryStorage as Default>::default(), None);
12251/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
12252/// // As the method needs a request, you would usually fill it with the desired information
12253/// // into the respective structure. Some of the parts shown here might not be applicable !
12254/// // Values shown here are possibly random and not representative !
12255/// let mut req = Role::default();
12256/// 
12257/// // You can configure optional parameters by calling the respective setters at will, and
12258/// // execute the final call using `doit()`.
12259/// // Values shown here are possibly random and not representative !
12260/// let result = hub.roles().insert(req, "customer")
12261///              .doit();
12262/// # }
12263/// ```
12264pub struct RoleInsertCall<'a, C, A>
12265    where C: 'a, A: 'a {
12266
12267    hub: &'a Directory<C, A>,
12268    _request: Role,
12269    _customer: String,
12270    _delegate: Option<&'a mut dyn Delegate>,
12271    _additional_params: HashMap<String, String>,
12272    _scopes: BTreeMap<String, ()>
12273}
12274
12275impl<'a, C, A> CallBuilder for RoleInsertCall<'a, C, A> {}
12276
12277impl<'a, C, A> RoleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
12278
12279
12280    /// Perform the operation you have build so far.
12281    pub fn doit(mut self) -> Result<(hyper::client::Response, Role)> {
12282        use std::io::{Read, Seek};
12283        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
12284        let mut dd = DefaultDelegate;
12285        let mut dlg: &mut dyn Delegate = match self._delegate {
12286            Some(d) => d,
12287            None => &mut dd
12288        };
12289        dlg.begin(MethodInfo { id: "directory.roles.insert",
12290                               http_method: hyper::method::Method::Post });
12291        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
12292        params.push(("customer", self._customer.to_string()));
12293        for &field in ["alt", "customer"].iter() {
12294            if self._additional_params.contains_key(field) {
12295                dlg.finished(false);
12296                return Err(Error::FieldClash(field));
12297            }
12298        }
12299        for (name, value) in self._additional_params.iter() {
12300            params.push((&name, value.clone()));
12301        }
12302
12303        params.push(("alt", "json".to_string()));
12304
12305        let mut url = self.hub._base_url.clone() + "customer/{customer}/roles";
12306        if self._scopes.len() == 0 {
12307            self._scopes.insert(Scope::DirectoryRolemanagement.as_ref().to_string(), ());
12308        }
12309
12310        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
12311            let mut replace_with: Option<&str> = None;
12312            for &(name, ref value) in params.iter() {
12313                if name == param_name {
12314                    replace_with = Some(value);
12315                    break;
12316                }
12317            }
12318            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
12319        }
12320        {
12321            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
12322            for param_name in ["customer"].iter() {
12323                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
12324                    indices_for_removal.push(index);
12325                }
12326            }
12327            for &index in indices_for_removal.iter() {
12328                params.remove(index);
12329            }
12330        }
12331
12332        let url = hyper::Url::parse_with_params(&url, params).unwrap();
12333
12334        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
12335        let mut request_value_reader =
12336            {
12337                let mut value = json::value::to_value(&self._request).expect("serde to work");
12338                remove_json_null_values(&mut value);
12339                let mut dst = io::Cursor::new(Vec::with_capacity(128));
12340                json::to_writer(&mut dst, &value).unwrap();
12341                dst
12342            };
12343        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
12344        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
12345
12346
12347        loop {
12348            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
12349                Ok(token) => token,
12350                Err(err) => {
12351                    match  dlg.token(&*err) {
12352                        Some(token) => token,
12353                        None => {
12354                            dlg.finished(false);
12355                            return Err(Error::MissingToken(err))
12356                        }
12357                    }
12358                }
12359            };
12360            let auth_header = Authorization(Bearer { token: token.access_token });
12361            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
12362            let mut req_result = {
12363                let mut client = &mut *self.hub.client.borrow_mut();
12364                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
12365                    .header(UserAgent(self.hub._user_agent.clone()))
12366                    .header(auth_header.clone())
12367                    .header(ContentType(json_mime_type.clone()))
12368                    .header(ContentLength(request_size as u64))
12369                    .body(&mut request_value_reader);
12370
12371                dlg.pre_request();
12372                req.send()
12373            };
12374
12375            match req_result {
12376                Err(err) => {
12377                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
12378                        sleep(d);
12379                        continue;
12380                    }
12381                    dlg.finished(false);
12382                    return Err(Error::HttpError(err))
12383                }
12384                Ok(mut res) => {
12385                    if !res.status.is_success() {
12386                        let mut json_err = String::new();
12387                        res.read_to_string(&mut json_err).unwrap();
12388                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
12389                                                              json::from_str(&json_err).ok(),
12390                                                              json::from_str(&json_err).ok()) {
12391                            sleep(d);
12392                            continue;
12393                        }
12394                        dlg.finished(false);
12395                        return match json::from_str::<ErrorResponse>(&json_err){
12396                            Err(_) => Err(Error::Failure(res)),
12397                            Ok(serr) => Err(Error::BadRequest(serr))
12398                        }
12399                    }
12400                    let result_value = {
12401                        let mut json_response = String::new();
12402                        res.read_to_string(&mut json_response).unwrap();
12403                        match json::from_str(&json_response) {
12404                            Ok(decoded) => (res, decoded),
12405                            Err(err) => {
12406                                dlg.response_json_decode_error(&json_response, &err);
12407                                return Err(Error::JsonDecodeError(json_response, err));
12408                            }
12409                        }
12410                    };
12411
12412                    dlg.finished(true);
12413                    return Ok(result_value)
12414                }
12415            }
12416        }
12417    }
12418
12419
12420    ///
12421    /// Sets the *request* property to the given value.
12422    ///
12423    /// Even though the property as already been set when instantiating this call,
12424    /// we provide this method for API completeness.
12425    pub fn request(mut self, new_value: Role) -> RoleInsertCall<'a, C, A> {
12426        self._request = new_value;
12427        self
12428    }
12429    /// Immutable ID of the G Suite account.
12430    ///
12431    /// Sets the *customer* path property to the given value.
12432    ///
12433    /// Even though the property as already been set when instantiating this call,
12434    /// we provide this method for API completeness.
12435    pub fn customer(mut self, new_value: &str) -> RoleInsertCall<'a, C, A> {
12436        self._customer = new_value.to_string();
12437        self
12438    }
12439    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12440    /// while executing the actual API request.
12441    /// 
12442    /// It should be used to handle progress information, and to implement a certain level of resilience.
12443    ///
12444    /// Sets the *delegate* property to the given value.
12445    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleInsertCall<'a, C, A> {
12446        self._delegate = Some(new_value);
12447        self
12448    }
12449
12450    /// Set any additional parameter of the query string used in the request.
12451    /// It should be used to set parameters which are not yet available through their own
12452    /// setters.
12453    ///
12454    /// Please note that this method must not be used to set any of the known parameters
12455    /// which have their own setter method. If done anyway, the request will fail.
12456    ///
12457    /// # Additional Parameters
12458    ///
12459    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12460    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12461    /// * *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.
12462    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12463    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12464    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12465    /// * *alt* (query-string) - Data format for the response.
12466    pub fn param<T>(mut self, name: T, value: T) -> RoleInsertCall<'a, C, A>
12467                                                        where T: AsRef<str> {
12468        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
12469        self
12470    }
12471
12472    /// Identifies the authorization scope for the method you are building.
12473    ///
12474    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
12475    /// `Scope::DirectoryRolemanagement`.
12476    ///
12477    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12478    /// tokens for more than one scope.
12479    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
12480    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
12481    /// function for details).
12482    ///
12483    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12484    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12485    /// sufficient, a read-write scope will do as well.
12486    pub fn add_scope<T, S>(mut self, scope: T) -> RoleInsertCall<'a, C, A>
12487                                                        where T: Into<Option<S>>,
12488                                                              S: AsRef<str> {
12489        match scope.into() {
12490          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
12491          None => None,
12492        };
12493        self
12494    }
12495}
12496
12497
12498/// Retrieves a paginated list of all the roles in a domain.
12499///
12500/// A builder for the *list* method supported by a *role* resource.
12501/// It is not used directly, but through a `RoleMethods` instance.
12502///
12503/// # Example
12504///
12505/// Instantiate a resource method builder
12506///
12507/// ```test_harness,no_run
12508/// # extern crate hyper;
12509/// # extern crate hyper_rustls;
12510/// # extern crate yup_oauth2 as oauth2;
12511/// # extern crate google_admin1_directory as admin1_directory;
12512/// # #[test] fn egal() {
12513/// # use std::default::Default;
12514/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
12515/// # use admin1_directory::Directory;
12516/// 
12517/// # let secret: ApplicationSecret = Default::default();
12518/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
12519/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
12520/// #                               <MemoryStorage as Default>::default(), None);
12521/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
12522/// // You can configure optional parameters by calling the respective setters at will, and
12523/// // execute the final call using `doit()`.
12524/// // Values shown here are possibly random and not representative !
12525/// let result = hub.roles().list("customer")
12526///              .page_token("consetetur")
12527///              .max_results(-84)
12528///              .doit();
12529/// # }
12530/// ```
12531pub struct RoleListCall<'a, C, A>
12532    where C: 'a, A: 'a {
12533
12534    hub: &'a Directory<C, A>,
12535    _customer: String,
12536    _page_token: Option<String>,
12537    _max_results: Option<i32>,
12538    _delegate: Option<&'a mut dyn Delegate>,
12539    _additional_params: HashMap<String, String>,
12540    _scopes: BTreeMap<String, ()>
12541}
12542
12543impl<'a, C, A> CallBuilder for RoleListCall<'a, C, A> {}
12544
12545impl<'a, C, A> RoleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
12546
12547
12548    /// Perform the operation you have build so far.
12549    pub fn doit(mut self) -> Result<(hyper::client::Response, Roles)> {
12550        use std::io::{Read, Seek};
12551        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
12552        let mut dd = DefaultDelegate;
12553        let mut dlg: &mut dyn Delegate = match self._delegate {
12554            Some(d) => d,
12555            None => &mut dd
12556        };
12557        dlg.begin(MethodInfo { id: "directory.roles.list",
12558                               http_method: hyper::method::Method::Get });
12559        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
12560        params.push(("customer", self._customer.to_string()));
12561        if let Some(value) = self._page_token {
12562            params.push(("pageToken", value.to_string()));
12563        }
12564        if let Some(value) = self._max_results {
12565            params.push(("maxResults", value.to_string()));
12566        }
12567        for &field in ["alt", "customer", "pageToken", "maxResults"].iter() {
12568            if self._additional_params.contains_key(field) {
12569                dlg.finished(false);
12570                return Err(Error::FieldClash(field));
12571            }
12572        }
12573        for (name, value) in self._additional_params.iter() {
12574            params.push((&name, value.clone()));
12575        }
12576
12577        params.push(("alt", "json".to_string()));
12578
12579        let mut url = self.hub._base_url.clone() + "customer/{customer}/roles";
12580        if self._scopes.len() == 0 {
12581            self._scopes.insert(Scope::DirectoryRolemanagementReadonly.as_ref().to_string(), ());
12582        }
12583
12584        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
12585            let mut replace_with: Option<&str> = None;
12586            for &(name, ref value) in params.iter() {
12587                if name == param_name {
12588                    replace_with = Some(value);
12589                    break;
12590                }
12591            }
12592            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
12593        }
12594        {
12595            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
12596            for param_name in ["customer"].iter() {
12597                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
12598                    indices_for_removal.push(index);
12599                }
12600            }
12601            for &index in indices_for_removal.iter() {
12602                params.remove(index);
12603            }
12604        }
12605
12606        let url = hyper::Url::parse_with_params(&url, params).unwrap();
12607
12608
12609
12610        loop {
12611            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
12612                Ok(token) => token,
12613                Err(err) => {
12614                    match  dlg.token(&*err) {
12615                        Some(token) => token,
12616                        None => {
12617                            dlg.finished(false);
12618                            return Err(Error::MissingToken(err))
12619                        }
12620                    }
12621                }
12622            };
12623            let auth_header = Authorization(Bearer { token: token.access_token });
12624            let mut req_result = {
12625                let mut client = &mut *self.hub.client.borrow_mut();
12626                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
12627                    .header(UserAgent(self.hub._user_agent.clone()))
12628                    .header(auth_header.clone());
12629
12630                dlg.pre_request();
12631                req.send()
12632            };
12633
12634            match req_result {
12635                Err(err) => {
12636                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
12637                        sleep(d);
12638                        continue;
12639                    }
12640                    dlg.finished(false);
12641                    return Err(Error::HttpError(err))
12642                }
12643                Ok(mut res) => {
12644                    if !res.status.is_success() {
12645                        let mut json_err = String::new();
12646                        res.read_to_string(&mut json_err).unwrap();
12647                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
12648                                                              json::from_str(&json_err).ok(),
12649                                                              json::from_str(&json_err).ok()) {
12650                            sleep(d);
12651                            continue;
12652                        }
12653                        dlg.finished(false);
12654                        return match json::from_str::<ErrorResponse>(&json_err){
12655                            Err(_) => Err(Error::Failure(res)),
12656                            Ok(serr) => Err(Error::BadRequest(serr))
12657                        }
12658                    }
12659                    let result_value = {
12660                        let mut json_response = String::new();
12661                        res.read_to_string(&mut json_response).unwrap();
12662                        match json::from_str(&json_response) {
12663                            Ok(decoded) => (res, decoded),
12664                            Err(err) => {
12665                                dlg.response_json_decode_error(&json_response, &err);
12666                                return Err(Error::JsonDecodeError(json_response, err));
12667                            }
12668                        }
12669                    };
12670
12671                    dlg.finished(true);
12672                    return Ok(result_value)
12673                }
12674            }
12675        }
12676    }
12677
12678
12679    /// Immutable ID of the G Suite account.
12680    ///
12681    /// Sets the *customer* path property to the given value.
12682    ///
12683    /// Even though the property as already been set when instantiating this call,
12684    /// we provide this method for API completeness.
12685    pub fn customer(mut self, new_value: &str) -> RoleListCall<'a, C, A> {
12686        self._customer = new_value.to_string();
12687        self
12688    }
12689    /// Token to specify the next page in the list.
12690    ///
12691    /// Sets the *page token* query property to the given value.
12692    pub fn page_token(mut self, new_value: &str) -> RoleListCall<'a, C, A> {
12693        self._page_token = Some(new_value.to_string());
12694        self
12695    }
12696    /// Maximum number of results to return.
12697    ///
12698    /// Sets the *max results* query property to the given value.
12699    pub fn max_results(mut self, new_value: i32) -> RoleListCall<'a, C, A> {
12700        self._max_results = Some(new_value);
12701        self
12702    }
12703    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12704    /// while executing the actual API request.
12705    /// 
12706    /// It should be used to handle progress information, and to implement a certain level of resilience.
12707    ///
12708    /// Sets the *delegate* property to the given value.
12709    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleListCall<'a, C, A> {
12710        self._delegate = Some(new_value);
12711        self
12712    }
12713
12714    /// Set any additional parameter of the query string used in the request.
12715    /// It should be used to set parameters which are not yet available through their own
12716    /// setters.
12717    ///
12718    /// Please note that this method must not be used to set any of the known parameters
12719    /// which have their own setter method. If done anyway, the request will fail.
12720    ///
12721    /// # Additional Parameters
12722    ///
12723    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12724    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12725    /// * *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.
12726    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12727    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12728    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12729    /// * *alt* (query-string) - Data format for the response.
12730    pub fn param<T>(mut self, name: T, value: T) -> RoleListCall<'a, C, A>
12731                                                        where T: AsRef<str> {
12732        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
12733        self
12734    }
12735
12736    /// Identifies the authorization scope for the method you are building.
12737    ///
12738    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
12739    /// `Scope::DirectoryRolemanagementReadonly`.
12740    ///
12741    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12742    /// tokens for more than one scope.
12743    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
12744    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
12745    /// function for details).
12746    ///
12747    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12748    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12749    /// sufficient, a read-write scope will do as well.
12750    pub fn add_scope<T, S>(mut self, scope: T) -> RoleListCall<'a, C, A>
12751                                                        where T: Into<Option<S>>,
12752                                                              S: AsRef<str> {
12753        match scope.into() {
12754          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
12755          None => None,
12756        };
12757        self
12758    }
12759}
12760
12761
12762/// Retrieves a list of notifications.
12763///
12764/// A builder for the *list* method supported by a *notification* resource.
12765/// It is not used directly, but through a `NotificationMethods` instance.
12766///
12767/// # Example
12768///
12769/// Instantiate a resource method builder
12770///
12771/// ```test_harness,no_run
12772/// # extern crate hyper;
12773/// # extern crate hyper_rustls;
12774/// # extern crate yup_oauth2 as oauth2;
12775/// # extern crate google_admin1_directory as admin1_directory;
12776/// # #[test] fn egal() {
12777/// # use std::default::Default;
12778/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
12779/// # use admin1_directory::Directory;
12780/// 
12781/// # let secret: ApplicationSecret = Default::default();
12782/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
12783/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
12784/// #                               <MemoryStorage as Default>::default(), None);
12785/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
12786/// // You can configure optional parameters by calling the respective setters at will, and
12787/// // execute the final call using `doit()`.
12788/// // Values shown here are possibly random and not representative !
12789/// let result = hub.notifications().list("customer")
12790///              .page_token("aliquyam")
12791///              .max_results(96)
12792///              .language("et")
12793///              .doit();
12794/// # }
12795/// ```
12796pub struct NotificationListCall<'a, C, A>
12797    where C: 'a, A: 'a {
12798
12799    hub: &'a Directory<C, A>,
12800    _customer: String,
12801    _page_token: Option<String>,
12802    _max_results: Option<u32>,
12803    _language: Option<String>,
12804    _delegate: Option<&'a mut dyn Delegate>,
12805    _additional_params: HashMap<String, String>,
12806    _scopes: BTreeMap<String, ()>
12807}
12808
12809impl<'a, C, A> CallBuilder for NotificationListCall<'a, C, A> {}
12810
12811impl<'a, C, A> NotificationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
12812
12813
12814    /// Perform the operation you have build so far.
12815    pub fn doit(mut self) -> Result<(hyper::client::Response, Notifications)> {
12816        use std::io::{Read, Seek};
12817        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
12818        let mut dd = DefaultDelegate;
12819        let mut dlg: &mut dyn Delegate = match self._delegate {
12820            Some(d) => d,
12821            None => &mut dd
12822        };
12823        dlg.begin(MethodInfo { id: "directory.notifications.list",
12824                               http_method: hyper::method::Method::Get });
12825        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
12826        params.push(("customer", self._customer.to_string()));
12827        if let Some(value) = self._page_token {
12828            params.push(("pageToken", value.to_string()));
12829        }
12830        if let Some(value) = self._max_results {
12831            params.push(("maxResults", value.to_string()));
12832        }
12833        if let Some(value) = self._language {
12834            params.push(("language", value.to_string()));
12835        }
12836        for &field in ["alt", "customer", "pageToken", "maxResults", "language"].iter() {
12837            if self._additional_params.contains_key(field) {
12838                dlg.finished(false);
12839                return Err(Error::FieldClash(field));
12840            }
12841        }
12842        for (name, value) in self._additional_params.iter() {
12843            params.push((&name, value.clone()));
12844        }
12845
12846        params.push(("alt", "json".to_string()));
12847
12848        let mut url = self.hub._base_url.clone() + "customer/{customer}/notifications";
12849        if self._scopes.len() == 0 {
12850            self._scopes.insert(Scope::DirectoryNotification.as_ref().to_string(), ());
12851        }
12852
12853        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
12854            let mut replace_with: Option<&str> = None;
12855            for &(name, ref value) in params.iter() {
12856                if name == param_name {
12857                    replace_with = Some(value);
12858                    break;
12859                }
12860            }
12861            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
12862        }
12863        {
12864            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
12865            for param_name in ["customer"].iter() {
12866                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
12867                    indices_for_removal.push(index);
12868                }
12869            }
12870            for &index in indices_for_removal.iter() {
12871                params.remove(index);
12872            }
12873        }
12874
12875        let url = hyper::Url::parse_with_params(&url, params).unwrap();
12876
12877
12878
12879        loop {
12880            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
12881                Ok(token) => token,
12882                Err(err) => {
12883                    match  dlg.token(&*err) {
12884                        Some(token) => token,
12885                        None => {
12886                            dlg.finished(false);
12887                            return Err(Error::MissingToken(err))
12888                        }
12889                    }
12890                }
12891            };
12892            let auth_header = Authorization(Bearer { token: token.access_token });
12893            let mut req_result = {
12894                let mut client = &mut *self.hub.client.borrow_mut();
12895                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
12896                    .header(UserAgent(self.hub._user_agent.clone()))
12897                    .header(auth_header.clone());
12898
12899                dlg.pre_request();
12900                req.send()
12901            };
12902
12903            match req_result {
12904                Err(err) => {
12905                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
12906                        sleep(d);
12907                        continue;
12908                    }
12909                    dlg.finished(false);
12910                    return Err(Error::HttpError(err))
12911                }
12912                Ok(mut res) => {
12913                    if !res.status.is_success() {
12914                        let mut json_err = String::new();
12915                        res.read_to_string(&mut json_err).unwrap();
12916                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
12917                                                              json::from_str(&json_err).ok(),
12918                                                              json::from_str(&json_err).ok()) {
12919                            sleep(d);
12920                            continue;
12921                        }
12922                        dlg.finished(false);
12923                        return match json::from_str::<ErrorResponse>(&json_err){
12924                            Err(_) => Err(Error::Failure(res)),
12925                            Ok(serr) => Err(Error::BadRequest(serr))
12926                        }
12927                    }
12928                    let result_value = {
12929                        let mut json_response = String::new();
12930                        res.read_to_string(&mut json_response).unwrap();
12931                        match json::from_str(&json_response) {
12932                            Ok(decoded) => (res, decoded),
12933                            Err(err) => {
12934                                dlg.response_json_decode_error(&json_response, &err);
12935                                return Err(Error::JsonDecodeError(json_response, err));
12936                            }
12937                        }
12938                    };
12939
12940                    dlg.finished(true);
12941                    return Ok(result_value)
12942                }
12943            }
12944        }
12945    }
12946
12947
12948    /// The unique ID for the customer's G Suite account.
12949    ///
12950    /// Sets the *customer* path property to the given value.
12951    ///
12952    /// Even though the property as already been set when instantiating this call,
12953    /// we provide this method for API completeness.
12954    pub fn customer(mut self, new_value: &str) -> NotificationListCall<'a, C, A> {
12955        self._customer = new_value.to_string();
12956        self
12957    }
12958    /// The token to specify the page of results to retrieve.
12959    ///
12960    /// Sets the *page token* query property to the given value.
12961    pub fn page_token(mut self, new_value: &str) -> NotificationListCall<'a, C, A> {
12962        self._page_token = Some(new_value.to_string());
12963        self
12964    }
12965    /// Maximum number of notifications to return per page. The default is 100.
12966    ///
12967    /// Sets the *max results* query property to the given value.
12968    pub fn max_results(mut self, new_value: u32) -> NotificationListCall<'a, C, A> {
12969        self._max_results = Some(new_value);
12970        self
12971    }
12972    /// The ISO 639-1 code of the language notifications are returned in. The default is English (en).
12973    ///
12974    /// Sets the *language* query property to the given value.
12975    pub fn language(mut self, new_value: &str) -> NotificationListCall<'a, C, A> {
12976        self._language = Some(new_value.to_string());
12977        self
12978    }
12979    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12980    /// while executing the actual API request.
12981    /// 
12982    /// It should be used to handle progress information, and to implement a certain level of resilience.
12983    ///
12984    /// Sets the *delegate* property to the given value.
12985    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> NotificationListCall<'a, C, A> {
12986        self._delegate = Some(new_value);
12987        self
12988    }
12989
12990    /// Set any additional parameter of the query string used in the request.
12991    /// It should be used to set parameters which are not yet available through their own
12992    /// setters.
12993    ///
12994    /// Please note that this method must not be used to set any of the known parameters
12995    /// which have their own setter method. If done anyway, the request will fail.
12996    ///
12997    /// # Additional Parameters
12998    ///
12999    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13000    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13001    /// * *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.
13002    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13003    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13004    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13005    /// * *alt* (query-string) - Data format for the response.
13006    pub fn param<T>(mut self, name: T, value: T) -> NotificationListCall<'a, C, A>
13007                                                        where T: AsRef<str> {
13008        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
13009        self
13010    }
13011
13012    /// Identifies the authorization scope for the method you are building.
13013    ///
13014    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
13015    /// `Scope::DirectoryNotification`.
13016    ///
13017    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13018    /// tokens for more than one scope.
13019    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
13020    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
13021    /// function for details).
13022    ///
13023    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13024    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13025    /// sufficient, a read-write scope will do as well.
13026    pub fn add_scope<T, S>(mut self, scope: T) -> NotificationListCall<'a, C, A>
13027                                                        where T: Into<Option<S>>,
13028                                                              S: AsRef<str> {
13029        match scope.into() {
13030          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
13031          None => None,
13032        };
13033        self
13034    }
13035}
13036
13037
13038/// Updates a notification.
13039///
13040/// A builder for the *update* method supported by a *notification* resource.
13041/// It is not used directly, but through a `NotificationMethods` instance.
13042///
13043/// # Example
13044///
13045/// Instantiate a resource method builder
13046///
13047/// ```test_harness,no_run
13048/// # extern crate hyper;
13049/// # extern crate hyper_rustls;
13050/// # extern crate yup_oauth2 as oauth2;
13051/// # extern crate google_admin1_directory as admin1_directory;
13052/// use admin1_directory::Notification;
13053/// # #[test] fn egal() {
13054/// # use std::default::Default;
13055/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
13056/// # use admin1_directory::Directory;
13057/// 
13058/// # let secret: ApplicationSecret = Default::default();
13059/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
13060/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
13061/// #                               <MemoryStorage as Default>::default(), None);
13062/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
13063/// // As the method needs a request, you would usually fill it with the desired information
13064/// // into the respective structure. Some of the parts shown here might not be applicable !
13065/// // Values shown here are possibly random and not representative !
13066/// let mut req = Notification::default();
13067/// 
13068/// // You can configure optional parameters by calling the respective setters at will, and
13069/// // execute the final call using `doit()`.
13070/// // Values shown here are possibly random and not representative !
13071/// let result = hub.notifications().update(req, "customer", "notificationId")
13072///              .doit();
13073/// # }
13074/// ```
13075pub struct NotificationUpdateCall<'a, C, A>
13076    where C: 'a, A: 'a {
13077
13078    hub: &'a Directory<C, A>,
13079    _request: Notification,
13080    _customer: String,
13081    _notification_id: String,
13082    _delegate: Option<&'a mut dyn Delegate>,
13083    _additional_params: HashMap<String, String>,
13084    _scopes: BTreeMap<String, ()>
13085}
13086
13087impl<'a, C, A> CallBuilder for NotificationUpdateCall<'a, C, A> {}
13088
13089impl<'a, C, A> NotificationUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
13090
13091
13092    /// Perform the operation you have build so far.
13093    pub fn doit(mut self) -> Result<(hyper::client::Response, Notification)> {
13094        use std::io::{Read, Seek};
13095        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
13096        let mut dd = DefaultDelegate;
13097        let mut dlg: &mut dyn Delegate = match self._delegate {
13098            Some(d) => d,
13099            None => &mut dd
13100        };
13101        dlg.begin(MethodInfo { id: "directory.notifications.update",
13102                               http_method: hyper::method::Method::Put });
13103        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
13104        params.push(("customer", self._customer.to_string()));
13105        params.push(("notificationId", self._notification_id.to_string()));
13106        for &field in ["alt", "customer", "notificationId"].iter() {
13107            if self._additional_params.contains_key(field) {
13108                dlg.finished(false);
13109                return Err(Error::FieldClash(field));
13110            }
13111        }
13112        for (name, value) in self._additional_params.iter() {
13113            params.push((&name, value.clone()));
13114        }
13115
13116        params.push(("alt", "json".to_string()));
13117
13118        let mut url = self.hub._base_url.clone() + "customer/{customer}/notifications/{notificationId}";
13119        if self._scopes.len() == 0 {
13120            self._scopes.insert(Scope::DirectoryNotification.as_ref().to_string(), ());
13121        }
13122
13123        for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
13124            let mut replace_with: Option<&str> = None;
13125            for &(name, ref value) in params.iter() {
13126                if name == param_name {
13127                    replace_with = Some(value);
13128                    break;
13129                }
13130            }
13131            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
13132        }
13133        {
13134            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
13135            for param_name in ["notificationId", "customer"].iter() {
13136                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
13137                    indices_for_removal.push(index);
13138                }
13139            }
13140            for &index in indices_for_removal.iter() {
13141                params.remove(index);
13142            }
13143        }
13144
13145        let url = hyper::Url::parse_with_params(&url, params).unwrap();
13146
13147        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
13148        let mut request_value_reader =
13149            {
13150                let mut value = json::value::to_value(&self._request).expect("serde to work");
13151                remove_json_null_values(&mut value);
13152                let mut dst = io::Cursor::new(Vec::with_capacity(128));
13153                json::to_writer(&mut dst, &value).unwrap();
13154                dst
13155            };
13156        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
13157        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
13158
13159
13160        loop {
13161            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
13162                Ok(token) => token,
13163                Err(err) => {
13164                    match  dlg.token(&*err) {
13165                        Some(token) => token,
13166                        None => {
13167                            dlg.finished(false);
13168                            return Err(Error::MissingToken(err))
13169                        }
13170                    }
13171                }
13172            };
13173            let auth_header = Authorization(Bearer { token: token.access_token });
13174            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
13175            let mut req_result = {
13176                let mut client = &mut *self.hub.client.borrow_mut();
13177                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
13178                    .header(UserAgent(self.hub._user_agent.clone()))
13179                    .header(auth_header.clone())
13180                    .header(ContentType(json_mime_type.clone()))
13181                    .header(ContentLength(request_size as u64))
13182                    .body(&mut request_value_reader);
13183
13184                dlg.pre_request();
13185                req.send()
13186            };
13187
13188            match req_result {
13189                Err(err) => {
13190                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
13191                        sleep(d);
13192                        continue;
13193                    }
13194                    dlg.finished(false);
13195                    return Err(Error::HttpError(err))
13196                }
13197                Ok(mut res) => {
13198                    if !res.status.is_success() {
13199                        let mut json_err = String::new();
13200                        res.read_to_string(&mut json_err).unwrap();
13201                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
13202                                                              json::from_str(&json_err).ok(),
13203                                                              json::from_str(&json_err).ok()) {
13204                            sleep(d);
13205                            continue;
13206                        }
13207                        dlg.finished(false);
13208                        return match json::from_str::<ErrorResponse>(&json_err){
13209                            Err(_) => Err(Error::Failure(res)),
13210                            Ok(serr) => Err(Error::BadRequest(serr))
13211                        }
13212                    }
13213                    let result_value = {
13214                        let mut json_response = String::new();
13215                        res.read_to_string(&mut json_response).unwrap();
13216                        match json::from_str(&json_response) {
13217                            Ok(decoded) => (res, decoded),
13218                            Err(err) => {
13219                                dlg.response_json_decode_error(&json_response, &err);
13220                                return Err(Error::JsonDecodeError(json_response, err));
13221                            }
13222                        }
13223                    };
13224
13225                    dlg.finished(true);
13226                    return Ok(result_value)
13227                }
13228            }
13229        }
13230    }
13231
13232
13233    ///
13234    /// Sets the *request* property to the given value.
13235    ///
13236    /// Even though the property as already been set when instantiating this call,
13237    /// we provide this method for API completeness.
13238    pub fn request(mut self, new_value: Notification) -> NotificationUpdateCall<'a, C, A> {
13239        self._request = new_value;
13240        self
13241    }
13242    /// The unique ID for the customer's G Suite account.
13243    ///
13244    /// Sets the *customer* path property to the given value.
13245    ///
13246    /// Even though the property as already been set when instantiating this call,
13247    /// we provide this method for API completeness.
13248    pub fn customer(mut self, new_value: &str) -> NotificationUpdateCall<'a, C, A> {
13249        self._customer = new_value.to_string();
13250        self
13251    }
13252    /// The unique ID of the notification.
13253    ///
13254    /// Sets the *notification id* path property to the given value.
13255    ///
13256    /// Even though the property as already been set when instantiating this call,
13257    /// we provide this method for API completeness.
13258    pub fn notification_id(mut self, new_value: &str) -> NotificationUpdateCall<'a, C, A> {
13259        self._notification_id = new_value.to_string();
13260        self
13261    }
13262    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13263    /// while executing the actual API request.
13264    /// 
13265    /// It should be used to handle progress information, and to implement a certain level of resilience.
13266    ///
13267    /// Sets the *delegate* property to the given value.
13268    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> NotificationUpdateCall<'a, C, A> {
13269        self._delegate = Some(new_value);
13270        self
13271    }
13272
13273    /// Set any additional parameter of the query string used in the request.
13274    /// It should be used to set parameters which are not yet available through their own
13275    /// setters.
13276    ///
13277    /// Please note that this method must not be used to set any of the known parameters
13278    /// which have their own setter method. If done anyway, the request will fail.
13279    ///
13280    /// # Additional Parameters
13281    ///
13282    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13283    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13284    /// * *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.
13285    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13286    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13287    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13288    /// * *alt* (query-string) - Data format for the response.
13289    pub fn param<T>(mut self, name: T, value: T) -> NotificationUpdateCall<'a, C, A>
13290                                                        where T: AsRef<str> {
13291        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
13292        self
13293    }
13294
13295    /// Identifies the authorization scope for the method you are building.
13296    ///
13297    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
13298    /// `Scope::DirectoryNotification`.
13299    ///
13300    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13301    /// tokens for more than one scope.
13302    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
13303    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
13304    /// function for details).
13305    ///
13306    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13307    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13308    /// sufficient, a read-write scope will do as well.
13309    pub fn add_scope<T, S>(mut self, scope: T) -> NotificationUpdateCall<'a, C, A>
13310                                                        where T: Into<Option<S>>,
13311                                                              S: AsRef<str> {
13312        match scope.into() {
13313          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
13314          None => None,
13315        };
13316        self
13317    }
13318}
13319
13320
13321/// Deletes a notification
13322///
13323/// A builder for the *delete* method supported by a *notification* resource.
13324/// It is not used directly, but through a `NotificationMethods` instance.
13325///
13326/// # Example
13327///
13328/// Instantiate a resource method builder
13329///
13330/// ```test_harness,no_run
13331/// # extern crate hyper;
13332/// # extern crate hyper_rustls;
13333/// # extern crate yup_oauth2 as oauth2;
13334/// # extern crate google_admin1_directory as admin1_directory;
13335/// # #[test] fn egal() {
13336/// # use std::default::Default;
13337/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
13338/// # use admin1_directory::Directory;
13339/// 
13340/// # let secret: ApplicationSecret = Default::default();
13341/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
13342/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
13343/// #                               <MemoryStorage as Default>::default(), None);
13344/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
13345/// // You can configure optional parameters by calling the respective setters at will, and
13346/// // execute the final call using `doit()`.
13347/// // Values shown here are possibly random and not representative !
13348/// let result = hub.notifications().delete("customer", "notificationId")
13349///              .doit();
13350/// # }
13351/// ```
13352pub struct NotificationDeleteCall<'a, C, A>
13353    where C: 'a, A: 'a {
13354
13355    hub: &'a Directory<C, A>,
13356    _customer: String,
13357    _notification_id: String,
13358    _delegate: Option<&'a mut dyn Delegate>,
13359    _additional_params: HashMap<String, String>,
13360    _scopes: BTreeMap<String, ()>
13361}
13362
13363impl<'a, C, A> CallBuilder for NotificationDeleteCall<'a, C, A> {}
13364
13365impl<'a, C, A> NotificationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
13366
13367
13368    /// Perform the operation you have build so far.
13369    pub fn doit(mut self) -> Result<hyper::client::Response> {
13370        use std::io::{Read, Seek};
13371        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
13372        let mut dd = DefaultDelegate;
13373        let mut dlg: &mut dyn Delegate = match self._delegate {
13374            Some(d) => d,
13375            None => &mut dd
13376        };
13377        dlg.begin(MethodInfo { id: "directory.notifications.delete",
13378                               http_method: hyper::method::Method::Delete });
13379        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
13380        params.push(("customer", self._customer.to_string()));
13381        params.push(("notificationId", self._notification_id.to_string()));
13382        for &field in ["customer", "notificationId"].iter() {
13383            if self._additional_params.contains_key(field) {
13384                dlg.finished(false);
13385                return Err(Error::FieldClash(field));
13386            }
13387        }
13388        for (name, value) in self._additional_params.iter() {
13389            params.push((&name, value.clone()));
13390        }
13391
13392
13393        let mut url = self.hub._base_url.clone() + "customer/{customer}/notifications/{notificationId}";
13394        if self._scopes.len() == 0 {
13395            self._scopes.insert(Scope::DirectoryNotification.as_ref().to_string(), ());
13396        }
13397
13398        for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
13399            let mut replace_with: Option<&str> = None;
13400            for &(name, ref value) in params.iter() {
13401                if name == param_name {
13402                    replace_with = Some(value);
13403                    break;
13404                }
13405            }
13406            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
13407        }
13408        {
13409            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
13410            for param_name in ["notificationId", "customer"].iter() {
13411                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
13412                    indices_for_removal.push(index);
13413                }
13414            }
13415            for &index in indices_for_removal.iter() {
13416                params.remove(index);
13417            }
13418        }
13419
13420        let url = hyper::Url::parse_with_params(&url, params).unwrap();
13421
13422
13423
13424        loop {
13425            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
13426                Ok(token) => token,
13427                Err(err) => {
13428                    match  dlg.token(&*err) {
13429                        Some(token) => token,
13430                        None => {
13431                            dlg.finished(false);
13432                            return Err(Error::MissingToken(err))
13433                        }
13434                    }
13435                }
13436            };
13437            let auth_header = Authorization(Bearer { token: token.access_token });
13438            let mut req_result = {
13439                let mut client = &mut *self.hub.client.borrow_mut();
13440                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
13441                    .header(UserAgent(self.hub._user_agent.clone()))
13442                    .header(auth_header.clone());
13443
13444                dlg.pre_request();
13445                req.send()
13446            };
13447
13448            match req_result {
13449                Err(err) => {
13450                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
13451                        sleep(d);
13452                        continue;
13453                    }
13454                    dlg.finished(false);
13455                    return Err(Error::HttpError(err))
13456                }
13457                Ok(mut res) => {
13458                    if !res.status.is_success() {
13459                        let mut json_err = String::new();
13460                        res.read_to_string(&mut json_err).unwrap();
13461                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
13462                                                              json::from_str(&json_err).ok(),
13463                                                              json::from_str(&json_err).ok()) {
13464                            sleep(d);
13465                            continue;
13466                        }
13467                        dlg.finished(false);
13468                        return match json::from_str::<ErrorResponse>(&json_err){
13469                            Err(_) => Err(Error::Failure(res)),
13470                            Ok(serr) => Err(Error::BadRequest(serr))
13471                        }
13472                    }
13473                    let result_value = res;
13474
13475                    dlg.finished(true);
13476                    return Ok(result_value)
13477                }
13478            }
13479        }
13480    }
13481
13482
13483    /// The unique ID for the customer's G Suite account. The customerId is also returned as part of the Users resource.
13484    ///
13485    /// Sets the *customer* path property to the given value.
13486    ///
13487    /// Even though the property as already been set when instantiating this call,
13488    /// we provide this method for API completeness.
13489    pub fn customer(mut self, new_value: &str) -> NotificationDeleteCall<'a, C, A> {
13490        self._customer = new_value.to_string();
13491        self
13492    }
13493    /// The unique ID of the notification.
13494    ///
13495    /// Sets the *notification id* path property to the given value.
13496    ///
13497    /// Even though the property as already been set when instantiating this call,
13498    /// we provide this method for API completeness.
13499    pub fn notification_id(mut self, new_value: &str) -> NotificationDeleteCall<'a, C, A> {
13500        self._notification_id = new_value.to_string();
13501        self
13502    }
13503    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13504    /// while executing the actual API request.
13505    /// 
13506    /// It should be used to handle progress information, and to implement a certain level of resilience.
13507    ///
13508    /// Sets the *delegate* property to the given value.
13509    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> NotificationDeleteCall<'a, C, A> {
13510        self._delegate = Some(new_value);
13511        self
13512    }
13513
13514    /// Set any additional parameter of the query string used in the request.
13515    /// It should be used to set parameters which are not yet available through their own
13516    /// setters.
13517    ///
13518    /// Please note that this method must not be used to set any of the known parameters
13519    /// which have their own setter method. If done anyway, the request will fail.
13520    ///
13521    /// # Additional Parameters
13522    ///
13523    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13524    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13525    /// * *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.
13526    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13527    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13528    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13529    /// * *alt* (query-string) - Data format for the response.
13530    pub fn param<T>(mut self, name: T, value: T) -> NotificationDeleteCall<'a, C, A>
13531                                                        where T: AsRef<str> {
13532        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
13533        self
13534    }
13535
13536    /// Identifies the authorization scope for the method you are building.
13537    ///
13538    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
13539    /// `Scope::DirectoryNotification`.
13540    ///
13541    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13542    /// tokens for more than one scope.
13543    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
13544    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
13545    /// function for details).
13546    ///
13547    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13548    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13549    /// sufficient, a read-write scope will do as well.
13550    pub fn add_scope<T, S>(mut self, scope: T) -> NotificationDeleteCall<'a, C, A>
13551                                                        where T: Into<Option<S>>,
13552                                                              S: AsRef<str> {
13553        match scope.into() {
13554          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
13555          None => None,
13556        };
13557        self
13558    }
13559}
13560
13561
13562/// Retrieves a notification.
13563///
13564/// A builder for the *get* method supported by a *notification* resource.
13565/// It is not used directly, but through a `NotificationMethods` instance.
13566///
13567/// # Example
13568///
13569/// Instantiate a resource method builder
13570///
13571/// ```test_harness,no_run
13572/// # extern crate hyper;
13573/// # extern crate hyper_rustls;
13574/// # extern crate yup_oauth2 as oauth2;
13575/// # extern crate google_admin1_directory as admin1_directory;
13576/// # #[test] fn egal() {
13577/// # use std::default::Default;
13578/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
13579/// # use admin1_directory::Directory;
13580/// 
13581/// # let secret: ApplicationSecret = Default::default();
13582/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
13583/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
13584/// #                               <MemoryStorage as Default>::default(), None);
13585/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
13586/// // You can configure optional parameters by calling the respective setters at will, and
13587/// // execute the final call using `doit()`.
13588/// // Values shown here are possibly random and not representative !
13589/// let result = hub.notifications().get("customer", "notificationId")
13590///              .doit();
13591/// # }
13592/// ```
13593pub struct NotificationGetCall<'a, C, A>
13594    where C: 'a, A: 'a {
13595
13596    hub: &'a Directory<C, A>,
13597    _customer: String,
13598    _notification_id: String,
13599    _delegate: Option<&'a mut dyn Delegate>,
13600    _additional_params: HashMap<String, String>,
13601    _scopes: BTreeMap<String, ()>
13602}
13603
13604impl<'a, C, A> CallBuilder for NotificationGetCall<'a, C, A> {}
13605
13606impl<'a, C, A> NotificationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
13607
13608
13609    /// Perform the operation you have build so far.
13610    pub fn doit(mut self) -> Result<(hyper::client::Response, Notification)> {
13611        use std::io::{Read, Seek};
13612        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
13613        let mut dd = DefaultDelegate;
13614        let mut dlg: &mut dyn Delegate = match self._delegate {
13615            Some(d) => d,
13616            None => &mut dd
13617        };
13618        dlg.begin(MethodInfo { id: "directory.notifications.get",
13619                               http_method: hyper::method::Method::Get });
13620        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
13621        params.push(("customer", self._customer.to_string()));
13622        params.push(("notificationId", self._notification_id.to_string()));
13623        for &field in ["alt", "customer", "notificationId"].iter() {
13624            if self._additional_params.contains_key(field) {
13625                dlg.finished(false);
13626                return Err(Error::FieldClash(field));
13627            }
13628        }
13629        for (name, value) in self._additional_params.iter() {
13630            params.push((&name, value.clone()));
13631        }
13632
13633        params.push(("alt", "json".to_string()));
13634
13635        let mut url = self.hub._base_url.clone() + "customer/{customer}/notifications/{notificationId}";
13636        if self._scopes.len() == 0 {
13637            self._scopes.insert(Scope::DirectoryNotification.as_ref().to_string(), ());
13638        }
13639
13640        for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
13641            let mut replace_with: Option<&str> = None;
13642            for &(name, ref value) in params.iter() {
13643                if name == param_name {
13644                    replace_with = Some(value);
13645                    break;
13646                }
13647            }
13648            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
13649        }
13650        {
13651            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
13652            for param_name in ["notificationId", "customer"].iter() {
13653                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
13654                    indices_for_removal.push(index);
13655                }
13656            }
13657            for &index in indices_for_removal.iter() {
13658                params.remove(index);
13659            }
13660        }
13661
13662        let url = hyper::Url::parse_with_params(&url, params).unwrap();
13663
13664
13665
13666        loop {
13667            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
13668                Ok(token) => token,
13669                Err(err) => {
13670                    match  dlg.token(&*err) {
13671                        Some(token) => token,
13672                        None => {
13673                            dlg.finished(false);
13674                            return Err(Error::MissingToken(err))
13675                        }
13676                    }
13677                }
13678            };
13679            let auth_header = Authorization(Bearer { token: token.access_token });
13680            let mut req_result = {
13681                let mut client = &mut *self.hub.client.borrow_mut();
13682                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
13683                    .header(UserAgent(self.hub._user_agent.clone()))
13684                    .header(auth_header.clone());
13685
13686                dlg.pre_request();
13687                req.send()
13688            };
13689
13690            match req_result {
13691                Err(err) => {
13692                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
13693                        sleep(d);
13694                        continue;
13695                    }
13696                    dlg.finished(false);
13697                    return Err(Error::HttpError(err))
13698                }
13699                Ok(mut res) => {
13700                    if !res.status.is_success() {
13701                        let mut json_err = String::new();
13702                        res.read_to_string(&mut json_err).unwrap();
13703                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
13704                                                              json::from_str(&json_err).ok(),
13705                                                              json::from_str(&json_err).ok()) {
13706                            sleep(d);
13707                            continue;
13708                        }
13709                        dlg.finished(false);
13710                        return match json::from_str::<ErrorResponse>(&json_err){
13711                            Err(_) => Err(Error::Failure(res)),
13712                            Ok(serr) => Err(Error::BadRequest(serr))
13713                        }
13714                    }
13715                    let result_value = {
13716                        let mut json_response = String::new();
13717                        res.read_to_string(&mut json_response).unwrap();
13718                        match json::from_str(&json_response) {
13719                            Ok(decoded) => (res, decoded),
13720                            Err(err) => {
13721                                dlg.response_json_decode_error(&json_response, &err);
13722                                return Err(Error::JsonDecodeError(json_response, err));
13723                            }
13724                        }
13725                    };
13726
13727                    dlg.finished(true);
13728                    return Ok(result_value)
13729                }
13730            }
13731        }
13732    }
13733
13734
13735    /// The unique ID for the customer's G Suite account. The customerId is also returned as part of the Users resource.
13736    ///
13737    /// Sets the *customer* path property to the given value.
13738    ///
13739    /// Even though the property as already been set when instantiating this call,
13740    /// we provide this method for API completeness.
13741    pub fn customer(mut self, new_value: &str) -> NotificationGetCall<'a, C, A> {
13742        self._customer = new_value.to_string();
13743        self
13744    }
13745    /// The unique ID of the notification.
13746    ///
13747    /// Sets the *notification id* path property to the given value.
13748    ///
13749    /// Even though the property as already been set when instantiating this call,
13750    /// we provide this method for API completeness.
13751    pub fn notification_id(mut self, new_value: &str) -> NotificationGetCall<'a, C, A> {
13752        self._notification_id = new_value.to_string();
13753        self
13754    }
13755    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13756    /// while executing the actual API request.
13757    /// 
13758    /// It should be used to handle progress information, and to implement a certain level of resilience.
13759    ///
13760    /// Sets the *delegate* property to the given value.
13761    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> NotificationGetCall<'a, C, A> {
13762        self._delegate = Some(new_value);
13763        self
13764    }
13765
13766    /// Set any additional parameter of the query string used in the request.
13767    /// It should be used to set parameters which are not yet available through their own
13768    /// setters.
13769    ///
13770    /// Please note that this method must not be used to set any of the known parameters
13771    /// which have their own setter method. If done anyway, the request will fail.
13772    ///
13773    /// # Additional Parameters
13774    ///
13775    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13776    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13777    /// * *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.
13778    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13779    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13780    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13781    /// * *alt* (query-string) - Data format for the response.
13782    pub fn param<T>(mut self, name: T, value: T) -> NotificationGetCall<'a, C, A>
13783                                                        where T: AsRef<str> {
13784        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
13785        self
13786    }
13787
13788    /// Identifies the authorization scope for the method you are building.
13789    ///
13790    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
13791    /// `Scope::DirectoryNotification`.
13792    ///
13793    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13794    /// tokens for more than one scope.
13795    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
13796    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
13797    /// function for details).
13798    ///
13799    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13800    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13801    /// sufficient, a read-write scope will do as well.
13802    pub fn add_scope<T, S>(mut self, scope: T) -> NotificationGetCall<'a, C, A>
13803                                                        where T: Into<Option<S>>,
13804                                                              S: AsRef<str> {
13805        match scope.into() {
13806          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
13807          None => None,
13808        };
13809        self
13810    }
13811}
13812
13813
13814/// Updates a notification. This method supports patch semantics.
13815///
13816/// A builder for the *patch* method supported by a *notification* resource.
13817/// It is not used directly, but through a `NotificationMethods` instance.
13818///
13819/// # Example
13820///
13821/// Instantiate a resource method builder
13822///
13823/// ```test_harness,no_run
13824/// # extern crate hyper;
13825/// # extern crate hyper_rustls;
13826/// # extern crate yup_oauth2 as oauth2;
13827/// # extern crate google_admin1_directory as admin1_directory;
13828/// use admin1_directory::Notification;
13829/// # #[test] fn egal() {
13830/// # use std::default::Default;
13831/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
13832/// # use admin1_directory::Directory;
13833/// 
13834/// # let secret: ApplicationSecret = Default::default();
13835/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
13836/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
13837/// #                               <MemoryStorage as Default>::default(), None);
13838/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
13839/// // As the method needs a request, you would usually fill it with the desired information
13840/// // into the respective structure. Some of the parts shown here might not be applicable !
13841/// // Values shown here are possibly random and not representative !
13842/// let mut req = Notification::default();
13843/// 
13844/// // You can configure optional parameters by calling the respective setters at will, and
13845/// // execute the final call using `doit()`.
13846/// // Values shown here are possibly random and not representative !
13847/// let result = hub.notifications().patch(req, "customer", "notificationId")
13848///              .doit();
13849/// # }
13850/// ```
13851pub struct NotificationPatchCall<'a, C, A>
13852    where C: 'a, A: 'a {
13853
13854    hub: &'a Directory<C, A>,
13855    _request: Notification,
13856    _customer: String,
13857    _notification_id: String,
13858    _delegate: Option<&'a mut dyn Delegate>,
13859    _additional_params: HashMap<String, String>,
13860    _scopes: BTreeMap<String, ()>
13861}
13862
13863impl<'a, C, A> CallBuilder for NotificationPatchCall<'a, C, A> {}
13864
13865impl<'a, C, A> NotificationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
13866
13867
13868    /// Perform the operation you have build so far.
13869    pub fn doit(mut self) -> Result<(hyper::client::Response, Notification)> {
13870        use std::io::{Read, Seek};
13871        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
13872        let mut dd = DefaultDelegate;
13873        let mut dlg: &mut dyn Delegate = match self._delegate {
13874            Some(d) => d,
13875            None => &mut dd
13876        };
13877        dlg.begin(MethodInfo { id: "directory.notifications.patch",
13878                               http_method: hyper::method::Method::Patch });
13879        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
13880        params.push(("customer", self._customer.to_string()));
13881        params.push(("notificationId", self._notification_id.to_string()));
13882        for &field in ["alt", "customer", "notificationId"].iter() {
13883            if self._additional_params.contains_key(field) {
13884                dlg.finished(false);
13885                return Err(Error::FieldClash(field));
13886            }
13887        }
13888        for (name, value) in self._additional_params.iter() {
13889            params.push((&name, value.clone()));
13890        }
13891
13892        params.push(("alt", "json".to_string()));
13893
13894        let mut url = self.hub._base_url.clone() + "customer/{customer}/notifications/{notificationId}";
13895        if self._scopes.len() == 0 {
13896            self._scopes.insert(Scope::DirectoryNotification.as_ref().to_string(), ());
13897        }
13898
13899        for &(find_this, param_name) in [("{customer}", "customer"), ("{notificationId}", "notificationId")].iter() {
13900            let mut replace_with: Option<&str> = None;
13901            for &(name, ref value) in params.iter() {
13902                if name == param_name {
13903                    replace_with = Some(value);
13904                    break;
13905                }
13906            }
13907            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
13908        }
13909        {
13910            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
13911            for param_name in ["notificationId", "customer"].iter() {
13912                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
13913                    indices_for_removal.push(index);
13914                }
13915            }
13916            for &index in indices_for_removal.iter() {
13917                params.remove(index);
13918            }
13919        }
13920
13921        let url = hyper::Url::parse_with_params(&url, params).unwrap();
13922
13923        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
13924        let mut request_value_reader =
13925            {
13926                let mut value = json::value::to_value(&self._request).expect("serde to work");
13927                remove_json_null_values(&mut value);
13928                let mut dst = io::Cursor::new(Vec::with_capacity(128));
13929                json::to_writer(&mut dst, &value).unwrap();
13930                dst
13931            };
13932        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
13933        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
13934
13935
13936        loop {
13937            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
13938                Ok(token) => token,
13939                Err(err) => {
13940                    match  dlg.token(&*err) {
13941                        Some(token) => token,
13942                        None => {
13943                            dlg.finished(false);
13944                            return Err(Error::MissingToken(err))
13945                        }
13946                    }
13947                }
13948            };
13949            let auth_header = Authorization(Bearer { token: token.access_token });
13950            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
13951            let mut req_result = {
13952                let mut client = &mut *self.hub.client.borrow_mut();
13953                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
13954                    .header(UserAgent(self.hub._user_agent.clone()))
13955                    .header(auth_header.clone())
13956                    .header(ContentType(json_mime_type.clone()))
13957                    .header(ContentLength(request_size as u64))
13958                    .body(&mut request_value_reader);
13959
13960                dlg.pre_request();
13961                req.send()
13962            };
13963
13964            match req_result {
13965                Err(err) => {
13966                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
13967                        sleep(d);
13968                        continue;
13969                    }
13970                    dlg.finished(false);
13971                    return Err(Error::HttpError(err))
13972                }
13973                Ok(mut res) => {
13974                    if !res.status.is_success() {
13975                        let mut json_err = String::new();
13976                        res.read_to_string(&mut json_err).unwrap();
13977                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
13978                                                              json::from_str(&json_err).ok(),
13979                                                              json::from_str(&json_err).ok()) {
13980                            sleep(d);
13981                            continue;
13982                        }
13983                        dlg.finished(false);
13984                        return match json::from_str::<ErrorResponse>(&json_err){
13985                            Err(_) => Err(Error::Failure(res)),
13986                            Ok(serr) => Err(Error::BadRequest(serr))
13987                        }
13988                    }
13989                    let result_value = {
13990                        let mut json_response = String::new();
13991                        res.read_to_string(&mut json_response).unwrap();
13992                        match json::from_str(&json_response) {
13993                            Ok(decoded) => (res, decoded),
13994                            Err(err) => {
13995                                dlg.response_json_decode_error(&json_response, &err);
13996                                return Err(Error::JsonDecodeError(json_response, err));
13997                            }
13998                        }
13999                    };
14000
14001                    dlg.finished(true);
14002                    return Ok(result_value)
14003                }
14004            }
14005        }
14006    }
14007
14008
14009    ///
14010    /// Sets the *request* property to the given value.
14011    ///
14012    /// Even though the property as already been set when instantiating this call,
14013    /// we provide this method for API completeness.
14014    pub fn request(mut self, new_value: Notification) -> NotificationPatchCall<'a, C, A> {
14015        self._request = new_value;
14016        self
14017    }
14018    /// The unique ID for the customer's G Suite account.
14019    ///
14020    /// Sets the *customer* path property to the given value.
14021    ///
14022    /// Even though the property as already been set when instantiating this call,
14023    /// we provide this method for API completeness.
14024    pub fn customer(mut self, new_value: &str) -> NotificationPatchCall<'a, C, A> {
14025        self._customer = new_value.to_string();
14026        self
14027    }
14028    /// The unique ID of the notification.
14029    ///
14030    /// Sets the *notification id* path property to the given value.
14031    ///
14032    /// Even though the property as already been set when instantiating this call,
14033    /// we provide this method for API completeness.
14034    pub fn notification_id(mut self, new_value: &str) -> NotificationPatchCall<'a, C, A> {
14035        self._notification_id = new_value.to_string();
14036        self
14037    }
14038    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14039    /// while executing the actual API request.
14040    /// 
14041    /// It should be used to handle progress information, and to implement a certain level of resilience.
14042    ///
14043    /// Sets the *delegate* property to the given value.
14044    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> NotificationPatchCall<'a, C, A> {
14045        self._delegate = Some(new_value);
14046        self
14047    }
14048
14049    /// Set any additional parameter of the query string used in the request.
14050    /// It should be used to set parameters which are not yet available through their own
14051    /// setters.
14052    ///
14053    /// Please note that this method must not be used to set any of the known parameters
14054    /// which have their own setter method. If done anyway, the request will fail.
14055    ///
14056    /// # Additional Parameters
14057    ///
14058    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14059    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14060    /// * *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.
14061    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14062    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14063    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14064    /// * *alt* (query-string) - Data format for the response.
14065    pub fn param<T>(mut self, name: T, value: T) -> NotificationPatchCall<'a, C, A>
14066                                                        where T: AsRef<str> {
14067        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
14068        self
14069    }
14070
14071    /// Identifies the authorization scope for the method you are building.
14072    ///
14073    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
14074    /// `Scope::DirectoryNotification`.
14075    ///
14076    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14077    /// tokens for more than one scope.
14078    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
14079    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
14080    /// function for details).
14081    ///
14082    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14083    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14084    /// sufficient, a read-write scope will do as well.
14085    pub fn add_scope<T, S>(mut self, scope: T) -> NotificationPatchCall<'a, C, A>
14086                                                        where T: Into<Option<S>>,
14087                                                              S: AsRef<str> {
14088        match scope.into() {
14089          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
14090          None => None,
14091        };
14092        self
14093    }
14094}
14095
14096
14097/// Retrieves a paginated list of all privileges for a customer.
14098///
14099/// A builder for the *list* method supported by a *privilege* resource.
14100/// It is not used directly, but through a `PrivilegeMethods` instance.
14101///
14102/// # Example
14103///
14104/// Instantiate a resource method builder
14105///
14106/// ```test_harness,no_run
14107/// # extern crate hyper;
14108/// # extern crate hyper_rustls;
14109/// # extern crate yup_oauth2 as oauth2;
14110/// # extern crate google_admin1_directory as admin1_directory;
14111/// # #[test] fn egal() {
14112/// # use std::default::Default;
14113/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
14114/// # use admin1_directory::Directory;
14115/// 
14116/// # let secret: ApplicationSecret = Default::default();
14117/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
14118/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
14119/// #                               <MemoryStorage as Default>::default(), None);
14120/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
14121/// // You can configure optional parameters by calling the respective setters at will, and
14122/// // execute the final call using `doit()`.
14123/// // Values shown here are possibly random and not representative !
14124/// let result = hub.privileges().list("customer")
14125///              .doit();
14126/// # }
14127/// ```
14128pub struct PrivilegeListCall<'a, C, A>
14129    where C: 'a, A: 'a {
14130
14131    hub: &'a Directory<C, A>,
14132    _customer: String,
14133    _delegate: Option<&'a mut dyn Delegate>,
14134    _additional_params: HashMap<String, String>,
14135    _scopes: BTreeMap<String, ()>
14136}
14137
14138impl<'a, C, A> CallBuilder for PrivilegeListCall<'a, C, A> {}
14139
14140impl<'a, C, A> PrivilegeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
14141
14142
14143    /// Perform the operation you have build so far.
14144    pub fn doit(mut self) -> Result<(hyper::client::Response, Privileges)> {
14145        use std::io::{Read, Seek};
14146        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
14147        let mut dd = DefaultDelegate;
14148        let mut dlg: &mut dyn Delegate = match self._delegate {
14149            Some(d) => d,
14150            None => &mut dd
14151        };
14152        dlg.begin(MethodInfo { id: "directory.privileges.list",
14153                               http_method: hyper::method::Method::Get });
14154        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
14155        params.push(("customer", self._customer.to_string()));
14156        for &field in ["alt", "customer"].iter() {
14157            if self._additional_params.contains_key(field) {
14158                dlg.finished(false);
14159                return Err(Error::FieldClash(field));
14160            }
14161        }
14162        for (name, value) in self._additional_params.iter() {
14163            params.push((&name, value.clone()));
14164        }
14165
14166        params.push(("alt", "json".to_string()));
14167
14168        let mut url = self.hub._base_url.clone() + "customer/{customer}/roles/ALL/privileges";
14169        if self._scopes.len() == 0 {
14170            self._scopes.insert(Scope::DirectoryRolemanagementReadonly.as_ref().to_string(), ());
14171        }
14172
14173        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
14174            let mut replace_with: Option<&str> = None;
14175            for &(name, ref value) in params.iter() {
14176                if name == param_name {
14177                    replace_with = Some(value);
14178                    break;
14179                }
14180            }
14181            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
14182        }
14183        {
14184            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
14185            for param_name in ["customer"].iter() {
14186                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
14187                    indices_for_removal.push(index);
14188                }
14189            }
14190            for &index in indices_for_removal.iter() {
14191                params.remove(index);
14192            }
14193        }
14194
14195        let url = hyper::Url::parse_with_params(&url, params).unwrap();
14196
14197
14198
14199        loop {
14200            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
14201                Ok(token) => token,
14202                Err(err) => {
14203                    match  dlg.token(&*err) {
14204                        Some(token) => token,
14205                        None => {
14206                            dlg.finished(false);
14207                            return Err(Error::MissingToken(err))
14208                        }
14209                    }
14210                }
14211            };
14212            let auth_header = Authorization(Bearer { token: token.access_token });
14213            let mut req_result = {
14214                let mut client = &mut *self.hub.client.borrow_mut();
14215                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
14216                    .header(UserAgent(self.hub._user_agent.clone()))
14217                    .header(auth_header.clone());
14218
14219                dlg.pre_request();
14220                req.send()
14221            };
14222
14223            match req_result {
14224                Err(err) => {
14225                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
14226                        sleep(d);
14227                        continue;
14228                    }
14229                    dlg.finished(false);
14230                    return Err(Error::HttpError(err))
14231                }
14232                Ok(mut res) => {
14233                    if !res.status.is_success() {
14234                        let mut json_err = String::new();
14235                        res.read_to_string(&mut json_err).unwrap();
14236                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
14237                                                              json::from_str(&json_err).ok(),
14238                                                              json::from_str(&json_err).ok()) {
14239                            sleep(d);
14240                            continue;
14241                        }
14242                        dlg.finished(false);
14243                        return match json::from_str::<ErrorResponse>(&json_err){
14244                            Err(_) => Err(Error::Failure(res)),
14245                            Ok(serr) => Err(Error::BadRequest(serr))
14246                        }
14247                    }
14248                    let result_value = {
14249                        let mut json_response = String::new();
14250                        res.read_to_string(&mut json_response).unwrap();
14251                        match json::from_str(&json_response) {
14252                            Ok(decoded) => (res, decoded),
14253                            Err(err) => {
14254                                dlg.response_json_decode_error(&json_response, &err);
14255                                return Err(Error::JsonDecodeError(json_response, err));
14256                            }
14257                        }
14258                    };
14259
14260                    dlg.finished(true);
14261                    return Ok(result_value)
14262                }
14263            }
14264        }
14265    }
14266
14267
14268    /// Immutable ID of the G Suite account.
14269    ///
14270    /// Sets the *customer* path property to the given value.
14271    ///
14272    /// Even though the property as already been set when instantiating this call,
14273    /// we provide this method for API completeness.
14274    pub fn customer(mut self, new_value: &str) -> PrivilegeListCall<'a, C, A> {
14275        self._customer = new_value.to_string();
14276        self
14277    }
14278    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14279    /// while executing the actual API request.
14280    /// 
14281    /// It should be used to handle progress information, and to implement a certain level of resilience.
14282    ///
14283    /// Sets the *delegate* property to the given value.
14284    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> PrivilegeListCall<'a, C, A> {
14285        self._delegate = Some(new_value);
14286        self
14287    }
14288
14289    /// Set any additional parameter of the query string used in the request.
14290    /// It should be used to set parameters which are not yet available through their own
14291    /// setters.
14292    ///
14293    /// Please note that this method must not be used to set any of the known parameters
14294    /// which have their own setter method. If done anyway, the request will fail.
14295    ///
14296    /// # Additional Parameters
14297    ///
14298    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14299    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14300    /// * *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.
14301    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14302    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14303    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14304    /// * *alt* (query-string) - Data format for the response.
14305    pub fn param<T>(mut self, name: T, value: T) -> PrivilegeListCall<'a, C, A>
14306                                                        where T: AsRef<str> {
14307        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
14308        self
14309    }
14310
14311    /// Identifies the authorization scope for the method you are building.
14312    ///
14313    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
14314    /// `Scope::DirectoryRolemanagementReadonly`.
14315    ///
14316    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14317    /// tokens for more than one scope.
14318    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
14319    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
14320    /// function for details).
14321    ///
14322    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14323    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14324    /// sufficient, a read-write scope will do as well.
14325    pub fn add_scope<T, S>(mut self, scope: T) -> PrivilegeListCall<'a, C, A>
14326                                                        where T: Into<Option<S>>,
14327                                                              S: AsRef<str> {
14328        match scope.into() {
14329          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
14330          None => None,
14331        };
14332        self
14333    }
14334}
14335
14336
14337/// Stop watching resources through this channel
14338///
14339/// A builder for the *stop* method supported by a *channel* resource.
14340/// It is not used directly, but through a `ChannelMethods` instance.
14341///
14342/// # Example
14343///
14344/// Instantiate a resource method builder
14345///
14346/// ```test_harness,no_run
14347/// # extern crate hyper;
14348/// # extern crate hyper_rustls;
14349/// # extern crate yup_oauth2 as oauth2;
14350/// # extern crate google_admin1_directory as admin1_directory;
14351/// use admin1_directory::Channel;
14352/// # #[test] fn egal() {
14353/// # use std::default::Default;
14354/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
14355/// # use admin1_directory::Directory;
14356/// 
14357/// # let secret: ApplicationSecret = Default::default();
14358/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
14359/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
14360/// #                               <MemoryStorage as Default>::default(), None);
14361/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
14362/// // As the method needs a request, you would usually fill it with the desired information
14363/// // into the respective structure. Some of the parts shown here might not be applicable !
14364/// // Values shown here are possibly random and not representative !
14365/// let mut req = Channel::default();
14366/// 
14367/// // You can configure optional parameters by calling the respective setters at will, and
14368/// // execute the final call using `doit()`.
14369/// // Values shown here are possibly random and not representative !
14370/// let result = hub.channels().stop(req)
14371///              .doit();
14372/// # }
14373/// ```
14374pub struct ChannelStopCall<'a, C, A>
14375    where C: 'a, A: 'a {
14376
14377    hub: &'a Directory<C, A>,
14378    _request: Channel,
14379    _delegate: Option<&'a mut dyn Delegate>,
14380    _additional_params: HashMap<String, String>,
14381    _scopes: BTreeMap<String, ()>
14382}
14383
14384impl<'a, C, A> CallBuilder for ChannelStopCall<'a, C, A> {}
14385
14386impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
14387
14388
14389    /// Perform the operation you have build so far.
14390    pub fn doit(mut self) -> Result<hyper::client::Response> {
14391        use std::io::{Read, Seek};
14392        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
14393        let mut dd = DefaultDelegate;
14394        let mut dlg: &mut dyn Delegate = match self._delegate {
14395            Some(d) => d,
14396            None => &mut dd
14397        };
14398        dlg.begin(MethodInfo { id: "admin.channels.stop",
14399                               http_method: hyper::method::Method::Post });
14400        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
14401        for &field in [].iter() {
14402            if self._additional_params.contains_key(field) {
14403                dlg.finished(false);
14404                return Err(Error::FieldClash(field));
14405            }
14406        }
14407        for (name, value) in self._additional_params.iter() {
14408            params.push((&name, value.clone()));
14409        }
14410
14411
14412        let mut url = self.hub._base_url.clone() + "/admin/directory_v1/channels/stop";
14413        if self._scopes.len() == 0 {
14414            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
14415        }
14416
14417
14418        let url = hyper::Url::parse_with_params(&url, params).unwrap();
14419
14420        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
14421        let mut request_value_reader =
14422            {
14423                let mut value = json::value::to_value(&self._request).expect("serde to work");
14424                remove_json_null_values(&mut value);
14425                let mut dst = io::Cursor::new(Vec::with_capacity(128));
14426                json::to_writer(&mut dst, &value).unwrap();
14427                dst
14428            };
14429        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
14430        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
14431
14432
14433        loop {
14434            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
14435                Ok(token) => token,
14436                Err(err) => {
14437                    match  dlg.token(&*err) {
14438                        Some(token) => token,
14439                        None => {
14440                            dlg.finished(false);
14441                            return Err(Error::MissingToken(err))
14442                        }
14443                    }
14444                }
14445            };
14446            let auth_header = Authorization(Bearer { token: token.access_token });
14447            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
14448            let mut req_result = {
14449                let mut client = &mut *self.hub.client.borrow_mut();
14450                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
14451                    .header(UserAgent(self.hub._user_agent.clone()))
14452                    .header(auth_header.clone())
14453                    .header(ContentType(json_mime_type.clone()))
14454                    .header(ContentLength(request_size as u64))
14455                    .body(&mut request_value_reader);
14456
14457                dlg.pre_request();
14458                req.send()
14459            };
14460
14461            match req_result {
14462                Err(err) => {
14463                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
14464                        sleep(d);
14465                        continue;
14466                    }
14467                    dlg.finished(false);
14468                    return Err(Error::HttpError(err))
14469                }
14470                Ok(mut res) => {
14471                    if !res.status.is_success() {
14472                        let mut json_err = String::new();
14473                        res.read_to_string(&mut json_err).unwrap();
14474                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
14475                                                              json::from_str(&json_err).ok(),
14476                                                              json::from_str(&json_err).ok()) {
14477                            sleep(d);
14478                            continue;
14479                        }
14480                        dlg.finished(false);
14481                        return match json::from_str::<ErrorResponse>(&json_err){
14482                            Err(_) => Err(Error::Failure(res)),
14483                            Ok(serr) => Err(Error::BadRequest(serr))
14484                        }
14485                    }
14486                    let result_value = res;
14487
14488                    dlg.finished(true);
14489                    return Ok(result_value)
14490                }
14491            }
14492        }
14493    }
14494
14495
14496    ///
14497    /// Sets the *request* property to the given value.
14498    ///
14499    /// Even though the property as already been set when instantiating this call,
14500    /// we provide this method for API completeness.
14501    pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C, A> {
14502        self._request = new_value;
14503        self
14504    }
14505    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14506    /// while executing the actual API request.
14507    /// 
14508    /// It should be used to handle progress information, and to implement a certain level of resilience.
14509    ///
14510    /// Sets the *delegate* property to the given value.
14511    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ChannelStopCall<'a, C, A> {
14512        self._delegate = Some(new_value);
14513        self
14514    }
14515
14516    /// Set any additional parameter of the query string used in the request.
14517    /// It should be used to set parameters which are not yet available through their own
14518    /// setters.
14519    ///
14520    /// Please note that this method must not be used to set any of the known parameters
14521    /// which have their own setter method. If done anyway, the request will fail.
14522    ///
14523    /// # Additional Parameters
14524    ///
14525    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14526    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14527    /// * *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.
14528    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14529    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14530    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14531    /// * *alt* (query-string) - Data format for the response.
14532    pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C, A>
14533                                                        where T: AsRef<str> {
14534        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
14535        self
14536    }
14537
14538    /// Identifies the authorization scope for the method you are building.
14539    ///
14540    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
14541    /// `Scope::DirectoryUser`.
14542    ///
14543    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14544    /// tokens for more than one scope.
14545    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
14546    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
14547    /// function for details).
14548    ///
14549    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14550    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14551    /// sufficient, a read-write scope will do as well.
14552    pub fn add_scope<T, S>(mut self, scope: T) -> ChannelStopCall<'a, C, A>
14553                                                        where T: Into<Option<S>>,
14554                                                              S: AsRef<str> {
14555        match scope.into() {
14556          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
14557          None => None,
14558        };
14559        self
14560    }
14561}
14562
14563
14564/// Retrieve Mobile Device
14565///
14566/// A builder for the *get* method supported by a *mobiledevice* resource.
14567/// It is not used directly, but through a `MobiledeviceMethods` instance.
14568///
14569/// # Example
14570///
14571/// Instantiate a resource method builder
14572///
14573/// ```test_harness,no_run
14574/// # extern crate hyper;
14575/// # extern crate hyper_rustls;
14576/// # extern crate yup_oauth2 as oauth2;
14577/// # extern crate google_admin1_directory as admin1_directory;
14578/// # #[test] fn egal() {
14579/// # use std::default::Default;
14580/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
14581/// # use admin1_directory::Directory;
14582/// 
14583/// # let secret: ApplicationSecret = Default::default();
14584/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
14585/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
14586/// #                               <MemoryStorage as Default>::default(), None);
14587/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
14588/// // You can configure optional parameters by calling the respective setters at will, and
14589/// // execute the final call using `doit()`.
14590/// // Values shown here are possibly random and not representative !
14591/// let result = hub.mobiledevices().get("customerId", "resourceId")
14592///              .projection("sadipscing")
14593///              .doit();
14594/// # }
14595/// ```
14596pub struct MobiledeviceGetCall<'a, C, A>
14597    where C: 'a, A: 'a {
14598
14599    hub: &'a Directory<C, A>,
14600    _customer_id: String,
14601    _resource_id: String,
14602    _projection: Option<String>,
14603    _delegate: Option<&'a mut dyn Delegate>,
14604    _additional_params: HashMap<String, String>,
14605    _scopes: BTreeMap<String, ()>
14606}
14607
14608impl<'a, C, A> CallBuilder for MobiledeviceGetCall<'a, C, A> {}
14609
14610impl<'a, C, A> MobiledeviceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
14611
14612
14613    /// Perform the operation you have build so far.
14614    pub fn doit(mut self) -> Result<(hyper::client::Response, MobileDevice)> {
14615        use std::io::{Read, Seek};
14616        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
14617        let mut dd = DefaultDelegate;
14618        let mut dlg: &mut dyn Delegate = match self._delegate {
14619            Some(d) => d,
14620            None => &mut dd
14621        };
14622        dlg.begin(MethodInfo { id: "directory.mobiledevices.get",
14623                               http_method: hyper::method::Method::Get });
14624        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
14625        params.push(("customerId", self._customer_id.to_string()));
14626        params.push(("resourceId", self._resource_id.to_string()));
14627        if let Some(value) = self._projection {
14628            params.push(("projection", value.to_string()));
14629        }
14630        for &field in ["alt", "customerId", "resourceId", "projection"].iter() {
14631            if self._additional_params.contains_key(field) {
14632                dlg.finished(false);
14633                return Err(Error::FieldClash(field));
14634            }
14635        }
14636        for (name, value) in self._additional_params.iter() {
14637            params.push((&name, value.clone()));
14638        }
14639
14640        params.push(("alt", "json".to_string()));
14641
14642        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/mobile/{resourceId}";
14643        if self._scopes.len() == 0 {
14644            self._scopes.insert(Scope::DirectoryDeviceMobileReadonly.as_ref().to_string(), ());
14645        }
14646
14647        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{resourceId}", "resourceId")].iter() {
14648            let mut replace_with: Option<&str> = None;
14649            for &(name, ref value) in params.iter() {
14650                if name == param_name {
14651                    replace_with = Some(value);
14652                    break;
14653                }
14654            }
14655            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
14656        }
14657        {
14658            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
14659            for param_name in ["resourceId", "customerId"].iter() {
14660                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
14661                    indices_for_removal.push(index);
14662                }
14663            }
14664            for &index in indices_for_removal.iter() {
14665                params.remove(index);
14666            }
14667        }
14668
14669        let url = hyper::Url::parse_with_params(&url, params).unwrap();
14670
14671
14672
14673        loop {
14674            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
14675                Ok(token) => token,
14676                Err(err) => {
14677                    match  dlg.token(&*err) {
14678                        Some(token) => token,
14679                        None => {
14680                            dlg.finished(false);
14681                            return Err(Error::MissingToken(err))
14682                        }
14683                    }
14684                }
14685            };
14686            let auth_header = Authorization(Bearer { token: token.access_token });
14687            let mut req_result = {
14688                let mut client = &mut *self.hub.client.borrow_mut();
14689                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
14690                    .header(UserAgent(self.hub._user_agent.clone()))
14691                    .header(auth_header.clone());
14692
14693                dlg.pre_request();
14694                req.send()
14695            };
14696
14697            match req_result {
14698                Err(err) => {
14699                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
14700                        sleep(d);
14701                        continue;
14702                    }
14703                    dlg.finished(false);
14704                    return Err(Error::HttpError(err))
14705                }
14706                Ok(mut res) => {
14707                    if !res.status.is_success() {
14708                        let mut json_err = String::new();
14709                        res.read_to_string(&mut json_err).unwrap();
14710                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
14711                                                              json::from_str(&json_err).ok(),
14712                                                              json::from_str(&json_err).ok()) {
14713                            sleep(d);
14714                            continue;
14715                        }
14716                        dlg.finished(false);
14717                        return match json::from_str::<ErrorResponse>(&json_err){
14718                            Err(_) => Err(Error::Failure(res)),
14719                            Ok(serr) => Err(Error::BadRequest(serr))
14720                        }
14721                    }
14722                    let result_value = {
14723                        let mut json_response = String::new();
14724                        res.read_to_string(&mut json_response).unwrap();
14725                        match json::from_str(&json_response) {
14726                            Ok(decoded) => (res, decoded),
14727                            Err(err) => {
14728                                dlg.response_json_decode_error(&json_response, &err);
14729                                return Err(Error::JsonDecodeError(json_response, err));
14730                            }
14731                        }
14732                    };
14733
14734                    dlg.finished(true);
14735                    return Ok(result_value)
14736                }
14737            }
14738        }
14739    }
14740
14741
14742    /// Immutable ID of the G Suite account
14743    ///
14744    /// Sets the *customer id* path property to the given value.
14745    ///
14746    /// Even though the property as already been set when instantiating this call,
14747    /// we provide this method for API completeness.
14748    pub fn customer_id(mut self, new_value: &str) -> MobiledeviceGetCall<'a, C, A> {
14749        self._customer_id = new_value.to_string();
14750        self
14751    }
14752    /// Immutable ID of Mobile Device
14753    ///
14754    /// Sets the *resource id* path property to the given value.
14755    ///
14756    /// Even though the property as already been set when instantiating this call,
14757    /// we provide this method for API completeness.
14758    pub fn resource_id(mut self, new_value: &str) -> MobiledeviceGetCall<'a, C, A> {
14759        self._resource_id = new_value.to_string();
14760        self
14761    }
14762    /// Restrict information returned to a set of selected fields.
14763    ///
14764    /// Sets the *projection* query property to the given value.
14765    pub fn projection(mut self, new_value: &str) -> MobiledeviceGetCall<'a, C, A> {
14766        self._projection = Some(new_value.to_string());
14767        self
14768    }
14769    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14770    /// while executing the actual API request.
14771    /// 
14772    /// It should be used to handle progress information, and to implement a certain level of resilience.
14773    ///
14774    /// Sets the *delegate* property to the given value.
14775    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MobiledeviceGetCall<'a, C, A> {
14776        self._delegate = Some(new_value);
14777        self
14778    }
14779
14780    /// Set any additional parameter of the query string used in the request.
14781    /// It should be used to set parameters which are not yet available through their own
14782    /// setters.
14783    ///
14784    /// Please note that this method must not be used to set any of the known parameters
14785    /// which have their own setter method. If done anyway, the request will fail.
14786    ///
14787    /// # Additional Parameters
14788    ///
14789    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14790    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14791    /// * *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.
14792    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14793    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14794    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14795    /// * *alt* (query-string) - Data format for the response.
14796    pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceGetCall<'a, C, A>
14797                                                        where T: AsRef<str> {
14798        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
14799        self
14800    }
14801
14802    /// Identifies the authorization scope for the method you are building.
14803    ///
14804    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
14805    /// `Scope::DirectoryDeviceMobileReadonly`.
14806    ///
14807    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14808    /// tokens for more than one scope.
14809    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
14810    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
14811    /// function for details).
14812    ///
14813    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14814    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14815    /// sufficient, a read-write scope will do as well.
14816    pub fn add_scope<T, S>(mut self, scope: T) -> MobiledeviceGetCall<'a, C, A>
14817                                                        where T: Into<Option<S>>,
14818                                                              S: AsRef<str> {
14819        match scope.into() {
14820          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
14821          None => None,
14822        };
14823        self
14824    }
14825}
14826
14827
14828/// Retrieve all Mobile Devices of a customer (paginated)
14829///
14830/// A builder for the *list* method supported by a *mobiledevice* resource.
14831/// It is not used directly, but through a `MobiledeviceMethods` instance.
14832///
14833/// # Example
14834///
14835/// Instantiate a resource method builder
14836///
14837/// ```test_harness,no_run
14838/// # extern crate hyper;
14839/// # extern crate hyper_rustls;
14840/// # extern crate yup_oauth2 as oauth2;
14841/// # extern crate google_admin1_directory as admin1_directory;
14842/// # #[test] fn egal() {
14843/// # use std::default::Default;
14844/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
14845/// # use admin1_directory::Directory;
14846/// 
14847/// # let secret: ApplicationSecret = Default::default();
14848/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
14849/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
14850/// #                               <MemoryStorage as Default>::default(), None);
14851/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
14852/// // You can configure optional parameters by calling the respective setters at will, and
14853/// // execute the final call using `doit()`.
14854/// // Values shown here are possibly random and not representative !
14855/// let result = hub.mobiledevices().list("customerId")
14856///              .sort_order("dolore")
14857///              .query("nonumy")
14858///              .projection("sed")
14859///              .page_token("aliquyam")
14860///              .order_by("sit")
14861///              .max_results(-40)
14862///              .doit();
14863/// # }
14864/// ```
14865pub struct MobiledeviceListCall<'a, C, A>
14866    where C: 'a, A: 'a {
14867
14868    hub: &'a Directory<C, A>,
14869    _customer_id: String,
14870    _sort_order: Option<String>,
14871    _query: Option<String>,
14872    _projection: Option<String>,
14873    _page_token: Option<String>,
14874    _order_by: Option<String>,
14875    _max_results: Option<i32>,
14876    _delegate: Option<&'a mut dyn Delegate>,
14877    _additional_params: HashMap<String, String>,
14878    _scopes: BTreeMap<String, ()>
14879}
14880
14881impl<'a, C, A> CallBuilder for MobiledeviceListCall<'a, C, A> {}
14882
14883impl<'a, C, A> MobiledeviceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
14884
14885
14886    /// Perform the operation you have build so far.
14887    pub fn doit(mut self) -> Result<(hyper::client::Response, MobileDevices)> {
14888        use std::io::{Read, Seek};
14889        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
14890        let mut dd = DefaultDelegate;
14891        let mut dlg: &mut dyn Delegate = match self._delegate {
14892            Some(d) => d,
14893            None => &mut dd
14894        };
14895        dlg.begin(MethodInfo { id: "directory.mobiledevices.list",
14896                               http_method: hyper::method::Method::Get });
14897        let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len());
14898        params.push(("customerId", self._customer_id.to_string()));
14899        if let Some(value) = self._sort_order {
14900            params.push(("sortOrder", value.to_string()));
14901        }
14902        if let Some(value) = self._query {
14903            params.push(("query", value.to_string()));
14904        }
14905        if let Some(value) = self._projection {
14906            params.push(("projection", value.to_string()));
14907        }
14908        if let Some(value) = self._page_token {
14909            params.push(("pageToken", value.to_string()));
14910        }
14911        if let Some(value) = self._order_by {
14912            params.push(("orderBy", value.to_string()));
14913        }
14914        if let Some(value) = self._max_results {
14915            params.push(("maxResults", value.to_string()));
14916        }
14917        for &field in ["alt", "customerId", "sortOrder", "query", "projection", "pageToken", "orderBy", "maxResults"].iter() {
14918            if self._additional_params.contains_key(field) {
14919                dlg.finished(false);
14920                return Err(Error::FieldClash(field));
14921            }
14922        }
14923        for (name, value) in self._additional_params.iter() {
14924            params.push((&name, value.clone()));
14925        }
14926
14927        params.push(("alt", "json".to_string()));
14928
14929        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/mobile";
14930        if self._scopes.len() == 0 {
14931            self._scopes.insert(Scope::DirectoryDeviceMobileReadonly.as_ref().to_string(), ());
14932        }
14933
14934        for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
14935            let mut replace_with: Option<&str> = None;
14936            for &(name, ref value) in params.iter() {
14937                if name == param_name {
14938                    replace_with = Some(value);
14939                    break;
14940                }
14941            }
14942            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
14943        }
14944        {
14945            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
14946            for param_name in ["customerId"].iter() {
14947                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
14948                    indices_for_removal.push(index);
14949                }
14950            }
14951            for &index in indices_for_removal.iter() {
14952                params.remove(index);
14953            }
14954        }
14955
14956        let url = hyper::Url::parse_with_params(&url, params).unwrap();
14957
14958
14959
14960        loop {
14961            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
14962                Ok(token) => token,
14963                Err(err) => {
14964                    match  dlg.token(&*err) {
14965                        Some(token) => token,
14966                        None => {
14967                            dlg.finished(false);
14968                            return Err(Error::MissingToken(err))
14969                        }
14970                    }
14971                }
14972            };
14973            let auth_header = Authorization(Bearer { token: token.access_token });
14974            let mut req_result = {
14975                let mut client = &mut *self.hub.client.borrow_mut();
14976                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
14977                    .header(UserAgent(self.hub._user_agent.clone()))
14978                    .header(auth_header.clone());
14979
14980                dlg.pre_request();
14981                req.send()
14982            };
14983
14984            match req_result {
14985                Err(err) => {
14986                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
14987                        sleep(d);
14988                        continue;
14989                    }
14990                    dlg.finished(false);
14991                    return Err(Error::HttpError(err))
14992                }
14993                Ok(mut res) => {
14994                    if !res.status.is_success() {
14995                        let mut json_err = String::new();
14996                        res.read_to_string(&mut json_err).unwrap();
14997                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
14998                                                              json::from_str(&json_err).ok(),
14999                                                              json::from_str(&json_err).ok()) {
15000                            sleep(d);
15001                            continue;
15002                        }
15003                        dlg.finished(false);
15004                        return match json::from_str::<ErrorResponse>(&json_err){
15005                            Err(_) => Err(Error::Failure(res)),
15006                            Ok(serr) => Err(Error::BadRequest(serr))
15007                        }
15008                    }
15009                    let result_value = {
15010                        let mut json_response = String::new();
15011                        res.read_to_string(&mut json_response).unwrap();
15012                        match json::from_str(&json_response) {
15013                            Ok(decoded) => (res, decoded),
15014                            Err(err) => {
15015                                dlg.response_json_decode_error(&json_response, &err);
15016                                return Err(Error::JsonDecodeError(json_response, err));
15017                            }
15018                        }
15019                    };
15020
15021                    dlg.finished(true);
15022                    return Ok(result_value)
15023                }
15024            }
15025        }
15026    }
15027
15028
15029    /// Immutable ID of the G Suite account
15030    ///
15031    /// Sets the *customer id* path property to the given value.
15032    ///
15033    /// Even though the property as already been set when instantiating this call,
15034    /// we provide this method for API completeness.
15035    pub fn customer_id(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
15036        self._customer_id = new_value.to_string();
15037        self
15038    }
15039    /// Whether to return results in ascending or descending order. Only of use when orderBy is also used
15040    ///
15041    /// Sets the *sort order* query property to the given value.
15042    pub fn sort_order(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
15043        self._sort_order = Some(new_value.to_string());
15044        self
15045    }
15046    /// Search string in the format given at http://support.google.com/a/bin/answer.py?answer=1408863#search
15047    ///
15048    /// Sets the *query* query property to the given value.
15049    pub fn query(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
15050        self._query = Some(new_value.to_string());
15051        self
15052    }
15053    /// Restrict information returned to a set of selected fields.
15054    ///
15055    /// Sets the *projection* query property to the given value.
15056    pub fn projection(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
15057        self._projection = Some(new_value.to_string());
15058        self
15059    }
15060    /// Token to specify next page in the list
15061    ///
15062    /// Sets the *page token* query property to the given value.
15063    pub fn page_token(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
15064        self._page_token = Some(new_value.to_string());
15065        self
15066    }
15067    /// Column to use for sorting results
15068    ///
15069    /// Sets the *order by* query property to the given value.
15070    pub fn order_by(mut self, new_value: &str) -> MobiledeviceListCall<'a, C, A> {
15071        self._order_by = Some(new_value.to_string());
15072        self
15073    }
15074    /// Maximum number of results to return. Max allowed value is 100.
15075    ///
15076    /// Sets the *max results* query property to the given value.
15077    pub fn max_results(mut self, new_value: i32) -> MobiledeviceListCall<'a, C, A> {
15078        self._max_results = Some(new_value);
15079        self
15080    }
15081    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15082    /// while executing the actual API request.
15083    /// 
15084    /// It should be used to handle progress information, and to implement a certain level of resilience.
15085    ///
15086    /// Sets the *delegate* property to the given value.
15087    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MobiledeviceListCall<'a, C, A> {
15088        self._delegate = Some(new_value);
15089        self
15090    }
15091
15092    /// Set any additional parameter of the query string used in the request.
15093    /// It should be used to set parameters which are not yet available through their own
15094    /// setters.
15095    ///
15096    /// Please note that this method must not be used to set any of the known parameters
15097    /// which have their own setter method. If done anyway, the request will fail.
15098    ///
15099    /// # Additional Parameters
15100    ///
15101    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15102    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15103    /// * *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.
15104    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15105    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15106    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15107    /// * *alt* (query-string) - Data format for the response.
15108    pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceListCall<'a, C, A>
15109                                                        where T: AsRef<str> {
15110        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
15111        self
15112    }
15113
15114    /// Identifies the authorization scope for the method you are building.
15115    ///
15116    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
15117    /// `Scope::DirectoryDeviceMobileReadonly`.
15118    ///
15119    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15120    /// tokens for more than one scope.
15121    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
15122    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
15123    /// function for details).
15124    ///
15125    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15126    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15127    /// sufficient, a read-write scope will do as well.
15128    pub fn add_scope<T, S>(mut self, scope: T) -> MobiledeviceListCall<'a, C, A>
15129                                                        where T: Into<Option<S>>,
15130                                                              S: AsRef<str> {
15131        match scope.into() {
15132          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
15133          None => None,
15134        };
15135        self
15136    }
15137}
15138
15139
15140/// Delete Mobile Device
15141///
15142/// A builder for the *delete* method supported by a *mobiledevice* resource.
15143/// It is not used directly, but through a `MobiledeviceMethods` instance.
15144///
15145/// # Example
15146///
15147/// Instantiate a resource method builder
15148///
15149/// ```test_harness,no_run
15150/// # extern crate hyper;
15151/// # extern crate hyper_rustls;
15152/// # extern crate yup_oauth2 as oauth2;
15153/// # extern crate google_admin1_directory as admin1_directory;
15154/// # #[test] fn egal() {
15155/// # use std::default::Default;
15156/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
15157/// # use admin1_directory::Directory;
15158/// 
15159/// # let secret: ApplicationSecret = Default::default();
15160/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
15161/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
15162/// #                               <MemoryStorage as Default>::default(), None);
15163/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
15164/// // You can configure optional parameters by calling the respective setters at will, and
15165/// // execute the final call using `doit()`.
15166/// // Values shown here are possibly random and not representative !
15167/// let result = hub.mobiledevices().delete("customerId", "resourceId")
15168///              .doit();
15169/// # }
15170/// ```
15171pub struct MobiledeviceDeleteCall<'a, C, A>
15172    where C: 'a, A: 'a {
15173
15174    hub: &'a Directory<C, A>,
15175    _customer_id: String,
15176    _resource_id: String,
15177    _delegate: Option<&'a mut dyn Delegate>,
15178    _additional_params: HashMap<String, String>,
15179    _scopes: BTreeMap<String, ()>
15180}
15181
15182impl<'a, C, A> CallBuilder for MobiledeviceDeleteCall<'a, C, A> {}
15183
15184impl<'a, C, A> MobiledeviceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
15185
15186
15187    /// Perform the operation you have build so far.
15188    pub fn doit(mut self) -> Result<hyper::client::Response> {
15189        use std::io::{Read, Seek};
15190        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
15191        let mut dd = DefaultDelegate;
15192        let mut dlg: &mut dyn Delegate = match self._delegate {
15193            Some(d) => d,
15194            None => &mut dd
15195        };
15196        dlg.begin(MethodInfo { id: "directory.mobiledevices.delete",
15197                               http_method: hyper::method::Method::Delete });
15198        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
15199        params.push(("customerId", self._customer_id.to_string()));
15200        params.push(("resourceId", self._resource_id.to_string()));
15201        for &field in ["customerId", "resourceId"].iter() {
15202            if self._additional_params.contains_key(field) {
15203                dlg.finished(false);
15204                return Err(Error::FieldClash(field));
15205            }
15206        }
15207        for (name, value) in self._additional_params.iter() {
15208            params.push((&name, value.clone()));
15209        }
15210
15211
15212        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/mobile/{resourceId}";
15213        if self._scopes.len() == 0 {
15214            self._scopes.insert(Scope::DirectoryDeviceMobile.as_ref().to_string(), ());
15215        }
15216
15217        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{resourceId}", "resourceId")].iter() {
15218            let mut replace_with: Option<&str> = None;
15219            for &(name, ref value) in params.iter() {
15220                if name == param_name {
15221                    replace_with = Some(value);
15222                    break;
15223                }
15224            }
15225            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
15226        }
15227        {
15228            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
15229            for param_name in ["resourceId", "customerId"].iter() {
15230                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15231                    indices_for_removal.push(index);
15232                }
15233            }
15234            for &index in indices_for_removal.iter() {
15235                params.remove(index);
15236            }
15237        }
15238
15239        let url = hyper::Url::parse_with_params(&url, params).unwrap();
15240
15241
15242
15243        loop {
15244            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
15245                Ok(token) => token,
15246                Err(err) => {
15247                    match  dlg.token(&*err) {
15248                        Some(token) => token,
15249                        None => {
15250                            dlg.finished(false);
15251                            return Err(Error::MissingToken(err))
15252                        }
15253                    }
15254                }
15255            };
15256            let auth_header = Authorization(Bearer { token: token.access_token });
15257            let mut req_result = {
15258                let mut client = &mut *self.hub.client.borrow_mut();
15259                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
15260                    .header(UserAgent(self.hub._user_agent.clone()))
15261                    .header(auth_header.clone());
15262
15263                dlg.pre_request();
15264                req.send()
15265            };
15266
15267            match req_result {
15268                Err(err) => {
15269                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
15270                        sleep(d);
15271                        continue;
15272                    }
15273                    dlg.finished(false);
15274                    return Err(Error::HttpError(err))
15275                }
15276                Ok(mut res) => {
15277                    if !res.status.is_success() {
15278                        let mut json_err = String::new();
15279                        res.read_to_string(&mut json_err).unwrap();
15280                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
15281                                                              json::from_str(&json_err).ok(),
15282                                                              json::from_str(&json_err).ok()) {
15283                            sleep(d);
15284                            continue;
15285                        }
15286                        dlg.finished(false);
15287                        return match json::from_str::<ErrorResponse>(&json_err){
15288                            Err(_) => Err(Error::Failure(res)),
15289                            Ok(serr) => Err(Error::BadRequest(serr))
15290                        }
15291                    }
15292                    let result_value = res;
15293
15294                    dlg.finished(true);
15295                    return Ok(result_value)
15296                }
15297            }
15298        }
15299    }
15300
15301
15302    /// Immutable ID of the G Suite account
15303    ///
15304    /// Sets the *customer id* path property to the given value.
15305    ///
15306    /// Even though the property as already been set when instantiating this call,
15307    /// we provide this method for API completeness.
15308    pub fn customer_id(mut self, new_value: &str) -> MobiledeviceDeleteCall<'a, C, A> {
15309        self._customer_id = new_value.to_string();
15310        self
15311    }
15312    /// Immutable ID of Mobile Device
15313    ///
15314    /// Sets the *resource id* path property to the given value.
15315    ///
15316    /// Even though the property as already been set when instantiating this call,
15317    /// we provide this method for API completeness.
15318    pub fn resource_id(mut self, new_value: &str) -> MobiledeviceDeleteCall<'a, C, A> {
15319        self._resource_id = new_value.to_string();
15320        self
15321    }
15322    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15323    /// while executing the actual API request.
15324    /// 
15325    /// It should be used to handle progress information, and to implement a certain level of resilience.
15326    ///
15327    /// Sets the *delegate* property to the given value.
15328    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MobiledeviceDeleteCall<'a, C, A> {
15329        self._delegate = Some(new_value);
15330        self
15331    }
15332
15333    /// Set any additional parameter of the query string used in the request.
15334    /// It should be used to set parameters which are not yet available through their own
15335    /// setters.
15336    ///
15337    /// Please note that this method must not be used to set any of the known parameters
15338    /// which have their own setter method. If done anyway, the request will fail.
15339    ///
15340    /// # Additional Parameters
15341    ///
15342    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15343    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15344    /// * *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.
15345    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15346    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15347    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15348    /// * *alt* (query-string) - Data format for the response.
15349    pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceDeleteCall<'a, C, A>
15350                                                        where T: AsRef<str> {
15351        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
15352        self
15353    }
15354
15355    /// Identifies the authorization scope for the method you are building.
15356    ///
15357    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
15358    /// `Scope::DirectoryDeviceMobile`.
15359    ///
15360    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15361    /// tokens for more than one scope.
15362    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
15363    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
15364    /// function for details).
15365    ///
15366    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15367    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15368    /// sufficient, a read-write scope will do as well.
15369    pub fn add_scope<T, S>(mut self, scope: T) -> MobiledeviceDeleteCall<'a, C, A>
15370                                                        where T: Into<Option<S>>,
15371                                                              S: AsRef<str> {
15372        match scope.into() {
15373          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
15374          None => None,
15375        };
15376        self
15377    }
15378}
15379
15380
15381/// Take action on Mobile Device
15382///
15383/// A builder for the *action* method supported by a *mobiledevice* resource.
15384/// It is not used directly, but through a `MobiledeviceMethods` instance.
15385///
15386/// # Example
15387///
15388/// Instantiate a resource method builder
15389///
15390/// ```test_harness,no_run
15391/// # extern crate hyper;
15392/// # extern crate hyper_rustls;
15393/// # extern crate yup_oauth2 as oauth2;
15394/// # extern crate google_admin1_directory as admin1_directory;
15395/// use admin1_directory::MobileDeviceAction;
15396/// # #[test] fn egal() {
15397/// # use std::default::Default;
15398/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
15399/// # use admin1_directory::Directory;
15400/// 
15401/// # let secret: ApplicationSecret = Default::default();
15402/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
15403/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
15404/// #                               <MemoryStorage as Default>::default(), None);
15405/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
15406/// // As the method needs a request, you would usually fill it with the desired information
15407/// // into the respective structure. Some of the parts shown here might not be applicable !
15408/// // Values shown here are possibly random and not representative !
15409/// let mut req = MobileDeviceAction::default();
15410/// 
15411/// // You can configure optional parameters by calling the respective setters at will, and
15412/// // execute the final call using `doit()`.
15413/// // Values shown here are possibly random and not representative !
15414/// let result = hub.mobiledevices().action(req, "customerId", "resourceId")
15415///              .doit();
15416/// # }
15417/// ```
15418pub struct MobiledeviceActionCall<'a, C, A>
15419    where C: 'a, A: 'a {
15420
15421    hub: &'a Directory<C, A>,
15422    _request: MobileDeviceAction,
15423    _customer_id: String,
15424    _resource_id: String,
15425    _delegate: Option<&'a mut dyn Delegate>,
15426    _additional_params: HashMap<String, String>,
15427    _scopes: BTreeMap<String, ()>
15428}
15429
15430impl<'a, C, A> CallBuilder for MobiledeviceActionCall<'a, C, A> {}
15431
15432impl<'a, C, A> MobiledeviceActionCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
15433
15434
15435    /// Perform the operation you have build so far.
15436    pub fn doit(mut self) -> Result<hyper::client::Response> {
15437        use std::io::{Read, Seek};
15438        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
15439        let mut dd = DefaultDelegate;
15440        let mut dlg: &mut dyn Delegate = match self._delegate {
15441            Some(d) => d,
15442            None => &mut dd
15443        };
15444        dlg.begin(MethodInfo { id: "directory.mobiledevices.action",
15445                               http_method: hyper::method::Method::Post });
15446        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
15447        params.push(("customerId", self._customer_id.to_string()));
15448        params.push(("resourceId", self._resource_id.to_string()));
15449        for &field in ["customerId", "resourceId"].iter() {
15450            if self._additional_params.contains_key(field) {
15451                dlg.finished(false);
15452                return Err(Error::FieldClash(field));
15453            }
15454        }
15455        for (name, value) in self._additional_params.iter() {
15456            params.push((&name, value.clone()));
15457        }
15458
15459
15460        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/mobile/{resourceId}/action";
15461        if self._scopes.len() == 0 {
15462            self._scopes.insert(Scope::DirectoryDeviceMobile.as_ref().to_string(), ());
15463        }
15464
15465        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{resourceId}", "resourceId")].iter() {
15466            let mut replace_with: Option<&str> = None;
15467            for &(name, ref value) in params.iter() {
15468                if name == param_name {
15469                    replace_with = Some(value);
15470                    break;
15471                }
15472            }
15473            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
15474        }
15475        {
15476            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
15477            for param_name in ["resourceId", "customerId"].iter() {
15478                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15479                    indices_for_removal.push(index);
15480                }
15481            }
15482            for &index in indices_for_removal.iter() {
15483                params.remove(index);
15484            }
15485        }
15486
15487        let url = hyper::Url::parse_with_params(&url, params).unwrap();
15488
15489        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
15490        let mut request_value_reader =
15491            {
15492                let mut value = json::value::to_value(&self._request).expect("serde to work");
15493                remove_json_null_values(&mut value);
15494                let mut dst = io::Cursor::new(Vec::with_capacity(128));
15495                json::to_writer(&mut dst, &value).unwrap();
15496                dst
15497            };
15498        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
15499        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
15500
15501
15502        loop {
15503            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
15504                Ok(token) => token,
15505                Err(err) => {
15506                    match  dlg.token(&*err) {
15507                        Some(token) => token,
15508                        None => {
15509                            dlg.finished(false);
15510                            return Err(Error::MissingToken(err))
15511                        }
15512                    }
15513                }
15514            };
15515            let auth_header = Authorization(Bearer { token: token.access_token });
15516            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
15517            let mut req_result = {
15518                let mut client = &mut *self.hub.client.borrow_mut();
15519                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
15520                    .header(UserAgent(self.hub._user_agent.clone()))
15521                    .header(auth_header.clone())
15522                    .header(ContentType(json_mime_type.clone()))
15523                    .header(ContentLength(request_size as u64))
15524                    .body(&mut request_value_reader);
15525
15526                dlg.pre_request();
15527                req.send()
15528            };
15529
15530            match req_result {
15531                Err(err) => {
15532                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
15533                        sleep(d);
15534                        continue;
15535                    }
15536                    dlg.finished(false);
15537                    return Err(Error::HttpError(err))
15538                }
15539                Ok(mut res) => {
15540                    if !res.status.is_success() {
15541                        let mut json_err = String::new();
15542                        res.read_to_string(&mut json_err).unwrap();
15543                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
15544                                                              json::from_str(&json_err).ok(),
15545                                                              json::from_str(&json_err).ok()) {
15546                            sleep(d);
15547                            continue;
15548                        }
15549                        dlg.finished(false);
15550                        return match json::from_str::<ErrorResponse>(&json_err){
15551                            Err(_) => Err(Error::Failure(res)),
15552                            Ok(serr) => Err(Error::BadRequest(serr))
15553                        }
15554                    }
15555                    let result_value = res;
15556
15557                    dlg.finished(true);
15558                    return Ok(result_value)
15559                }
15560            }
15561        }
15562    }
15563
15564
15565    ///
15566    /// Sets the *request* property to the given value.
15567    ///
15568    /// Even though the property as already been set when instantiating this call,
15569    /// we provide this method for API completeness.
15570    pub fn request(mut self, new_value: MobileDeviceAction) -> MobiledeviceActionCall<'a, C, A> {
15571        self._request = new_value;
15572        self
15573    }
15574    /// Immutable ID of the G Suite account
15575    ///
15576    /// Sets the *customer id* path property to the given value.
15577    ///
15578    /// Even though the property as already been set when instantiating this call,
15579    /// we provide this method for API completeness.
15580    pub fn customer_id(mut self, new_value: &str) -> MobiledeviceActionCall<'a, C, A> {
15581        self._customer_id = new_value.to_string();
15582        self
15583    }
15584    /// Immutable ID of Mobile Device
15585    ///
15586    /// Sets the *resource id* path property to the given value.
15587    ///
15588    /// Even though the property as already been set when instantiating this call,
15589    /// we provide this method for API completeness.
15590    pub fn resource_id(mut self, new_value: &str) -> MobiledeviceActionCall<'a, C, A> {
15591        self._resource_id = new_value.to_string();
15592        self
15593    }
15594    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15595    /// while executing the actual API request.
15596    /// 
15597    /// It should be used to handle progress information, and to implement a certain level of resilience.
15598    ///
15599    /// Sets the *delegate* property to the given value.
15600    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MobiledeviceActionCall<'a, C, A> {
15601        self._delegate = Some(new_value);
15602        self
15603    }
15604
15605    /// Set any additional parameter of the query string used in the request.
15606    /// It should be used to set parameters which are not yet available through their own
15607    /// setters.
15608    ///
15609    /// Please note that this method must not be used to set any of the known parameters
15610    /// which have their own setter method. If done anyway, the request will fail.
15611    ///
15612    /// # Additional Parameters
15613    ///
15614    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15615    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15616    /// * *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.
15617    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15618    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15619    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15620    /// * *alt* (query-string) - Data format for the response.
15621    pub fn param<T>(mut self, name: T, value: T) -> MobiledeviceActionCall<'a, C, A>
15622                                                        where T: AsRef<str> {
15623        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
15624        self
15625    }
15626
15627    /// Identifies the authorization scope for the method you are building.
15628    ///
15629    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
15630    /// `Scope::DirectoryDeviceMobile`.
15631    ///
15632    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15633    /// tokens for more than one scope.
15634    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
15635    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
15636    /// function for details).
15637    ///
15638    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15639    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15640    /// sufficient, a read-write scope will do as well.
15641    pub fn add_scope<T, S>(mut self, scope: T) -> MobiledeviceActionCall<'a, C, A>
15642                                                        where T: Into<Option<S>>,
15643                                                              S: AsRef<str> {
15644        match scope.into() {
15645          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
15646          None => None,
15647        };
15648        self
15649    }
15650}
15651
15652
15653/// Get information about an access token issued by a user.
15654///
15655/// A builder for the *get* method supported by a *token* resource.
15656/// It is not used directly, but through a `TokenMethods` instance.
15657///
15658/// # Example
15659///
15660/// Instantiate a resource method builder
15661///
15662/// ```test_harness,no_run
15663/// # extern crate hyper;
15664/// # extern crate hyper_rustls;
15665/// # extern crate yup_oauth2 as oauth2;
15666/// # extern crate google_admin1_directory as admin1_directory;
15667/// # #[test] fn egal() {
15668/// # use std::default::Default;
15669/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
15670/// # use admin1_directory::Directory;
15671/// 
15672/// # let secret: ApplicationSecret = Default::default();
15673/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
15674/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
15675/// #                               <MemoryStorage as Default>::default(), None);
15676/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
15677/// // You can configure optional parameters by calling the respective setters at will, and
15678/// // execute the final call using `doit()`.
15679/// // Values shown here are possibly random and not representative !
15680/// let result = hub.tokens().get("userKey", "clientId")
15681///              .doit();
15682/// # }
15683/// ```
15684pub struct TokenGetCall<'a, C, A>
15685    where C: 'a, A: 'a {
15686
15687    hub: &'a Directory<C, A>,
15688    _user_key: String,
15689    _client_id: String,
15690    _delegate: Option<&'a mut dyn Delegate>,
15691    _additional_params: HashMap<String, String>,
15692    _scopes: BTreeMap<String, ()>
15693}
15694
15695impl<'a, C, A> CallBuilder for TokenGetCall<'a, C, A> {}
15696
15697impl<'a, C, A> TokenGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
15698
15699
15700    /// Perform the operation you have build so far.
15701    pub fn doit(mut self) -> Result<(hyper::client::Response, Token)> {
15702        use std::io::{Read, Seek};
15703        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
15704        let mut dd = DefaultDelegate;
15705        let mut dlg: &mut dyn Delegate = match self._delegate {
15706            Some(d) => d,
15707            None => &mut dd
15708        };
15709        dlg.begin(MethodInfo { id: "directory.tokens.get",
15710                               http_method: hyper::method::Method::Get });
15711        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
15712        params.push(("userKey", self._user_key.to_string()));
15713        params.push(("clientId", self._client_id.to_string()));
15714        for &field in ["alt", "userKey", "clientId"].iter() {
15715            if self._additional_params.contains_key(field) {
15716                dlg.finished(false);
15717                return Err(Error::FieldClash(field));
15718            }
15719        }
15720        for (name, value) in self._additional_params.iter() {
15721            params.push((&name, value.clone()));
15722        }
15723
15724        params.push(("alt", "json".to_string()));
15725
15726        let mut url = self.hub._base_url.clone() + "users/{userKey}/tokens/{clientId}";
15727        if self._scopes.len() == 0 {
15728            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
15729        }
15730
15731        for &(find_this, param_name) in [("{userKey}", "userKey"), ("{clientId}", "clientId")].iter() {
15732            let mut replace_with: Option<&str> = None;
15733            for &(name, ref value) in params.iter() {
15734                if name == param_name {
15735                    replace_with = Some(value);
15736                    break;
15737                }
15738            }
15739            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
15740        }
15741        {
15742            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
15743            for param_name in ["clientId", "userKey"].iter() {
15744                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15745                    indices_for_removal.push(index);
15746                }
15747            }
15748            for &index in indices_for_removal.iter() {
15749                params.remove(index);
15750            }
15751        }
15752
15753        let url = hyper::Url::parse_with_params(&url, params).unwrap();
15754
15755
15756
15757        loop {
15758            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
15759                Ok(token) => token,
15760                Err(err) => {
15761                    match  dlg.token(&*err) {
15762                        Some(token) => token,
15763                        None => {
15764                            dlg.finished(false);
15765                            return Err(Error::MissingToken(err))
15766                        }
15767                    }
15768                }
15769            };
15770            let auth_header = Authorization(Bearer { token: token.access_token });
15771            let mut req_result = {
15772                let mut client = &mut *self.hub.client.borrow_mut();
15773                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
15774                    .header(UserAgent(self.hub._user_agent.clone()))
15775                    .header(auth_header.clone());
15776
15777                dlg.pre_request();
15778                req.send()
15779            };
15780
15781            match req_result {
15782                Err(err) => {
15783                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
15784                        sleep(d);
15785                        continue;
15786                    }
15787                    dlg.finished(false);
15788                    return Err(Error::HttpError(err))
15789                }
15790                Ok(mut res) => {
15791                    if !res.status.is_success() {
15792                        let mut json_err = String::new();
15793                        res.read_to_string(&mut json_err).unwrap();
15794                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
15795                                                              json::from_str(&json_err).ok(),
15796                                                              json::from_str(&json_err).ok()) {
15797                            sleep(d);
15798                            continue;
15799                        }
15800                        dlg.finished(false);
15801                        return match json::from_str::<ErrorResponse>(&json_err){
15802                            Err(_) => Err(Error::Failure(res)),
15803                            Ok(serr) => Err(Error::BadRequest(serr))
15804                        }
15805                    }
15806                    let result_value = {
15807                        let mut json_response = String::new();
15808                        res.read_to_string(&mut json_response).unwrap();
15809                        match json::from_str(&json_response) {
15810                            Ok(decoded) => (res, decoded),
15811                            Err(err) => {
15812                                dlg.response_json_decode_error(&json_response, &err);
15813                                return Err(Error::JsonDecodeError(json_response, err));
15814                            }
15815                        }
15816                    };
15817
15818                    dlg.finished(true);
15819                    return Ok(result_value)
15820                }
15821            }
15822        }
15823    }
15824
15825
15826    /// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
15827    ///
15828    /// Sets the *user key* path property to the given value.
15829    ///
15830    /// Even though the property as already been set when instantiating this call,
15831    /// we provide this method for API completeness.
15832    pub fn user_key(mut self, new_value: &str) -> TokenGetCall<'a, C, A> {
15833        self._user_key = new_value.to_string();
15834        self
15835    }
15836    /// The Client ID of the application the token is issued to.
15837    ///
15838    /// Sets the *client id* path property to the given value.
15839    ///
15840    /// Even though the property as already been set when instantiating this call,
15841    /// we provide this method for API completeness.
15842    pub fn client_id(mut self, new_value: &str) -> TokenGetCall<'a, C, A> {
15843        self._client_id = new_value.to_string();
15844        self
15845    }
15846    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15847    /// while executing the actual API request.
15848    /// 
15849    /// It should be used to handle progress information, and to implement a certain level of resilience.
15850    ///
15851    /// Sets the *delegate* property to the given value.
15852    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> TokenGetCall<'a, C, A> {
15853        self._delegate = Some(new_value);
15854        self
15855    }
15856
15857    /// Set any additional parameter of the query string used in the request.
15858    /// It should be used to set parameters which are not yet available through their own
15859    /// setters.
15860    ///
15861    /// Please note that this method must not be used to set any of the known parameters
15862    /// which have their own setter method. If done anyway, the request will fail.
15863    ///
15864    /// # Additional Parameters
15865    ///
15866    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15867    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15868    /// * *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.
15869    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15870    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15871    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15872    /// * *alt* (query-string) - Data format for the response.
15873    pub fn param<T>(mut self, name: T, value: T) -> TokenGetCall<'a, C, A>
15874                                                        where T: AsRef<str> {
15875        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
15876        self
15877    }
15878
15879    /// Identifies the authorization scope for the method you are building.
15880    ///
15881    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
15882    /// `Scope::DirectoryUserSecurity`.
15883    ///
15884    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15885    /// tokens for more than one scope.
15886    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
15887    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
15888    /// function for details).
15889    ///
15890    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15891    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15892    /// sufficient, a read-write scope will do as well.
15893    pub fn add_scope<T, S>(mut self, scope: T) -> TokenGetCall<'a, C, A>
15894                                                        where T: Into<Option<S>>,
15895                                                              S: AsRef<str> {
15896        match scope.into() {
15897          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
15898          None => None,
15899        };
15900        self
15901    }
15902}
15903
15904
15905/// Returns the set of tokens specified user has issued to 3rd party applications.
15906///
15907/// A builder for the *list* method supported by a *token* resource.
15908/// It is not used directly, but through a `TokenMethods` instance.
15909///
15910/// # Example
15911///
15912/// Instantiate a resource method builder
15913///
15914/// ```test_harness,no_run
15915/// # extern crate hyper;
15916/// # extern crate hyper_rustls;
15917/// # extern crate yup_oauth2 as oauth2;
15918/// # extern crate google_admin1_directory as admin1_directory;
15919/// # #[test] fn egal() {
15920/// # use std::default::Default;
15921/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
15922/// # use admin1_directory::Directory;
15923/// 
15924/// # let secret: ApplicationSecret = Default::default();
15925/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
15926/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
15927/// #                               <MemoryStorage as Default>::default(), None);
15928/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
15929/// // You can configure optional parameters by calling the respective setters at will, and
15930/// // execute the final call using `doit()`.
15931/// // Values shown here are possibly random and not representative !
15932/// let result = hub.tokens().list("userKey")
15933///              .doit();
15934/// # }
15935/// ```
15936pub struct TokenListCall<'a, C, A>
15937    where C: 'a, A: 'a {
15938
15939    hub: &'a Directory<C, A>,
15940    _user_key: String,
15941    _delegate: Option<&'a mut dyn Delegate>,
15942    _additional_params: HashMap<String, String>,
15943    _scopes: BTreeMap<String, ()>
15944}
15945
15946impl<'a, C, A> CallBuilder for TokenListCall<'a, C, A> {}
15947
15948impl<'a, C, A> TokenListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
15949
15950
15951    /// Perform the operation you have build so far.
15952    pub fn doit(mut self) -> Result<(hyper::client::Response, Tokens)> {
15953        use std::io::{Read, Seek};
15954        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
15955        let mut dd = DefaultDelegate;
15956        let mut dlg: &mut dyn Delegate = match self._delegate {
15957            Some(d) => d,
15958            None => &mut dd
15959        };
15960        dlg.begin(MethodInfo { id: "directory.tokens.list",
15961                               http_method: hyper::method::Method::Get });
15962        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
15963        params.push(("userKey", self._user_key.to_string()));
15964        for &field in ["alt", "userKey"].iter() {
15965            if self._additional_params.contains_key(field) {
15966                dlg.finished(false);
15967                return Err(Error::FieldClash(field));
15968            }
15969        }
15970        for (name, value) in self._additional_params.iter() {
15971            params.push((&name, value.clone()));
15972        }
15973
15974        params.push(("alt", "json".to_string()));
15975
15976        let mut url = self.hub._base_url.clone() + "users/{userKey}/tokens";
15977        if self._scopes.len() == 0 {
15978            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
15979        }
15980
15981        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
15982            let mut replace_with: Option<&str> = None;
15983            for &(name, ref value) in params.iter() {
15984                if name == param_name {
15985                    replace_with = Some(value);
15986                    break;
15987                }
15988            }
15989            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
15990        }
15991        {
15992            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
15993            for param_name in ["userKey"].iter() {
15994                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15995                    indices_for_removal.push(index);
15996                }
15997            }
15998            for &index in indices_for_removal.iter() {
15999                params.remove(index);
16000            }
16001        }
16002
16003        let url = hyper::Url::parse_with_params(&url, params).unwrap();
16004
16005
16006
16007        loop {
16008            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
16009                Ok(token) => token,
16010                Err(err) => {
16011                    match  dlg.token(&*err) {
16012                        Some(token) => token,
16013                        None => {
16014                            dlg.finished(false);
16015                            return Err(Error::MissingToken(err))
16016                        }
16017                    }
16018                }
16019            };
16020            let auth_header = Authorization(Bearer { token: token.access_token });
16021            let mut req_result = {
16022                let mut client = &mut *self.hub.client.borrow_mut();
16023                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
16024                    .header(UserAgent(self.hub._user_agent.clone()))
16025                    .header(auth_header.clone());
16026
16027                dlg.pre_request();
16028                req.send()
16029            };
16030
16031            match req_result {
16032                Err(err) => {
16033                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
16034                        sleep(d);
16035                        continue;
16036                    }
16037                    dlg.finished(false);
16038                    return Err(Error::HttpError(err))
16039                }
16040                Ok(mut res) => {
16041                    if !res.status.is_success() {
16042                        let mut json_err = String::new();
16043                        res.read_to_string(&mut json_err).unwrap();
16044                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
16045                                                              json::from_str(&json_err).ok(),
16046                                                              json::from_str(&json_err).ok()) {
16047                            sleep(d);
16048                            continue;
16049                        }
16050                        dlg.finished(false);
16051                        return match json::from_str::<ErrorResponse>(&json_err){
16052                            Err(_) => Err(Error::Failure(res)),
16053                            Ok(serr) => Err(Error::BadRequest(serr))
16054                        }
16055                    }
16056                    let result_value = {
16057                        let mut json_response = String::new();
16058                        res.read_to_string(&mut json_response).unwrap();
16059                        match json::from_str(&json_response) {
16060                            Ok(decoded) => (res, decoded),
16061                            Err(err) => {
16062                                dlg.response_json_decode_error(&json_response, &err);
16063                                return Err(Error::JsonDecodeError(json_response, err));
16064                            }
16065                        }
16066                    };
16067
16068                    dlg.finished(true);
16069                    return Ok(result_value)
16070                }
16071            }
16072        }
16073    }
16074
16075
16076    /// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
16077    ///
16078    /// Sets the *user key* path property to the given value.
16079    ///
16080    /// Even though the property as already been set when instantiating this call,
16081    /// we provide this method for API completeness.
16082    pub fn user_key(mut self, new_value: &str) -> TokenListCall<'a, C, A> {
16083        self._user_key = new_value.to_string();
16084        self
16085    }
16086    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16087    /// while executing the actual API request.
16088    /// 
16089    /// It should be used to handle progress information, and to implement a certain level of resilience.
16090    ///
16091    /// Sets the *delegate* property to the given value.
16092    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> TokenListCall<'a, C, A> {
16093        self._delegate = Some(new_value);
16094        self
16095    }
16096
16097    /// Set any additional parameter of the query string used in the request.
16098    /// It should be used to set parameters which are not yet available through their own
16099    /// setters.
16100    ///
16101    /// Please note that this method must not be used to set any of the known parameters
16102    /// which have their own setter method. If done anyway, the request will fail.
16103    ///
16104    /// # Additional Parameters
16105    ///
16106    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16107    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16108    /// * *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.
16109    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16110    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16111    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16112    /// * *alt* (query-string) - Data format for the response.
16113    pub fn param<T>(mut self, name: T, value: T) -> TokenListCall<'a, C, A>
16114                                                        where T: AsRef<str> {
16115        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
16116        self
16117    }
16118
16119    /// Identifies the authorization scope for the method you are building.
16120    ///
16121    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16122    /// `Scope::DirectoryUserSecurity`.
16123    ///
16124    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16125    /// tokens for more than one scope.
16126    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16127    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16128    /// function for details).
16129    ///
16130    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16131    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16132    /// sufficient, a read-write scope will do as well.
16133    pub fn add_scope<T, S>(mut self, scope: T) -> TokenListCall<'a, C, A>
16134                                                        where T: Into<Option<S>>,
16135                                                              S: AsRef<str> {
16136        match scope.into() {
16137          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16138          None => None,
16139        };
16140        self
16141    }
16142}
16143
16144
16145/// Delete all access tokens issued by a user for an application.
16146///
16147/// A builder for the *delete* method supported by a *token* resource.
16148/// It is not used directly, but through a `TokenMethods` instance.
16149///
16150/// # Example
16151///
16152/// Instantiate a resource method builder
16153///
16154/// ```test_harness,no_run
16155/// # extern crate hyper;
16156/// # extern crate hyper_rustls;
16157/// # extern crate yup_oauth2 as oauth2;
16158/// # extern crate google_admin1_directory as admin1_directory;
16159/// # #[test] fn egal() {
16160/// # use std::default::Default;
16161/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
16162/// # use admin1_directory::Directory;
16163/// 
16164/// # let secret: ApplicationSecret = Default::default();
16165/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
16166/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
16167/// #                               <MemoryStorage as Default>::default(), None);
16168/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
16169/// // You can configure optional parameters by calling the respective setters at will, and
16170/// // execute the final call using `doit()`.
16171/// // Values shown here are possibly random and not representative !
16172/// let result = hub.tokens().delete("userKey", "clientId")
16173///              .doit();
16174/// # }
16175/// ```
16176pub struct TokenDeleteCall<'a, C, A>
16177    where C: 'a, A: 'a {
16178
16179    hub: &'a Directory<C, A>,
16180    _user_key: String,
16181    _client_id: String,
16182    _delegate: Option<&'a mut dyn Delegate>,
16183    _additional_params: HashMap<String, String>,
16184    _scopes: BTreeMap<String, ()>
16185}
16186
16187impl<'a, C, A> CallBuilder for TokenDeleteCall<'a, C, A> {}
16188
16189impl<'a, C, A> TokenDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
16190
16191
16192    /// Perform the operation you have build so far.
16193    pub fn doit(mut self) -> Result<hyper::client::Response> {
16194        use std::io::{Read, Seek};
16195        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
16196        let mut dd = DefaultDelegate;
16197        let mut dlg: &mut dyn Delegate = match self._delegate {
16198            Some(d) => d,
16199            None => &mut dd
16200        };
16201        dlg.begin(MethodInfo { id: "directory.tokens.delete",
16202                               http_method: hyper::method::Method::Delete });
16203        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
16204        params.push(("userKey", self._user_key.to_string()));
16205        params.push(("clientId", self._client_id.to_string()));
16206        for &field in ["userKey", "clientId"].iter() {
16207            if self._additional_params.contains_key(field) {
16208                dlg.finished(false);
16209                return Err(Error::FieldClash(field));
16210            }
16211        }
16212        for (name, value) in self._additional_params.iter() {
16213            params.push((&name, value.clone()));
16214        }
16215
16216
16217        let mut url = self.hub._base_url.clone() + "users/{userKey}/tokens/{clientId}";
16218        if self._scopes.len() == 0 {
16219            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
16220        }
16221
16222        for &(find_this, param_name) in [("{userKey}", "userKey"), ("{clientId}", "clientId")].iter() {
16223            let mut replace_with: Option<&str> = None;
16224            for &(name, ref value) in params.iter() {
16225                if name == param_name {
16226                    replace_with = Some(value);
16227                    break;
16228                }
16229            }
16230            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
16231        }
16232        {
16233            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
16234            for param_name in ["clientId", "userKey"].iter() {
16235                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
16236                    indices_for_removal.push(index);
16237                }
16238            }
16239            for &index in indices_for_removal.iter() {
16240                params.remove(index);
16241            }
16242        }
16243
16244        let url = hyper::Url::parse_with_params(&url, params).unwrap();
16245
16246
16247
16248        loop {
16249            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
16250                Ok(token) => token,
16251                Err(err) => {
16252                    match  dlg.token(&*err) {
16253                        Some(token) => token,
16254                        None => {
16255                            dlg.finished(false);
16256                            return Err(Error::MissingToken(err))
16257                        }
16258                    }
16259                }
16260            };
16261            let auth_header = Authorization(Bearer { token: token.access_token });
16262            let mut req_result = {
16263                let mut client = &mut *self.hub.client.borrow_mut();
16264                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
16265                    .header(UserAgent(self.hub._user_agent.clone()))
16266                    .header(auth_header.clone());
16267
16268                dlg.pre_request();
16269                req.send()
16270            };
16271
16272            match req_result {
16273                Err(err) => {
16274                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
16275                        sleep(d);
16276                        continue;
16277                    }
16278                    dlg.finished(false);
16279                    return Err(Error::HttpError(err))
16280                }
16281                Ok(mut res) => {
16282                    if !res.status.is_success() {
16283                        let mut json_err = String::new();
16284                        res.read_to_string(&mut json_err).unwrap();
16285                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
16286                                                              json::from_str(&json_err).ok(),
16287                                                              json::from_str(&json_err).ok()) {
16288                            sleep(d);
16289                            continue;
16290                        }
16291                        dlg.finished(false);
16292                        return match json::from_str::<ErrorResponse>(&json_err){
16293                            Err(_) => Err(Error::Failure(res)),
16294                            Ok(serr) => Err(Error::BadRequest(serr))
16295                        }
16296                    }
16297                    let result_value = res;
16298
16299                    dlg.finished(true);
16300                    return Ok(result_value)
16301                }
16302            }
16303        }
16304    }
16305
16306
16307    /// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
16308    ///
16309    /// Sets the *user key* path property to the given value.
16310    ///
16311    /// Even though the property as already been set when instantiating this call,
16312    /// we provide this method for API completeness.
16313    pub fn user_key(mut self, new_value: &str) -> TokenDeleteCall<'a, C, A> {
16314        self._user_key = new_value.to_string();
16315        self
16316    }
16317    /// The Client ID of the application the token is issued to.
16318    ///
16319    /// Sets the *client id* path property to the given value.
16320    ///
16321    /// Even though the property as already been set when instantiating this call,
16322    /// we provide this method for API completeness.
16323    pub fn client_id(mut self, new_value: &str) -> TokenDeleteCall<'a, C, A> {
16324        self._client_id = new_value.to_string();
16325        self
16326    }
16327    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16328    /// while executing the actual API request.
16329    /// 
16330    /// It should be used to handle progress information, and to implement a certain level of resilience.
16331    ///
16332    /// Sets the *delegate* property to the given value.
16333    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> TokenDeleteCall<'a, C, A> {
16334        self._delegate = Some(new_value);
16335        self
16336    }
16337
16338    /// Set any additional parameter of the query string used in the request.
16339    /// It should be used to set parameters which are not yet available through their own
16340    /// setters.
16341    ///
16342    /// Please note that this method must not be used to set any of the known parameters
16343    /// which have their own setter method. If done anyway, the request will fail.
16344    ///
16345    /// # Additional Parameters
16346    ///
16347    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16348    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16349    /// * *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.
16350    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16351    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16352    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16353    /// * *alt* (query-string) - Data format for the response.
16354    pub fn param<T>(mut self, name: T, value: T) -> TokenDeleteCall<'a, C, A>
16355                                                        where T: AsRef<str> {
16356        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
16357        self
16358    }
16359
16360    /// Identifies the authorization scope for the method you are building.
16361    ///
16362    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16363    /// `Scope::DirectoryUserSecurity`.
16364    ///
16365    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16366    /// tokens for more than one scope.
16367    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16368    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16369    /// function for details).
16370    ///
16371    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16372    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16373    /// sufficient, a read-write scope will do as well.
16374    pub fn add_scope<T, S>(mut self, scope: T) -> TokenDeleteCall<'a, C, A>
16375                                                        where T: Into<Option<S>>,
16376                                                              S: AsRef<str> {
16377        match scope.into() {
16378          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16379          None => None,
16380        };
16381        self
16382    }
16383}
16384
16385
16386/// Creates a role assignment.
16387///
16388/// A builder for the *insert* method supported by a *roleAssignment* resource.
16389/// It is not used directly, but through a `RoleAssignmentMethods` instance.
16390///
16391/// # Example
16392///
16393/// Instantiate a resource method builder
16394///
16395/// ```test_harness,no_run
16396/// # extern crate hyper;
16397/// # extern crate hyper_rustls;
16398/// # extern crate yup_oauth2 as oauth2;
16399/// # extern crate google_admin1_directory as admin1_directory;
16400/// use admin1_directory::RoleAssignment;
16401/// # #[test] fn egal() {
16402/// # use std::default::Default;
16403/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
16404/// # use admin1_directory::Directory;
16405/// 
16406/// # let secret: ApplicationSecret = Default::default();
16407/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
16408/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
16409/// #                               <MemoryStorage as Default>::default(), None);
16410/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
16411/// // As the method needs a request, you would usually fill it with the desired information
16412/// // into the respective structure. Some of the parts shown here might not be applicable !
16413/// // Values shown here are possibly random and not representative !
16414/// let mut req = RoleAssignment::default();
16415/// 
16416/// // You can configure optional parameters by calling the respective setters at will, and
16417/// // execute the final call using `doit()`.
16418/// // Values shown here are possibly random and not representative !
16419/// let result = hub.role_assignments().insert(req, "customer")
16420///              .doit();
16421/// # }
16422/// ```
16423pub struct RoleAssignmentInsertCall<'a, C, A>
16424    where C: 'a, A: 'a {
16425
16426    hub: &'a Directory<C, A>,
16427    _request: RoleAssignment,
16428    _customer: String,
16429    _delegate: Option<&'a mut dyn Delegate>,
16430    _additional_params: HashMap<String, String>,
16431    _scopes: BTreeMap<String, ()>
16432}
16433
16434impl<'a, C, A> CallBuilder for RoleAssignmentInsertCall<'a, C, A> {}
16435
16436impl<'a, C, A> RoleAssignmentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
16437
16438
16439    /// Perform the operation you have build so far.
16440    pub fn doit(mut self) -> Result<(hyper::client::Response, RoleAssignment)> {
16441        use std::io::{Read, Seek};
16442        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
16443        let mut dd = DefaultDelegate;
16444        let mut dlg: &mut dyn Delegate = match self._delegate {
16445            Some(d) => d,
16446            None => &mut dd
16447        };
16448        dlg.begin(MethodInfo { id: "directory.roleAssignments.insert",
16449                               http_method: hyper::method::Method::Post });
16450        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
16451        params.push(("customer", self._customer.to_string()));
16452        for &field in ["alt", "customer"].iter() {
16453            if self._additional_params.contains_key(field) {
16454                dlg.finished(false);
16455                return Err(Error::FieldClash(field));
16456            }
16457        }
16458        for (name, value) in self._additional_params.iter() {
16459            params.push((&name, value.clone()));
16460        }
16461
16462        params.push(("alt", "json".to_string()));
16463
16464        let mut url = self.hub._base_url.clone() + "customer/{customer}/roleassignments";
16465        if self._scopes.len() == 0 {
16466            self._scopes.insert(Scope::DirectoryRolemanagement.as_ref().to_string(), ());
16467        }
16468
16469        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
16470            let mut replace_with: Option<&str> = None;
16471            for &(name, ref value) in params.iter() {
16472                if name == param_name {
16473                    replace_with = Some(value);
16474                    break;
16475                }
16476            }
16477            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
16478        }
16479        {
16480            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
16481            for param_name in ["customer"].iter() {
16482                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
16483                    indices_for_removal.push(index);
16484                }
16485            }
16486            for &index in indices_for_removal.iter() {
16487                params.remove(index);
16488            }
16489        }
16490
16491        let url = hyper::Url::parse_with_params(&url, params).unwrap();
16492
16493        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
16494        let mut request_value_reader =
16495            {
16496                let mut value = json::value::to_value(&self._request).expect("serde to work");
16497                remove_json_null_values(&mut value);
16498                let mut dst = io::Cursor::new(Vec::with_capacity(128));
16499                json::to_writer(&mut dst, &value).unwrap();
16500                dst
16501            };
16502        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
16503        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
16504
16505
16506        loop {
16507            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
16508                Ok(token) => token,
16509                Err(err) => {
16510                    match  dlg.token(&*err) {
16511                        Some(token) => token,
16512                        None => {
16513                            dlg.finished(false);
16514                            return Err(Error::MissingToken(err))
16515                        }
16516                    }
16517                }
16518            };
16519            let auth_header = Authorization(Bearer { token: token.access_token });
16520            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
16521            let mut req_result = {
16522                let mut client = &mut *self.hub.client.borrow_mut();
16523                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
16524                    .header(UserAgent(self.hub._user_agent.clone()))
16525                    .header(auth_header.clone())
16526                    .header(ContentType(json_mime_type.clone()))
16527                    .header(ContentLength(request_size as u64))
16528                    .body(&mut request_value_reader);
16529
16530                dlg.pre_request();
16531                req.send()
16532            };
16533
16534            match req_result {
16535                Err(err) => {
16536                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
16537                        sleep(d);
16538                        continue;
16539                    }
16540                    dlg.finished(false);
16541                    return Err(Error::HttpError(err))
16542                }
16543                Ok(mut res) => {
16544                    if !res.status.is_success() {
16545                        let mut json_err = String::new();
16546                        res.read_to_string(&mut json_err).unwrap();
16547                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
16548                                                              json::from_str(&json_err).ok(),
16549                                                              json::from_str(&json_err).ok()) {
16550                            sleep(d);
16551                            continue;
16552                        }
16553                        dlg.finished(false);
16554                        return match json::from_str::<ErrorResponse>(&json_err){
16555                            Err(_) => Err(Error::Failure(res)),
16556                            Ok(serr) => Err(Error::BadRequest(serr))
16557                        }
16558                    }
16559                    let result_value = {
16560                        let mut json_response = String::new();
16561                        res.read_to_string(&mut json_response).unwrap();
16562                        match json::from_str(&json_response) {
16563                            Ok(decoded) => (res, decoded),
16564                            Err(err) => {
16565                                dlg.response_json_decode_error(&json_response, &err);
16566                                return Err(Error::JsonDecodeError(json_response, err));
16567                            }
16568                        }
16569                    };
16570
16571                    dlg.finished(true);
16572                    return Ok(result_value)
16573                }
16574            }
16575        }
16576    }
16577
16578
16579    ///
16580    /// Sets the *request* property to the given value.
16581    ///
16582    /// Even though the property as already been set when instantiating this call,
16583    /// we provide this method for API completeness.
16584    pub fn request(mut self, new_value: RoleAssignment) -> RoleAssignmentInsertCall<'a, C, A> {
16585        self._request = new_value;
16586        self
16587    }
16588    /// Immutable ID of the G Suite account.
16589    ///
16590    /// Sets the *customer* path property to the given value.
16591    ///
16592    /// Even though the property as already been set when instantiating this call,
16593    /// we provide this method for API completeness.
16594    pub fn customer(mut self, new_value: &str) -> RoleAssignmentInsertCall<'a, C, A> {
16595        self._customer = new_value.to_string();
16596        self
16597    }
16598    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16599    /// while executing the actual API request.
16600    /// 
16601    /// It should be used to handle progress information, and to implement a certain level of resilience.
16602    ///
16603    /// Sets the *delegate* property to the given value.
16604    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleAssignmentInsertCall<'a, C, A> {
16605        self._delegate = Some(new_value);
16606        self
16607    }
16608
16609    /// Set any additional parameter of the query string used in the request.
16610    /// It should be used to set parameters which are not yet available through their own
16611    /// setters.
16612    ///
16613    /// Please note that this method must not be used to set any of the known parameters
16614    /// which have their own setter method. If done anyway, the request will fail.
16615    ///
16616    /// # Additional Parameters
16617    ///
16618    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16619    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16620    /// * *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.
16621    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16622    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16623    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16624    /// * *alt* (query-string) - Data format for the response.
16625    pub fn param<T>(mut self, name: T, value: T) -> RoleAssignmentInsertCall<'a, C, A>
16626                                                        where T: AsRef<str> {
16627        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
16628        self
16629    }
16630
16631    /// Identifies the authorization scope for the method you are building.
16632    ///
16633    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16634    /// `Scope::DirectoryRolemanagement`.
16635    ///
16636    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16637    /// tokens for more than one scope.
16638    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16639    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16640    /// function for details).
16641    ///
16642    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16643    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16644    /// sufficient, a read-write scope will do as well.
16645    pub fn add_scope<T, S>(mut self, scope: T) -> RoleAssignmentInsertCall<'a, C, A>
16646                                                        where T: Into<Option<S>>,
16647                                                              S: AsRef<str> {
16648        match scope.into() {
16649          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16650          None => None,
16651        };
16652        self
16653    }
16654}
16655
16656
16657/// Retrieve a role assignment.
16658///
16659/// A builder for the *get* method supported by a *roleAssignment* resource.
16660/// It is not used directly, but through a `RoleAssignmentMethods` instance.
16661///
16662/// # Example
16663///
16664/// Instantiate a resource method builder
16665///
16666/// ```test_harness,no_run
16667/// # extern crate hyper;
16668/// # extern crate hyper_rustls;
16669/// # extern crate yup_oauth2 as oauth2;
16670/// # extern crate google_admin1_directory as admin1_directory;
16671/// # #[test] fn egal() {
16672/// # use std::default::Default;
16673/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
16674/// # use admin1_directory::Directory;
16675/// 
16676/// # let secret: ApplicationSecret = Default::default();
16677/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
16678/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
16679/// #                               <MemoryStorage as Default>::default(), None);
16680/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
16681/// // You can configure optional parameters by calling the respective setters at will, and
16682/// // execute the final call using `doit()`.
16683/// // Values shown here are possibly random and not representative !
16684/// let result = hub.role_assignments().get("customer", "roleAssignmentId")
16685///              .doit();
16686/// # }
16687/// ```
16688pub struct RoleAssignmentGetCall<'a, C, A>
16689    where C: 'a, A: 'a {
16690
16691    hub: &'a Directory<C, A>,
16692    _customer: String,
16693    _role_assignment_id: String,
16694    _delegate: Option<&'a mut dyn Delegate>,
16695    _additional_params: HashMap<String, String>,
16696    _scopes: BTreeMap<String, ()>
16697}
16698
16699impl<'a, C, A> CallBuilder for RoleAssignmentGetCall<'a, C, A> {}
16700
16701impl<'a, C, A> RoleAssignmentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
16702
16703
16704    /// Perform the operation you have build so far.
16705    pub fn doit(mut self) -> Result<(hyper::client::Response, RoleAssignment)> {
16706        use std::io::{Read, Seek};
16707        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
16708        let mut dd = DefaultDelegate;
16709        let mut dlg: &mut dyn Delegate = match self._delegate {
16710            Some(d) => d,
16711            None => &mut dd
16712        };
16713        dlg.begin(MethodInfo { id: "directory.roleAssignments.get",
16714                               http_method: hyper::method::Method::Get });
16715        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
16716        params.push(("customer", self._customer.to_string()));
16717        params.push(("roleAssignmentId", self._role_assignment_id.to_string()));
16718        for &field in ["alt", "customer", "roleAssignmentId"].iter() {
16719            if self._additional_params.contains_key(field) {
16720                dlg.finished(false);
16721                return Err(Error::FieldClash(field));
16722            }
16723        }
16724        for (name, value) in self._additional_params.iter() {
16725            params.push((&name, value.clone()));
16726        }
16727
16728        params.push(("alt", "json".to_string()));
16729
16730        let mut url = self.hub._base_url.clone() + "customer/{customer}/roleassignments/{roleAssignmentId}";
16731        if self._scopes.len() == 0 {
16732            self._scopes.insert(Scope::DirectoryRolemanagementReadonly.as_ref().to_string(), ());
16733        }
16734
16735        for &(find_this, param_name) in [("{customer}", "customer"), ("{roleAssignmentId}", "roleAssignmentId")].iter() {
16736            let mut replace_with: Option<&str> = None;
16737            for &(name, ref value) in params.iter() {
16738                if name == param_name {
16739                    replace_with = Some(value);
16740                    break;
16741                }
16742            }
16743            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
16744        }
16745        {
16746            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
16747            for param_name in ["roleAssignmentId", "customer"].iter() {
16748                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
16749                    indices_for_removal.push(index);
16750                }
16751            }
16752            for &index in indices_for_removal.iter() {
16753                params.remove(index);
16754            }
16755        }
16756
16757        let url = hyper::Url::parse_with_params(&url, params).unwrap();
16758
16759
16760
16761        loop {
16762            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
16763                Ok(token) => token,
16764                Err(err) => {
16765                    match  dlg.token(&*err) {
16766                        Some(token) => token,
16767                        None => {
16768                            dlg.finished(false);
16769                            return Err(Error::MissingToken(err))
16770                        }
16771                    }
16772                }
16773            };
16774            let auth_header = Authorization(Bearer { token: token.access_token });
16775            let mut req_result = {
16776                let mut client = &mut *self.hub.client.borrow_mut();
16777                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
16778                    .header(UserAgent(self.hub._user_agent.clone()))
16779                    .header(auth_header.clone());
16780
16781                dlg.pre_request();
16782                req.send()
16783            };
16784
16785            match req_result {
16786                Err(err) => {
16787                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
16788                        sleep(d);
16789                        continue;
16790                    }
16791                    dlg.finished(false);
16792                    return Err(Error::HttpError(err))
16793                }
16794                Ok(mut res) => {
16795                    if !res.status.is_success() {
16796                        let mut json_err = String::new();
16797                        res.read_to_string(&mut json_err).unwrap();
16798                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
16799                                                              json::from_str(&json_err).ok(),
16800                                                              json::from_str(&json_err).ok()) {
16801                            sleep(d);
16802                            continue;
16803                        }
16804                        dlg.finished(false);
16805                        return match json::from_str::<ErrorResponse>(&json_err){
16806                            Err(_) => Err(Error::Failure(res)),
16807                            Ok(serr) => Err(Error::BadRequest(serr))
16808                        }
16809                    }
16810                    let result_value = {
16811                        let mut json_response = String::new();
16812                        res.read_to_string(&mut json_response).unwrap();
16813                        match json::from_str(&json_response) {
16814                            Ok(decoded) => (res, decoded),
16815                            Err(err) => {
16816                                dlg.response_json_decode_error(&json_response, &err);
16817                                return Err(Error::JsonDecodeError(json_response, err));
16818                            }
16819                        }
16820                    };
16821
16822                    dlg.finished(true);
16823                    return Ok(result_value)
16824                }
16825            }
16826        }
16827    }
16828
16829
16830    /// Immutable ID of the G Suite account.
16831    ///
16832    /// Sets the *customer* path property to the given value.
16833    ///
16834    /// Even though the property as already been set when instantiating this call,
16835    /// we provide this method for API completeness.
16836    pub fn customer(mut self, new_value: &str) -> RoleAssignmentGetCall<'a, C, A> {
16837        self._customer = new_value.to_string();
16838        self
16839    }
16840    /// Immutable ID of the role assignment.
16841    ///
16842    /// Sets the *role assignment id* path property to the given value.
16843    ///
16844    /// Even though the property as already been set when instantiating this call,
16845    /// we provide this method for API completeness.
16846    pub fn role_assignment_id(mut self, new_value: &str) -> RoleAssignmentGetCall<'a, C, A> {
16847        self._role_assignment_id = new_value.to_string();
16848        self
16849    }
16850    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16851    /// while executing the actual API request.
16852    /// 
16853    /// It should be used to handle progress information, and to implement a certain level of resilience.
16854    ///
16855    /// Sets the *delegate* property to the given value.
16856    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleAssignmentGetCall<'a, C, A> {
16857        self._delegate = Some(new_value);
16858        self
16859    }
16860
16861    /// Set any additional parameter of the query string used in the request.
16862    /// It should be used to set parameters which are not yet available through their own
16863    /// setters.
16864    ///
16865    /// Please note that this method must not be used to set any of the known parameters
16866    /// which have their own setter method. If done anyway, the request will fail.
16867    ///
16868    /// # Additional Parameters
16869    ///
16870    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16871    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16872    /// * *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.
16873    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16874    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16875    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16876    /// * *alt* (query-string) - Data format for the response.
16877    pub fn param<T>(mut self, name: T, value: T) -> RoleAssignmentGetCall<'a, C, A>
16878                                                        where T: AsRef<str> {
16879        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
16880        self
16881    }
16882
16883    /// Identifies the authorization scope for the method you are building.
16884    ///
16885    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16886    /// `Scope::DirectoryRolemanagementReadonly`.
16887    ///
16888    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16889    /// tokens for more than one scope.
16890    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16891    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16892    /// function for details).
16893    ///
16894    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16895    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16896    /// sufficient, a read-write scope will do as well.
16897    pub fn add_scope<T, S>(mut self, scope: T) -> RoleAssignmentGetCall<'a, C, A>
16898                                                        where T: Into<Option<S>>,
16899                                                              S: AsRef<str> {
16900        match scope.into() {
16901          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16902          None => None,
16903        };
16904        self
16905    }
16906}
16907
16908
16909/// Deletes a role assignment.
16910///
16911/// A builder for the *delete* method supported by a *roleAssignment* resource.
16912/// It is not used directly, but through a `RoleAssignmentMethods` instance.
16913///
16914/// # Example
16915///
16916/// Instantiate a resource method builder
16917///
16918/// ```test_harness,no_run
16919/// # extern crate hyper;
16920/// # extern crate hyper_rustls;
16921/// # extern crate yup_oauth2 as oauth2;
16922/// # extern crate google_admin1_directory as admin1_directory;
16923/// # #[test] fn egal() {
16924/// # use std::default::Default;
16925/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
16926/// # use admin1_directory::Directory;
16927/// 
16928/// # let secret: ApplicationSecret = Default::default();
16929/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
16930/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
16931/// #                               <MemoryStorage as Default>::default(), None);
16932/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
16933/// // You can configure optional parameters by calling the respective setters at will, and
16934/// // execute the final call using `doit()`.
16935/// // Values shown here are possibly random and not representative !
16936/// let result = hub.role_assignments().delete("customer", "roleAssignmentId")
16937///              .doit();
16938/// # }
16939/// ```
16940pub struct RoleAssignmentDeleteCall<'a, C, A>
16941    where C: 'a, A: 'a {
16942
16943    hub: &'a Directory<C, A>,
16944    _customer: String,
16945    _role_assignment_id: String,
16946    _delegate: Option<&'a mut dyn Delegate>,
16947    _additional_params: HashMap<String, String>,
16948    _scopes: BTreeMap<String, ()>
16949}
16950
16951impl<'a, C, A> CallBuilder for RoleAssignmentDeleteCall<'a, C, A> {}
16952
16953impl<'a, C, A> RoleAssignmentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
16954
16955
16956    /// Perform the operation you have build so far.
16957    pub fn doit(mut self) -> Result<hyper::client::Response> {
16958        use std::io::{Read, Seek};
16959        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
16960        let mut dd = DefaultDelegate;
16961        let mut dlg: &mut dyn Delegate = match self._delegate {
16962            Some(d) => d,
16963            None => &mut dd
16964        };
16965        dlg.begin(MethodInfo { id: "directory.roleAssignments.delete",
16966                               http_method: hyper::method::Method::Delete });
16967        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
16968        params.push(("customer", self._customer.to_string()));
16969        params.push(("roleAssignmentId", self._role_assignment_id.to_string()));
16970        for &field in ["customer", "roleAssignmentId"].iter() {
16971            if self._additional_params.contains_key(field) {
16972                dlg.finished(false);
16973                return Err(Error::FieldClash(field));
16974            }
16975        }
16976        for (name, value) in self._additional_params.iter() {
16977            params.push((&name, value.clone()));
16978        }
16979
16980
16981        let mut url = self.hub._base_url.clone() + "customer/{customer}/roleassignments/{roleAssignmentId}";
16982        if self._scopes.len() == 0 {
16983            self._scopes.insert(Scope::DirectoryRolemanagement.as_ref().to_string(), ());
16984        }
16985
16986        for &(find_this, param_name) in [("{customer}", "customer"), ("{roleAssignmentId}", "roleAssignmentId")].iter() {
16987            let mut replace_with: Option<&str> = None;
16988            for &(name, ref value) in params.iter() {
16989                if name == param_name {
16990                    replace_with = Some(value);
16991                    break;
16992                }
16993            }
16994            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
16995        }
16996        {
16997            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
16998            for param_name in ["roleAssignmentId", "customer"].iter() {
16999                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
17000                    indices_for_removal.push(index);
17001                }
17002            }
17003            for &index in indices_for_removal.iter() {
17004                params.remove(index);
17005            }
17006        }
17007
17008        let url = hyper::Url::parse_with_params(&url, params).unwrap();
17009
17010
17011
17012        loop {
17013            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
17014                Ok(token) => token,
17015                Err(err) => {
17016                    match  dlg.token(&*err) {
17017                        Some(token) => token,
17018                        None => {
17019                            dlg.finished(false);
17020                            return Err(Error::MissingToken(err))
17021                        }
17022                    }
17023                }
17024            };
17025            let auth_header = Authorization(Bearer { token: token.access_token });
17026            let mut req_result = {
17027                let mut client = &mut *self.hub.client.borrow_mut();
17028                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
17029                    .header(UserAgent(self.hub._user_agent.clone()))
17030                    .header(auth_header.clone());
17031
17032                dlg.pre_request();
17033                req.send()
17034            };
17035
17036            match req_result {
17037                Err(err) => {
17038                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
17039                        sleep(d);
17040                        continue;
17041                    }
17042                    dlg.finished(false);
17043                    return Err(Error::HttpError(err))
17044                }
17045                Ok(mut res) => {
17046                    if !res.status.is_success() {
17047                        let mut json_err = String::new();
17048                        res.read_to_string(&mut json_err).unwrap();
17049                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
17050                                                              json::from_str(&json_err).ok(),
17051                                                              json::from_str(&json_err).ok()) {
17052                            sleep(d);
17053                            continue;
17054                        }
17055                        dlg.finished(false);
17056                        return match json::from_str::<ErrorResponse>(&json_err){
17057                            Err(_) => Err(Error::Failure(res)),
17058                            Ok(serr) => Err(Error::BadRequest(serr))
17059                        }
17060                    }
17061                    let result_value = res;
17062
17063                    dlg.finished(true);
17064                    return Ok(result_value)
17065                }
17066            }
17067        }
17068    }
17069
17070
17071    /// Immutable ID of the G Suite account.
17072    ///
17073    /// Sets the *customer* path property to the given value.
17074    ///
17075    /// Even though the property as already been set when instantiating this call,
17076    /// we provide this method for API completeness.
17077    pub fn customer(mut self, new_value: &str) -> RoleAssignmentDeleteCall<'a, C, A> {
17078        self._customer = new_value.to_string();
17079        self
17080    }
17081    /// Immutable ID of the role assignment.
17082    ///
17083    /// Sets the *role assignment id* path property to the given value.
17084    ///
17085    /// Even though the property as already been set when instantiating this call,
17086    /// we provide this method for API completeness.
17087    pub fn role_assignment_id(mut self, new_value: &str) -> RoleAssignmentDeleteCall<'a, C, A> {
17088        self._role_assignment_id = new_value.to_string();
17089        self
17090    }
17091    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17092    /// while executing the actual API request.
17093    /// 
17094    /// It should be used to handle progress information, and to implement a certain level of resilience.
17095    ///
17096    /// Sets the *delegate* property to the given value.
17097    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleAssignmentDeleteCall<'a, C, A> {
17098        self._delegate = Some(new_value);
17099        self
17100    }
17101
17102    /// Set any additional parameter of the query string used in the request.
17103    /// It should be used to set parameters which are not yet available through their own
17104    /// setters.
17105    ///
17106    /// Please note that this method must not be used to set any of the known parameters
17107    /// which have their own setter method. If done anyway, the request will fail.
17108    ///
17109    /// # Additional Parameters
17110    ///
17111    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17112    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17113    /// * *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.
17114    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17115    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17116    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17117    /// * *alt* (query-string) - Data format for the response.
17118    pub fn param<T>(mut self, name: T, value: T) -> RoleAssignmentDeleteCall<'a, C, A>
17119                                                        where T: AsRef<str> {
17120        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
17121        self
17122    }
17123
17124    /// Identifies the authorization scope for the method you are building.
17125    ///
17126    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
17127    /// `Scope::DirectoryRolemanagement`.
17128    ///
17129    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17130    /// tokens for more than one scope.
17131    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
17132    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
17133    /// function for details).
17134    ///
17135    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17136    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17137    /// sufficient, a read-write scope will do as well.
17138    pub fn add_scope<T, S>(mut self, scope: T) -> RoleAssignmentDeleteCall<'a, C, A>
17139                                                        where T: Into<Option<S>>,
17140                                                              S: AsRef<str> {
17141        match scope.into() {
17142          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
17143          None => None,
17144        };
17145        self
17146    }
17147}
17148
17149
17150/// Retrieves a paginated list of all roleAssignments.
17151///
17152/// A builder for the *list* method supported by a *roleAssignment* resource.
17153/// It is not used directly, but through a `RoleAssignmentMethods` instance.
17154///
17155/// # Example
17156///
17157/// Instantiate a resource method builder
17158///
17159/// ```test_harness,no_run
17160/// # extern crate hyper;
17161/// # extern crate hyper_rustls;
17162/// # extern crate yup_oauth2 as oauth2;
17163/// # extern crate google_admin1_directory as admin1_directory;
17164/// # #[test] fn egal() {
17165/// # use std::default::Default;
17166/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
17167/// # use admin1_directory::Directory;
17168/// 
17169/// # let secret: ApplicationSecret = Default::default();
17170/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
17171/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
17172/// #                               <MemoryStorage as Default>::default(), None);
17173/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
17174/// // You can configure optional parameters by calling the respective setters at will, and
17175/// // execute the final call using `doit()`.
17176/// // Values shown here are possibly random and not representative !
17177/// let result = hub.role_assignments().list("customer")
17178///              .user_key("ut")
17179///              .role_id("justo")
17180///              .page_token("est")
17181///              .max_results(-46)
17182///              .doit();
17183/// # }
17184/// ```
17185pub struct RoleAssignmentListCall<'a, C, A>
17186    where C: 'a, A: 'a {
17187
17188    hub: &'a Directory<C, A>,
17189    _customer: String,
17190    _user_key: Option<String>,
17191    _role_id: Option<String>,
17192    _page_token: Option<String>,
17193    _max_results: Option<i32>,
17194    _delegate: Option<&'a mut dyn Delegate>,
17195    _additional_params: HashMap<String, String>,
17196    _scopes: BTreeMap<String, ()>
17197}
17198
17199impl<'a, C, A> CallBuilder for RoleAssignmentListCall<'a, C, A> {}
17200
17201impl<'a, C, A> RoleAssignmentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
17202
17203
17204    /// Perform the operation you have build so far.
17205    pub fn doit(mut self) -> Result<(hyper::client::Response, RoleAssignments)> {
17206        use std::io::{Read, Seek};
17207        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
17208        let mut dd = DefaultDelegate;
17209        let mut dlg: &mut dyn Delegate = match self._delegate {
17210            Some(d) => d,
17211            None => &mut dd
17212        };
17213        dlg.begin(MethodInfo { id: "directory.roleAssignments.list",
17214                               http_method: hyper::method::Method::Get });
17215        let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len());
17216        params.push(("customer", self._customer.to_string()));
17217        if let Some(value) = self._user_key {
17218            params.push(("userKey", value.to_string()));
17219        }
17220        if let Some(value) = self._role_id {
17221            params.push(("roleId", value.to_string()));
17222        }
17223        if let Some(value) = self._page_token {
17224            params.push(("pageToken", value.to_string()));
17225        }
17226        if let Some(value) = self._max_results {
17227            params.push(("maxResults", value.to_string()));
17228        }
17229        for &field in ["alt", "customer", "userKey", "roleId", "pageToken", "maxResults"].iter() {
17230            if self._additional_params.contains_key(field) {
17231                dlg.finished(false);
17232                return Err(Error::FieldClash(field));
17233            }
17234        }
17235        for (name, value) in self._additional_params.iter() {
17236            params.push((&name, value.clone()));
17237        }
17238
17239        params.push(("alt", "json".to_string()));
17240
17241        let mut url = self.hub._base_url.clone() + "customer/{customer}/roleassignments";
17242        if self._scopes.len() == 0 {
17243            self._scopes.insert(Scope::DirectoryRolemanagementReadonly.as_ref().to_string(), ());
17244        }
17245
17246        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
17247            let mut replace_with: Option<&str> = None;
17248            for &(name, ref value) in params.iter() {
17249                if name == param_name {
17250                    replace_with = Some(value);
17251                    break;
17252                }
17253            }
17254            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
17255        }
17256        {
17257            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
17258            for param_name in ["customer"].iter() {
17259                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
17260                    indices_for_removal.push(index);
17261                }
17262            }
17263            for &index in indices_for_removal.iter() {
17264                params.remove(index);
17265            }
17266        }
17267
17268        let url = hyper::Url::parse_with_params(&url, params).unwrap();
17269
17270
17271
17272        loop {
17273            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
17274                Ok(token) => token,
17275                Err(err) => {
17276                    match  dlg.token(&*err) {
17277                        Some(token) => token,
17278                        None => {
17279                            dlg.finished(false);
17280                            return Err(Error::MissingToken(err))
17281                        }
17282                    }
17283                }
17284            };
17285            let auth_header = Authorization(Bearer { token: token.access_token });
17286            let mut req_result = {
17287                let mut client = &mut *self.hub.client.borrow_mut();
17288                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
17289                    .header(UserAgent(self.hub._user_agent.clone()))
17290                    .header(auth_header.clone());
17291
17292                dlg.pre_request();
17293                req.send()
17294            };
17295
17296            match req_result {
17297                Err(err) => {
17298                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
17299                        sleep(d);
17300                        continue;
17301                    }
17302                    dlg.finished(false);
17303                    return Err(Error::HttpError(err))
17304                }
17305                Ok(mut res) => {
17306                    if !res.status.is_success() {
17307                        let mut json_err = String::new();
17308                        res.read_to_string(&mut json_err).unwrap();
17309                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
17310                                                              json::from_str(&json_err).ok(),
17311                                                              json::from_str(&json_err).ok()) {
17312                            sleep(d);
17313                            continue;
17314                        }
17315                        dlg.finished(false);
17316                        return match json::from_str::<ErrorResponse>(&json_err){
17317                            Err(_) => Err(Error::Failure(res)),
17318                            Ok(serr) => Err(Error::BadRequest(serr))
17319                        }
17320                    }
17321                    let result_value = {
17322                        let mut json_response = String::new();
17323                        res.read_to_string(&mut json_response).unwrap();
17324                        match json::from_str(&json_response) {
17325                            Ok(decoded) => (res, decoded),
17326                            Err(err) => {
17327                                dlg.response_json_decode_error(&json_response, &err);
17328                                return Err(Error::JsonDecodeError(json_response, err));
17329                            }
17330                        }
17331                    };
17332
17333                    dlg.finished(true);
17334                    return Ok(result_value)
17335                }
17336            }
17337        }
17338    }
17339
17340
17341    /// Immutable ID of the G Suite account.
17342    ///
17343    /// Sets the *customer* path property to the given value.
17344    ///
17345    /// Even though the property as already been set when instantiating this call,
17346    /// we provide this method for API completeness.
17347    pub fn customer(mut self, new_value: &str) -> RoleAssignmentListCall<'a, C, A> {
17348        self._customer = new_value.to_string();
17349        self
17350    }
17351    /// The user's primary email address, alias email address, or unique user ID. If included in the request, returns role assignments only for this user.
17352    ///
17353    /// Sets the *user key* query property to the given value.
17354    pub fn user_key(mut self, new_value: &str) -> RoleAssignmentListCall<'a, C, A> {
17355        self._user_key = Some(new_value.to_string());
17356        self
17357    }
17358    /// Immutable ID of a role. If included in the request, returns only role assignments containing this role ID.
17359    ///
17360    /// Sets the *role id* query property to the given value.
17361    pub fn role_id(mut self, new_value: &str) -> RoleAssignmentListCall<'a, C, A> {
17362        self._role_id = Some(new_value.to_string());
17363        self
17364    }
17365    /// Token to specify the next page in the list.
17366    ///
17367    /// Sets the *page token* query property to the given value.
17368    pub fn page_token(mut self, new_value: &str) -> RoleAssignmentListCall<'a, C, A> {
17369        self._page_token = Some(new_value.to_string());
17370        self
17371    }
17372    /// Maximum number of results to return.
17373    ///
17374    /// Sets the *max results* query property to the given value.
17375    pub fn max_results(mut self, new_value: i32) -> RoleAssignmentListCall<'a, C, A> {
17376        self._max_results = Some(new_value);
17377        self
17378    }
17379    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17380    /// while executing the actual API request.
17381    /// 
17382    /// It should be used to handle progress information, and to implement a certain level of resilience.
17383    ///
17384    /// Sets the *delegate* property to the given value.
17385    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> RoleAssignmentListCall<'a, C, A> {
17386        self._delegate = Some(new_value);
17387        self
17388    }
17389
17390    /// Set any additional parameter of the query string used in the request.
17391    /// It should be used to set parameters which are not yet available through their own
17392    /// setters.
17393    ///
17394    /// Please note that this method must not be used to set any of the known parameters
17395    /// which have their own setter method. If done anyway, the request will fail.
17396    ///
17397    /// # Additional Parameters
17398    ///
17399    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17400    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17401    /// * *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.
17402    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17403    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17404    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17405    /// * *alt* (query-string) - Data format for the response.
17406    pub fn param<T>(mut self, name: T, value: T) -> RoleAssignmentListCall<'a, C, A>
17407                                                        where T: AsRef<str> {
17408        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
17409        self
17410    }
17411
17412    /// Identifies the authorization scope for the method you are building.
17413    ///
17414    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
17415    /// `Scope::DirectoryRolemanagementReadonly`.
17416    ///
17417    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17418    /// tokens for more than one scope.
17419    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
17420    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
17421    /// function for details).
17422    ///
17423    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17424    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17425    /// sufficient, a read-write scope will do as well.
17426    pub fn add_scope<T, S>(mut self, scope: T) -> RoleAssignmentListCall<'a, C, A>
17427                                                        where T: Into<Option<S>>,
17428                                                              S: AsRef<str> {
17429        match scope.into() {
17430          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
17431          None => None,
17432        };
17433        self
17434    }
17435}
17436
17437
17438/// Retrieve all Chrome OS Devices of a customer (paginated)
17439///
17440/// A builder for the *list* method supported by a *chromeosdevice* resource.
17441/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
17442///
17443/// # Example
17444///
17445/// Instantiate a resource method builder
17446///
17447/// ```test_harness,no_run
17448/// # extern crate hyper;
17449/// # extern crate hyper_rustls;
17450/// # extern crate yup_oauth2 as oauth2;
17451/// # extern crate google_admin1_directory as admin1_directory;
17452/// # #[test] fn egal() {
17453/// # use std::default::Default;
17454/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
17455/// # use admin1_directory::Directory;
17456/// 
17457/// # let secret: ApplicationSecret = Default::default();
17458/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
17459/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
17460/// #                               <MemoryStorage as Default>::default(), None);
17461/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
17462/// // You can configure optional parameters by calling the respective setters at will, and
17463/// // execute the final call using `doit()`.
17464/// // Values shown here are possibly random and not representative !
17465/// let result = hub.chromeosdevices().list("customerId")
17466///              .sort_order("clita")
17467///              .query("diam")
17468///              .projection("justo")
17469///              .page_token("est")
17470///              .org_unit_path("clita")
17471///              .order_by("invidunt")
17472///              .max_results(-87)
17473///              .doit();
17474/// # }
17475/// ```
17476pub struct ChromeosdeviceListCall<'a, C, A>
17477    where C: 'a, A: 'a {
17478
17479    hub: &'a Directory<C, A>,
17480    _customer_id: String,
17481    _sort_order: Option<String>,
17482    _query: Option<String>,
17483    _projection: Option<String>,
17484    _page_token: Option<String>,
17485    _org_unit_path: Option<String>,
17486    _order_by: Option<String>,
17487    _max_results: Option<i32>,
17488    _delegate: Option<&'a mut dyn Delegate>,
17489    _additional_params: HashMap<String, String>,
17490    _scopes: BTreeMap<String, ()>
17491}
17492
17493impl<'a, C, A> CallBuilder for ChromeosdeviceListCall<'a, C, A> {}
17494
17495impl<'a, C, A> ChromeosdeviceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
17496
17497
17498    /// Perform the operation you have build so far.
17499    pub fn doit(mut self) -> Result<(hyper::client::Response, ChromeOsDevices)> {
17500        use std::io::{Read, Seek};
17501        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
17502        let mut dd = DefaultDelegate;
17503        let mut dlg: &mut dyn Delegate = match self._delegate {
17504            Some(d) => d,
17505            None => &mut dd
17506        };
17507        dlg.begin(MethodInfo { id: "directory.chromeosdevices.list",
17508                               http_method: hyper::method::Method::Get });
17509        let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len());
17510        params.push(("customerId", self._customer_id.to_string()));
17511        if let Some(value) = self._sort_order {
17512            params.push(("sortOrder", value.to_string()));
17513        }
17514        if let Some(value) = self._query {
17515            params.push(("query", value.to_string()));
17516        }
17517        if let Some(value) = self._projection {
17518            params.push(("projection", value.to_string()));
17519        }
17520        if let Some(value) = self._page_token {
17521            params.push(("pageToken", value.to_string()));
17522        }
17523        if let Some(value) = self._org_unit_path {
17524            params.push(("orgUnitPath", value.to_string()));
17525        }
17526        if let Some(value) = self._order_by {
17527            params.push(("orderBy", value.to_string()));
17528        }
17529        if let Some(value) = self._max_results {
17530            params.push(("maxResults", value.to_string()));
17531        }
17532        for &field in ["alt", "customerId", "sortOrder", "query", "projection", "pageToken", "orgUnitPath", "orderBy", "maxResults"].iter() {
17533            if self._additional_params.contains_key(field) {
17534                dlg.finished(false);
17535                return Err(Error::FieldClash(field));
17536            }
17537        }
17538        for (name, value) in self._additional_params.iter() {
17539            params.push((&name, value.clone()));
17540        }
17541
17542        params.push(("alt", "json".to_string()));
17543
17544        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/chromeos";
17545        if self._scopes.len() == 0 {
17546            self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
17547        }
17548
17549        for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
17550            let mut replace_with: Option<&str> = None;
17551            for &(name, ref value) in params.iter() {
17552                if name == param_name {
17553                    replace_with = Some(value);
17554                    break;
17555                }
17556            }
17557            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
17558        }
17559        {
17560            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
17561            for param_name in ["customerId"].iter() {
17562                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
17563                    indices_for_removal.push(index);
17564                }
17565            }
17566            for &index in indices_for_removal.iter() {
17567                params.remove(index);
17568            }
17569        }
17570
17571        let url = hyper::Url::parse_with_params(&url, params).unwrap();
17572
17573
17574
17575        loop {
17576            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
17577                Ok(token) => token,
17578                Err(err) => {
17579                    match  dlg.token(&*err) {
17580                        Some(token) => token,
17581                        None => {
17582                            dlg.finished(false);
17583                            return Err(Error::MissingToken(err))
17584                        }
17585                    }
17586                }
17587            };
17588            let auth_header = Authorization(Bearer { token: token.access_token });
17589            let mut req_result = {
17590                let mut client = &mut *self.hub.client.borrow_mut();
17591                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
17592                    .header(UserAgent(self.hub._user_agent.clone()))
17593                    .header(auth_header.clone());
17594
17595                dlg.pre_request();
17596                req.send()
17597            };
17598
17599            match req_result {
17600                Err(err) => {
17601                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
17602                        sleep(d);
17603                        continue;
17604                    }
17605                    dlg.finished(false);
17606                    return Err(Error::HttpError(err))
17607                }
17608                Ok(mut res) => {
17609                    if !res.status.is_success() {
17610                        let mut json_err = String::new();
17611                        res.read_to_string(&mut json_err).unwrap();
17612                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
17613                                                              json::from_str(&json_err).ok(),
17614                                                              json::from_str(&json_err).ok()) {
17615                            sleep(d);
17616                            continue;
17617                        }
17618                        dlg.finished(false);
17619                        return match json::from_str::<ErrorResponse>(&json_err){
17620                            Err(_) => Err(Error::Failure(res)),
17621                            Ok(serr) => Err(Error::BadRequest(serr))
17622                        }
17623                    }
17624                    let result_value = {
17625                        let mut json_response = String::new();
17626                        res.read_to_string(&mut json_response).unwrap();
17627                        match json::from_str(&json_response) {
17628                            Ok(decoded) => (res, decoded),
17629                            Err(err) => {
17630                                dlg.response_json_decode_error(&json_response, &err);
17631                                return Err(Error::JsonDecodeError(json_response, err));
17632                            }
17633                        }
17634                    };
17635
17636                    dlg.finished(true);
17637                    return Ok(result_value)
17638                }
17639            }
17640        }
17641    }
17642
17643
17644    /// Immutable ID of the G Suite account
17645    ///
17646    /// Sets the *customer id* path property to the given value.
17647    ///
17648    /// Even though the property as already been set when instantiating this call,
17649    /// we provide this method for API completeness.
17650    pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
17651        self._customer_id = new_value.to_string();
17652        self
17653    }
17654    /// Whether to return results in ascending or descending order. Only of use when orderBy is also used
17655    ///
17656    /// Sets the *sort order* query property to the given value.
17657    pub fn sort_order(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
17658        self._sort_order = Some(new_value.to_string());
17659        self
17660    }
17661    /// Search string in the format given at http://support.google.com/chromeos/a/bin/answer.py?answer=1698333
17662    ///
17663    /// Sets the *query* query property to the given value.
17664    pub fn query(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
17665        self._query = Some(new_value.to_string());
17666        self
17667    }
17668    /// Restrict information returned to a set of selected fields.
17669    ///
17670    /// Sets the *projection* query property to the given value.
17671    pub fn projection(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
17672        self._projection = Some(new_value.to_string());
17673        self
17674    }
17675    /// Token to specify next page in the list
17676    ///
17677    /// Sets the *page token* query property to the given value.
17678    pub fn page_token(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
17679        self._page_token = Some(new_value.to_string());
17680        self
17681    }
17682    /// Full path of the organizational unit or its ID
17683    ///
17684    /// Sets the *org unit path* query property to the given value.
17685    pub fn org_unit_path(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
17686        self._org_unit_path = Some(new_value.to_string());
17687        self
17688    }
17689    /// Column to use for sorting results
17690    ///
17691    /// Sets the *order by* query property to the given value.
17692    pub fn order_by(mut self, new_value: &str) -> ChromeosdeviceListCall<'a, C, A> {
17693        self._order_by = Some(new_value.to_string());
17694        self
17695    }
17696    /// Maximum number of results to return. Max allowed value is 200.
17697    ///
17698    /// Sets the *max results* query property to the given value.
17699    pub fn max_results(mut self, new_value: i32) -> ChromeosdeviceListCall<'a, C, A> {
17700        self._max_results = Some(new_value);
17701        self
17702    }
17703    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17704    /// while executing the actual API request.
17705    /// 
17706    /// It should be used to handle progress information, and to implement a certain level of resilience.
17707    ///
17708    /// Sets the *delegate* property to the given value.
17709    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ChromeosdeviceListCall<'a, C, A> {
17710        self._delegate = Some(new_value);
17711        self
17712    }
17713
17714    /// Set any additional parameter of the query string used in the request.
17715    /// It should be used to set parameters which are not yet available through their own
17716    /// setters.
17717    ///
17718    /// Please note that this method must not be used to set any of the known parameters
17719    /// which have their own setter method. If done anyway, the request will fail.
17720    ///
17721    /// # Additional Parameters
17722    ///
17723    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17724    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17725    /// * *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.
17726    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17727    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17728    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17729    /// * *alt* (query-string) - Data format for the response.
17730    pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceListCall<'a, C, A>
17731                                                        where T: AsRef<str> {
17732        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
17733        self
17734    }
17735
17736    /// Identifies the authorization scope for the method you are building.
17737    ///
17738    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
17739    /// `Scope::DirectoryDeviceChromeoReadonly`.
17740    ///
17741    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17742    /// tokens for more than one scope.
17743    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
17744    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
17745    /// function for details).
17746    ///
17747    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17748    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17749    /// sufficient, a read-write scope will do as well.
17750    pub fn add_scope<T, S>(mut self, scope: T) -> ChromeosdeviceListCall<'a, C, A>
17751                                                        where T: Into<Option<S>>,
17752                                                              S: AsRef<str> {
17753        match scope.into() {
17754          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
17755          None => None,
17756        };
17757        self
17758    }
17759}
17760
17761
17762/// Update Chrome OS Device. This method supports patch semantics.
17763///
17764/// A builder for the *patch* method supported by a *chromeosdevice* resource.
17765/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
17766///
17767/// # Example
17768///
17769/// Instantiate a resource method builder
17770///
17771/// ```test_harness,no_run
17772/// # extern crate hyper;
17773/// # extern crate hyper_rustls;
17774/// # extern crate yup_oauth2 as oauth2;
17775/// # extern crate google_admin1_directory as admin1_directory;
17776/// use admin1_directory::ChromeOsDevice;
17777/// # #[test] fn egal() {
17778/// # use std::default::Default;
17779/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
17780/// # use admin1_directory::Directory;
17781/// 
17782/// # let secret: ApplicationSecret = Default::default();
17783/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
17784/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
17785/// #                               <MemoryStorage as Default>::default(), None);
17786/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
17787/// // As the method needs a request, you would usually fill it with the desired information
17788/// // into the respective structure. Some of the parts shown here might not be applicable !
17789/// // Values shown here are possibly random and not representative !
17790/// let mut req = ChromeOsDevice::default();
17791/// 
17792/// // You can configure optional parameters by calling the respective setters at will, and
17793/// // execute the final call using `doit()`.
17794/// // Values shown here are possibly random and not representative !
17795/// let result = hub.chromeosdevices().patch(req, "customerId", "deviceId")
17796///              .projection("voluptua.")
17797///              .doit();
17798/// # }
17799/// ```
17800pub struct ChromeosdevicePatchCall<'a, C, A>
17801    where C: 'a, A: 'a {
17802
17803    hub: &'a Directory<C, A>,
17804    _request: ChromeOsDevice,
17805    _customer_id: String,
17806    _device_id: String,
17807    _projection: Option<String>,
17808    _delegate: Option<&'a mut dyn Delegate>,
17809    _additional_params: HashMap<String, String>,
17810    _scopes: BTreeMap<String, ()>
17811}
17812
17813impl<'a, C, A> CallBuilder for ChromeosdevicePatchCall<'a, C, A> {}
17814
17815impl<'a, C, A> ChromeosdevicePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
17816
17817
17818    /// Perform the operation you have build so far.
17819    pub fn doit(mut self) -> Result<(hyper::client::Response, ChromeOsDevice)> {
17820        use std::io::{Read, Seek};
17821        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
17822        let mut dd = DefaultDelegate;
17823        let mut dlg: &mut dyn Delegate = match self._delegate {
17824            Some(d) => d,
17825            None => &mut dd
17826        };
17827        dlg.begin(MethodInfo { id: "directory.chromeosdevices.patch",
17828                               http_method: hyper::method::Method::Patch });
17829        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
17830        params.push(("customerId", self._customer_id.to_string()));
17831        params.push(("deviceId", self._device_id.to_string()));
17832        if let Some(value) = self._projection {
17833            params.push(("projection", value.to_string()));
17834        }
17835        for &field in ["alt", "customerId", "deviceId", "projection"].iter() {
17836            if self._additional_params.contains_key(field) {
17837                dlg.finished(false);
17838                return Err(Error::FieldClash(field));
17839            }
17840        }
17841        for (name, value) in self._additional_params.iter() {
17842            params.push((&name, value.clone()));
17843        }
17844
17845        params.push(("alt", "json".to_string()));
17846
17847        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/chromeos/{deviceId}";
17848        if self._scopes.len() == 0 {
17849            self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
17850        }
17851
17852        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{deviceId}", "deviceId")].iter() {
17853            let mut replace_with: Option<&str> = None;
17854            for &(name, ref value) in params.iter() {
17855                if name == param_name {
17856                    replace_with = Some(value);
17857                    break;
17858                }
17859            }
17860            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
17861        }
17862        {
17863            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
17864            for param_name in ["deviceId", "customerId"].iter() {
17865                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
17866                    indices_for_removal.push(index);
17867                }
17868            }
17869            for &index in indices_for_removal.iter() {
17870                params.remove(index);
17871            }
17872        }
17873
17874        let url = hyper::Url::parse_with_params(&url, params).unwrap();
17875
17876        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
17877        let mut request_value_reader =
17878            {
17879                let mut value = json::value::to_value(&self._request).expect("serde to work");
17880                remove_json_null_values(&mut value);
17881                let mut dst = io::Cursor::new(Vec::with_capacity(128));
17882                json::to_writer(&mut dst, &value).unwrap();
17883                dst
17884            };
17885        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
17886        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
17887
17888
17889        loop {
17890            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
17891                Ok(token) => token,
17892                Err(err) => {
17893                    match  dlg.token(&*err) {
17894                        Some(token) => token,
17895                        None => {
17896                            dlg.finished(false);
17897                            return Err(Error::MissingToken(err))
17898                        }
17899                    }
17900                }
17901            };
17902            let auth_header = Authorization(Bearer { token: token.access_token });
17903            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
17904            let mut req_result = {
17905                let mut client = &mut *self.hub.client.borrow_mut();
17906                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
17907                    .header(UserAgent(self.hub._user_agent.clone()))
17908                    .header(auth_header.clone())
17909                    .header(ContentType(json_mime_type.clone()))
17910                    .header(ContentLength(request_size as u64))
17911                    .body(&mut request_value_reader);
17912
17913                dlg.pre_request();
17914                req.send()
17915            };
17916
17917            match req_result {
17918                Err(err) => {
17919                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
17920                        sleep(d);
17921                        continue;
17922                    }
17923                    dlg.finished(false);
17924                    return Err(Error::HttpError(err))
17925                }
17926                Ok(mut res) => {
17927                    if !res.status.is_success() {
17928                        let mut json_err = String::new();
17929                        res.read_to_string(&mut json_err).unwrap();
17930                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
17931                                                              json::from_str(&json_err).ok(),
17932                                                              json::from_str(&json_err).ok()) {
17933                            sleep(d);
17934                            continue;
17935                        }
17936                        dlg.finished(false);
17937                        return match json::from_str::<ErrorResponse>(&json_err){
17938                            Err(_) => Err(Error::Failure(res)),
17939                            Ok(serr) => Err(Error::BadRequest(serr))
17940                        }
17941                    }
17942                    let result_value = {
17943                        let mut json_response = String::new();
17944                        res.read_to_string(&mut json_response).unwrap();
17945                        match json::from_str(&json_response) {
17946                            Ok(decoded) => (res, decoded),
17947                            Err(err) => {
17948                                dlg.response_json_decode_error(&json_response, &err);
17949                                return Err(Error::JsonDecodeError(json_response, err));
17950                            }
17951                        }
17952                    };
17953
17954                    dlg.finished(true);
17955                    return Ok(result_value)
17956                }
17957            }
17958        }
17959    }
17960
17961
17962    ///
17963    /// Sets the *request* property to the given value.
17964    ///
17965    /// Even though the property as already been set when instantiating this call,
17966    /// we provide this method for API completeness.
17967    pub fn request(mut self, new_value: ChromeOsDevice) -> ChromeosdevicePatchCall<'a, C, A> {
17968        self._request = new_value;
17969        self
17970    }
17971    /// Immutable ID of the G Suite account
17972    ///
17973    /// Sets the *customer id* path property to the given value.
17974    ///
17975    /// Even though the property as already been set when instantiating this call,
17976    /// we provide this method for API completeness.
17977    pub fn customer_id(mut self, new_value: &str) -> ChromeosdevicePatchCall<'a, C, A> {
17978        self._customer_id = new_value.to_string();
17979        self
17980    }
17981    /// Immutable ID of Chrome OS Device
17982    ///
17983    /// Sets the *device id* path property to the given value.
17984    ///
17985    /// Even though the property as already been set when instantiating this call,
17986    /// we provide this method for API completeness.
17987    pub fn device_id(mut self, new_value: &str) -> ChromeosdevicePatchCall<'a, C, A> {
17988        self._device_id = new_value.to_string();
17989        self
17990    }
17991    /// Restrict information returned to a set of selected fields.
17992    ///
17993    /// Sets the *projection* query property to the given value.
17994    pub fn projection(mut self, new_value: &str) -> ChromeosdevicePatchCall<'a, C, A> {
17995        self._projection = Some(new_value.to_string());
17996        self
17997    }
17998    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17999    /// while executing the actual API request.
18000    /// 
18001    /// It should be used to handle progress information, and to implement a certain level of resilience.
18002    ///
18003    /// Sets the *delegate* property to the given value.
18004    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ChromeosdevicePatchCall<'a, C, A> {
18005        self._delegate = Some(new_value);
18006        self
18007    }
18008
18009    /// Set any additional parameter of the query string used in the request.
18010    /// It should be used to set parameters which are not yet available through their own
18011    /// setters.
18012    ///
18013    /// Please note that this method must not be used to set any of the known parameters
18014    /// which have their own setter method. If done anyway, the request will fail.
18015    ///
18016    /// # Additional Parameters
18017    ///
18018    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18019    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18020    /// * *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.
18021    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18022    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18023    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18024    /// * *alt* (query-string) - Data format for the response.
18025    pub fn param<T>(mut self, name: T, value: T) -> ChromeosdevicePatchCall<'a, C, A>
18026                                                        where T: AsRef<str> {
18027        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
18028        self
18029    }
18030
18031    /// Identifies the authorization scope for the method you are building.
18032    ///
18033    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
18034    /// `Scope::DirectoryDeviceChromeo`.
18035    ///
18036    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18037    /// tokens for more than one scope.
18038    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
18039    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
18040    /// function for details).
18041    ///
18042    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18043    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18044    /// sufficient, a read-write scope will do as well.
18045    pub fn add_scope<T, S>(mut self, scope: T) -> ChromeosdevicePatchCall<'a, C, A>
18046                                                        where T: Into<Option<S>>,
18047                                                              S: AsRef<str> {
18048        match scope.into() {
18049          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
18050          None => None,
18051        };
18052        self
18053    }
18054}
18055
18056
18057/// Update Chrome OS Device
18058///
18059/// A builder for the *update* method supported by a *chromeosdevice* resource.
18060/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
18061///
18062/// # Example
18063///
18064/// Instantiate a resource method builder
18065///
18066/// ```test_harness,no_run
18067/// # extern crate hyper;
18068/// # extern crate hyper_rustls;
18069/// # extern crate yup_oauth2 as oauth2;
18070/// # extern crate google_admin1_directory as admin1_directory;
18071/// use admin1_directory::ChromeOsDevice;
18072/// # #[test] fn egal() {
18073/// # use std::default::Default;
18074/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
18075/// # use admin1_directory::Directory;
18076/// 
18077/// # let secret: ApplicationSecret = Default::default();
18078/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
18079/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
18080/// #                               <MemoryStorage as Default>::default(), None);
18081/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
18082/// // As the method needs a request, you would usually fill it with the desired information
18083/// // into the respective structure. Some of the parts shown here might not be applicable !
18084/// // Values shown here are possibly random and not representative !
18085/// let mut req = ChromeOsDevice::default();
18086/// 
18087/// // You can configure optional parameters by calling the respective setters at will, and
18088/// // execute the final call using `doit()`.
18089/// // Values shown here are possibly random and not representative !
18090/// let result = hub.chromeosdevices().update(req, "customerId", "deviceId")
18091///              .projection("aliquyam")
18092///              .doit();
18093/// # }
18094/// ```
18095pub struct ChromeosdeviceUpdateCall<'a, C, A>
18096    where C: 'a, A: 'a {
18097
18098    hub: &'a Directory<C, A>,
18099    _request: ChromeOsDevice,
18100    _customer_id: String,
18101    _device_id: String,
18102    _projection: Option<String>,
18103    _delegate: Option<&'a mut dyn Delegate>,
18104    _additional_params: HashMap<String, String>,
18105    _scopes: BTreeMap<String, ()>
18106}
18107
18108impl<'a, C, A> CallBuilder for ChromeosdeviceUpdateCall<'a, C, A> {}
18109
18110impl<'a, C, A> ChromeosdeviceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
18111
18112
18113    /// Perform the operation you have build so far.
18114    pub fn doit(mut self) -> Result<(hyper::client::Response, ChromeOsDevice)> {
18115        use std::io::{Read, Seek};
18116        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
18117        let mut dd = DefaultDelegate;
18118        let mut dlg: &mut dyn Delegate = match self._delegate {
18119            Some(d) => d,
18120            None => &mut dd
18121        };
18122        dlg.begin(MethodInfo { id: "directory.chromeosdevices.update",
18123                               http_method: hyper::method::Method::Put });
18124        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
18125        params.push(("customerId", self._customer_id.to_string()));
18126        params.push(("deviceId", self._device_id.to_string()));
18127        if let Some(value) = self._projection {
18128            params.push(("projection", value.to_string()));
18129        }
18130        for &field in ["alt", "customerId", "deviceId", "projection"].iter() {
18131            if self._additional_params.contains_key(field) {
18132                dlg.finished(false);
18133                return Err(Error::FieldClash(field));
18134            }
18135        }
18136        for (name, value) in self._additional_params.iter() {
18137            params.push((&name, value.clone()));
18138        }
18139
18140        params.push(("alt", "json".to_string()));
18141
18142        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/chromeos/{deviceId}";
18143        if self._scopes.len() == 0 {
18144            self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
18145        }
18146
18147        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{deviceId}", "deviceId")].iter() {
18148            let mut replace_with: Option<&str> = None;
18149            for &(name, ref value) in params.iter() {
18150                if name == param_name {
18151                    replace_with = Some(value);
18152                    break;
18153                }
18154            }
18155            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
18156        }
18157        {
18158            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
18159            for param_name in ["deviceId", "customerId"].iter() {
18160                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
18161                    indices_for_removal.push(index);
18162                }
18163            }
18164            for &index in indices_for_removal.iter() {
18165                params.remove(index);
18166            }
18167        }
18168
18169        let url = hyper::Url::parse_with_params(&url, params).unwrap();
18170
18171        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
18172        let mut request_value_reader =
18173            {
18174                let mut value = json::value::to_value(&self._request).expect("serde to work");
18175                remove_json_null_values(&mut value);
18176                let mut dst = io::Cursor::new(Vec::with_capacity(128));
18177                json::to_writer(&mut dst, &value).unwrap();
18178                dst
18179            };
18180        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
18181        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
18182
18183
18184        loop {
18185            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
18186                Ok(token) => token,
18187                Err(err) => {
18188                    match  dlg.token(&*err) {
18189                        Some(token) => token,
18190                        None => {
18191                            dlg.finished(false);
18192                            return Err(Error::MissingToken(err))
18193                        }
18194                    }
18195                }
18196            };
18197            let auth_header = Authorization(Bearer { token: token.access_token });
18198            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
18199            let mut req_result = {
18200                let mut client = &mut *self.hub.client.borrow_mut();
18201                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
18202                    .header(UserAgent(self.hub._user_agent.clone()))
18203                    .header(auth_header.clone())
18204                    .header(ContentType(json_mime_type.clone()))
18205                    .header(ContentLength(request_size as u64))
18206                    .body(&mut request_value_reader);
18207
18208                dlg.pre_request();
18209                req.send()
18210            };
18211
18212            match req_result {
18213                Err(err) => {
18214                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
18215                        sleep(d);
18216                        continue;
18217                    }
18218                    dlg.finished(false);
18219                    return Err(Error::HttpError(err))
18220                }
18221                Ok(mut res) => {
18222                    if !res.status.is_success() {
18223                        let mut json_err = String::new();
18224                        res.read_to_string(&mut json_err).unwrap();
18225                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
18226                                                              json::from_str(&json_err).ok(),
18227                                                              json::from_str(&json_err).ok()) {
18228                            sleep(d);
18229                            continue;
18230                        }
18231                        dlg.finished(false);
18232                        return match json::from_str::<ErrorResponse>(&json_err){
18233                            Err(_) => Err(Error::Failure(res)),
18234                            Ok(serr) => Err(Error::BadRequest(serr))
18235                        }
18236                    }
18237                    let result_value = {
18238                        let mut json_response = String::new();
18239                        res.read_to_string(&mut json_response).unwrap();
18240                        match json::from_str(&json_response) {
18241                            Ok(decoded) => (res, decoded),
18242                            Err(err) => {
18243                                dlg.response_json_decode_error(&json_response, &err);
18244                                return Err(Error::JsonDecodeError(json_response, err));
18245                            }
18246                        }
18247                    };
18248
18249                    dlg.finished(true);
18250                    return Ok(result_value)
18251                }
18252            }
18253        }
18254    }
18255
18256
18257    ///
18258    /// Sets the *request* property to the given value.
18259    ///
18260    /// Even though the property as already been set when instantiating this call,
18261    /// we provide this method for API completeness.
18262    pub fn request(mut self, new_value: ChromeOsDevice) -> ChromeosdeviceUpdateCall<'a, C, A> {
18263        self._request = new_value;
18264        self
18265    }
18266    /// Immutable ID of the G Suite account
18267    ///
18268    /// Sets the *customer id* path property to the given value.
18269    ///
18270    /// Even though the property as already been set when instantiating this call,
18271    /// we provide this method for API completeness.
18272    pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
18273        self._customer_id = new_value.to_string();
18274        self
18275    }
18276    /// Immutable ID of Chrome OS Device
18277    ///
18278    /// Sets the *device id* path property to the given value.
18279    ///
18280    /// Even though the property as already been set when instantiating this call,
18281    /// we provide this method for API completeness.
18282    pub fn device_id(mut self, new_value: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
18283        self._device_id = new_value.to_string();
18284        self
18285    }
18286    /// Restrict information returned to a set of selected fields.
18287    ///
18288    /// Sets the *projection* query property to the given value.
18289    pub fn projection(mut self, new_value: &str) -> ChromeosdeviceUpdateCall<'a, C, A> {
18290        self._projection = Some(new_value.to_string());
18291        self
18292    }
18293    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18294    /// while executing the actual API request.
18295    /// 
18296    /// It should be used to handle progress information, and to implement a certain level of resilience.
18297    ///
18298    /// Sets the *delegate* property to the given value.
18299    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ChromeosdeviceUpdateCall<'a, C, A> {
18300        self._delegate = Some(new_value);
18301        self
18302    }
18303
18304    /// Set any additional parameter of the query string used in the request.
18305    /// It should be used to set parameters which are not yet available through their own
18306    /// setters.
18307    ///
18308    /// Please note that this method must not be used to set any of the known parameters
18309    /// which have their own setter method. If done anyway, the request will fail.
18310    ///
18311    /// # Additional Parameters
18312    ///
18313    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18314    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18315    /// * *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.
18316    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18317    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18318    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18319    /// * *alt* (query-string) - Data format for the response.
18320    pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceUpdateCall<'a, C, A>
18321                                                        where T: AsRef<str> {
18322        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
18323        self
18324    }
18325
18326    /// Identifies the authorization scope for the method you are building.
18327    ///
18328    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
18329    /// `Scope::DirectoryDeviceChromeo`.
18330    ///
18331    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18332    /// tokens for more than one scope.
18333    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
18334    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
18335    /// function for details).
18336    ///
18337    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18338    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18339    /// sufficient, a read-write scope will do as well.
18340    pub fn add_scope<T, S>(mut self, scope: T) -> ChromeosdeviceUpdateCall<'a, C, A>
18341                                                        where T: Into<Option<S>>,
18342                                                              S: AsRef<str> {
18343        match scope.into() {
18344          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
18345          None => None,
18346        };
18347        self
18348    }
18349}
18350
18351
18352/// Retrieve Chrome OS Device
18353///
18354/// A builder for the *get* method supported by a *chromeosdevice* resource.
18355/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
18356///
18357/// # Example
18358///
18359/// Instantiate a resource method builder
18360///
18361/// ```test_harness,no_run
18362/// # extern crate hyper;
18363/// # extern crate hyper_rustls;
18364/// # extern crate yup_oauth2 as oauth2;
18365/// # extern crate google_admin1_directory as admin1_directory;
18366/// # #[test] fn egal() {
18367/// # use std::default::Default;
18368/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
18369/// # use admin1_directory::Directory;
18370/// 
18371/// # let secret: ApplicationSecret = Default::default();
18372/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
18373/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
18374/// #                               <MemoryStorage as Default>::default(), None);
18375/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
18376/// // You can configure optional parameters by calling the respective setters at will, and
18377/// // execute the final call using `doit()`.
18378/// // Values shown here are possibly random and not representative !
18379/// let result = hub.chromeosdevices().get("customerId", "deviceId")
18380///              .projection("et")
18381///              .doit();
18382/// # }
18383/// ```
18384pub struct ChromeosdeviceGetCall<'a, C, A>
18385    where C: 'a, A: 'a {
18386
18387    hub: &'a Directory<C, A>,
18388    _customer_id: String,
18389    _device_id: String,
18390    _projection: Option<String>,
18391    _delegate: Option<&'a mut dyn Delegate>,
18392    _additional_params: HashMap<String, String>,
18393    _scopes: BTreeMap<String, ()>
18394}
18395
18396impl<'a, C, A> CallBuilder for ChromeosdeviceGetCall<'a, C, A> {}
18397
18398impl<'a, C, A> ChromeosdeviceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
18399
18400
18401    /// Perform the operation you have build so far.
18402    pub fn doit(mut self) -> Result<(hyper::client::Response, ChromeOsDevice)> {
18403        use std::io::{Read, Seek};
18404        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
18405        let mut dd = DefaultDelegate;
18406        let mut dlg: &mut dyn Delegate = match self._delegate {
18407            Some(d) => d,
18408            None => &mut dd
18409        };
18410        dlg.begin(MethodInfo { id: "directory.chromeosdevices.get",
18411                               http_method: hyper::method::Method::Get });
18412        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
18413        params.push(("customerId", self._customer_id.to_string()));
18414        params.push(("deviceId", self._device_id.to_string()));
18415        if let Some(value) = self._projection {
18416            params.push(("projection", value.to_string()));
18417        }
18418        for &field in ["alt", "customerId", "deviceId", "projection"].iter() {
18419            if self._additional_params.contains_key(field) {
18420                dlg.finished(false);
18421                return Err(Error::FieldClash(field));
18422            }
18423        }
18424        for (name, value) in self._additional_params.iter() {
18425            params.push((&name, value.clone()));
18426        }
18427
18428        params.push(("alt", "json".to_string()));
18429
18430        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/chromeos/{deviceId}";
18431        if self._scopes.len() == 0 {
18432            self._scopes.insert(Scope::DirectoryDeviceChromeoReadonly.as_ref().to_string(), ());
18433        }
18434
18435        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{deviceId}", "deviceId")].iter() {
18436            let mut replace_with: Option<&str> = None;
18437            for &(name, ref value) in params.iter() {
18438                if name == param_name {
18439                    replace_with = Some(value);
18440                    break;
18441                }
18442            }
18443            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
18444        }
18445        {
18446            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
18447            for param_name in ["deviceId", "customerId"].iter() {
18448                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
18449                    indices_for_removal.push(index);
18450                }
18451            }
18452            for &index in indices_for_removal.iter() {
18453                params.remove(index);
18454            }
18455        }
18456
18457        let url = hyper::Url::parse_with_params(&url, params).unwrap();
18458
18459
18460
18461        loop {
18462            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
18463                Ok(token) => token,
18464                Err(err) => {
18465                    match  dlg.token(&*err) {
18466                        Some(token) => token,
18467                        None => {
18468                            dlg.finished(false);
18469                            return Err(Error::MissingToken(err))
18470                        }
18471                    }
18472                }
18473            };
18474            let auth_header = Authorization(Bearer { token: token.access_token });
18475            let mut req_result = {
18476                let mut client = &mut *self.hub.client.borrow_mut();
18477                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
18478                    .header(UserAgent(self.hub._user_agent.clone()))
18479                    .header(auth_header.clone());
18480
18481                dlg.pre_request();
18482                req.send()
18483            };
18484
18485            match req_result {
18486                Err(err) => {
18487                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
18488                        sleep(d);
18489                        continue;
18490                    }
18491                    dlg.finished(false);
18492                    return Err(Error::HttpError(err))
18493                }
18494                Ok(mut res) => {
18495                    if !res.status.is_success() {
18496                        let mut json_err = String::new();
18497                        res.read_to_string(&mut json_err).unwrap();
18498                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
18499                                                              json::from_str(&json_err).ok(),
18500                                                              json::from_str(&json_err).ok()) {
18501                            sleep(d);
18502                            continue;
18503                        }
18504                        dlg.finished(false);
18505                        return match json::from_str::<ErrorResponse>(&json_err){
18506                            Err(_) => Err(Error::Failure(res)),
18507                            Ok(serr) => Err(Error::BadRequest(serr))
18508                        }
18509                    }
18510                    let result_value = {
18511                        let mut json_response = String::new();
18512                        res.read_to_string(&mut json_response).unwrap();
18513                        match json::from_str(&json_response) {
18514                            Ok(decoded) => (res, decoded),
18515                            Err(err) => {
18516                                dlg.response_json_decode_error(&json_response, &err);
18517                                return Err(Error::JsonDecodeError(json_response, err));
18518                            }
18519                        }
18520                    };
18521
18522                    dlg.finished(true);
18523                    return Ok(result_value)
18524                }
18525            }
18526        }
18527    }
18528
18529
18530    /// Immutable ID of the G Suite account
18531    ///
18532    /// Sets the *customer id* path property to the given value.
18533    ///
18534    /// Even though the property as already been set when instantiating this call,
18535    /// we provide this method for API completeness.
18536    pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceGetCall<'a, C, A> {
18537        self._customer_id = new_value.to_string();
18538        self
18539    }
18540    /// Immutable ID of Chrome OS Device
18541    ///
18542    /// Sets the *device id* path property to the given value.
18543    ///
18544    /// Even though the property as already been set when instantiating this call,
18545    /// we provide this method for API completeness.
18546    pub fn device_id(mut self, new_value: &str) -> ChromeosdeviceGetCall<'a, C, A> {
18547        self._device_id = new_value.to_string();
18548        self
18549    }
18550    /// Restrict information returned to a set of selected fields.
18551    ///
18552    /// Sets the *projection* query property to the given value.
18553    pub fn projection(mut self, new_value: &str) -> ChromeosdeviceGetCall<'a, C, A> {
18554        self._projection = Some(new_value.to_string());
18555        self
18556    }
18557    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18558    /// while executing the actual API request.
18559    /// 
18560    /// It should be used to handle progress information, and to implement a certain level of resilience.
18561    ///
18562    /// Sets the *delegate* property to the given value.
18563    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ChromeosdeviceGetCall<'a, C, A> {
18564        self._delegate = Some(new_value);
18565        self
18566    }
18567
18568    /// Set any additional parameter of the query string used in the request.
18569    /// It should be used to set parameters which are not yet available through their own
18570    /// setters.
18571    ///
18572    /// Please note that this method must not be used to set any of the known parameters
18573    /// which have their own setter method. If done anyway, the request will fail.
18574    ///
18575    /// # Additional Parameters
18576    ///
18577    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18578    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18579    /// * *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.
18580    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18581    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18582    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18583    /// * *alt* (query-string) - Data format for the response.
18584    pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceGetCall<'a, C, A>
18585                                                        where T: AsRef<str> {
18586        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
18587        self
18588    }
18589
18590    /// Identifies the authorization scope for the method you are building.
18591    ///
18592    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
18593    /// `Scope::DirectoryDeviceChromeoReadonly`.
18594    ///
18595    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18596    /// tokens for more than one scope.
18597    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
18598    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
18599    /// function for details).
18600    ///
18601    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18602    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18603    /// sufficient, a read-write scope will do as well.
18604    pub fn add_scope<T, S>(mut self, scope: T) -> ChromeosdeviceGetCall<'a, C, A>
18605                                                        where T: Into<Option<S>>,
18606                                                              S: AsRef<str> {
18607        match scope.into() {
18608          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
18609          None => None,
18610        };
18611        self
18612    }
18613}
18614
18615
18616/// Take action on Chrome OS Device
18617///
18618/// A builder for the *action* method supported by a *chromeosdevice* resource.
18619/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
18620///
18621/// # Example
18622///
18623/// Instantiate a resource method builder
18624///
18625/// ```test_harness,no_run
18626/// # extern crate hyper;
18627/// # extern crate hyper_rustls;
18628/// # extern crate yup_oauth2 as oauth2;
18629/// # extern crate google_admin1_directory as admin1_directory;
18630/// use admin1_directory::ChromeOsDeviceAction;
18631/// # #[test] fn egal() {
18632/// # use std::default::Default;
18633/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
18634/// # use admin1_directory::Directory;
18635/// 
18636/// # let secret: ApplicationSecret = Default::default();
18637/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
18638/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
18639/// #                               <MemoryStorage as Default>::default(), None);
18640/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
18641/// // As the method needs a request, you would usually fill it with the desired information
18642/// // into the respective structure. Some of the parts shown here might not be applicable !
18643/// // Values shown here are possibly random and not representative !
18644/// let mut req = ChromeOsDeviceAction::default();
18645/// 
18646/// // You can configure optional parameters by calling the respective setters at will, and
18647/// // execute the final call using `doit()`.
18648/// // Values shown here are possibly random and not representative !
18649/// let result = hub.chromeosdevices().action(req, "customerId", "resourceId")
18650///              .doit();
18651/// # }
18652/// ```
18653pub struct ChromeosdeviceActionCall<'a, C, A>
18654    where C: 'a, A: 'a {
18655
18656    hub: &'a Directory<C, A>,
18657    _request: ChromeOsDeviceAction,
18658    _customer_id: String,
18659    _resource_id: String,
18660    _delegate: Option<&'a mut dyn Delegate>,
18661    _additional_params: HashMap<String, String>,
18662    _scopes: BTreeMap<String, ()>
18663}
18664
18665impl<'a, C, A> CallBuilder for ChromeosdeviceActionCall<'a, C, A> {}
18666
18667impl<'a, C, A> ChromeosdeviceActionCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
18668
18669
18670    /// Perform the operation you have build so far.
18671    pub fn doit(mut self) -> Result<hyper::client::Response> {
18672        use std::io::{Read, Seek};
18673        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
18674        let mut dd = DefaultDelegate;
18675        let mut dlg: &mut dyn Delegate = match self._delegate {
18676            Some(d) => d,
18677            None => &mut dd
18678        };
18679        dlg.begin(MethodInfo { id: "directory.chromeosdevices.action",
18680                               http_method: hyper::method::Method::Post });
18681        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
18682        params.push(("customerId", self._customer_id.to_string()));
18683        params.push(("resourceId", self._resource_id.to_string()));
18684        for &field in ["customerId", "resourceId"].iter() {
18685            if self._additional_params.contains_key(field) {
18686                dlg.finished(false);
18687                return Err(Error::FieldClash(field));
18688            }
18689        }
18690        for (name, value) in self._additional_params.iter() {
18691            params.push((&name, value.clone()));
18692        }
18693
18694
18695        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/chromeos/{resourceId}/action";
18696        if self._scopes.len() == 0 {
18697            self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
18698        }
18699
18700        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{resourceId}", "resourceId")].iter() {
18701            let mut replace_with: Option<&str> = None;
18702            for &(name, ref value) in params.iter() {
18703                if name == param_name {
18704                    replace_with = Some(value);
18705                    break;
18706                }
18707            }
18708            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
18709        }
18710        {
18711            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
18712            for param_name in ["resourceId", "customerId"].iter() {
18713                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
18714                    indices_for_removal.push(index);
18715                }
18716            }
18717            for &index in indices_for_removal.iter() {
18718                params.remove(index);
18719            }
18720        }
18721
18722        let url = hyper::Url::parse_with_params(&url, params).unwrap();
18723
18724        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
18725        let mut request_value_reader =
18726            {
18727                let mut value = json::value::to_value(&self._request).expect("serde to work");
18728                remove_json_null_values(&mut value);
18729                let mut dst = io::Cursor::new(Vec::with_capacity(128));
18730                json::to_writer(&mut dst, &value).unwrap();
18731                dst
18732            };
18733        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
18734        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
18735
18736
18737        loop {
18738            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
18739                Ok(token) => token,
18740                Err(err) => {
18741                    match  dlg.token(&*err) {
18742                        Some(token) => token,
18743                        None => {
18744                            dlg.finished(false);
18745                            return Err(Error::MissingToken(err))
18746                        }
18747                    }
18748                }
18749            };
18750            let auth_header = Authorization(Bearer { token: token.access_token });
18751            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
18752            let mut req_result = {
18753                let mut client = &mut *self.hub.client.borrow_mut();
18754                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
18755                    .header(UserAgent(self.hub._user_agent.clone()))
18756                    .header(auth_header.clone())
18757                    .header(ContentType(json_mime_type.clone()))
18758                    .header(ContentLength(request_size as u64))
18759                    .body(&mut request_value_reader);
18760
18761                dlg.pre_request();
18762                req.send()
18763            };
18764
18765            match req_result {
18766                Err(err) => {
18767                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
18768                        sleep(d);
18769                        continue;
18770                    }
18771                    dlg.finished(false);
18772                    return Err(Error::HttpError(err))
18773                }
18774                Ok(mut res) => {
18775                    if !res.status.is_success() {
18776                        let mut json_err = String::new();
18777                        res.read_to_string(&mut json_err).unwrap();
18778                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
18779                                                              json::from_str(&json_err).ok(),
18780                                                              json::from_str(&json_err).ok()) {
18781                            sleep(d);
18782                            continue;
18783                        }
18784                        dlg.finished(false);
18785                        return match json::from_str::<ErrorResponse>(&json_err){
18786                            Err(_) => Err(Error::Failure(res)),
18787                            Ok(serr) => Err(Error::BadRequest(serr))
18788                        }
18789                    }
18790                    let result_value = res;
18791
18792                    dlg.finished(true);
18793                    return Ok(result_value)
18794                }
18795            }
18796        }
18797    }
18798
18799
18800    ///
18801    /// Sets the *request* property to the given value.
18802    ///
18803    /// Even though the property as already been set when instantiating this call,
18804    /// we provide this method for API completeness.
18805    pub fn request(mut self, new_value: ChromeOsDeviceAction) -> ChromeosdeviceActionCall<'a, C, A> {
18806        self._request = new_value;
18807        self
18808    }
18809    /// Immutable ID of the G Suite account
18810    ///
18811    /// Sets the *customer id* path property to the given value.
18812    ///
18813    /// Even though the property as already been set when instantiating this call,
18814    /// we provide this method for API completeness.
18815    pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceActionCall<'a, C, A> {
18816        self._customer_id = new_value.to_string();
18817        self
18818    }
18819    /// Immutable ID of Chrome OS Device
18820    ///
18821    /// Sets the *resource id* path property to the given value.
18822    ///
18823    /// Even though the property as already been set when instantiating this call,
18824    /// we provide this method for API completeness.
18825    pub fn resource_id(mut self, new_value: &str) -> ChromeosdeviceActionCall<'a, C, A> {
18826        self._resource_id = new_value.to_string();
18827        self
18828    }
18829    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18830    /// while executing the actual API request.
18831    /// 
18832    /// It should be used to handle progress information, and to implement a certain level of resilience.
18833    ///
18834    /// Sets the *delegate* property to the given value.
18835    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ChromeosdeviceActionCall<'a, C, A> {
18836        self._delegate = Some(new_value);
18837        self
18838    }
18839
18840    /// Set any additional parameter of the query string used in the request.
18841    /// It should be used to set parameters which are not yet available through their own
18842    /// setters.
18843    ///
18844    /// Please note that this method must not be used to set any of the known parameters
18845    /// which have their own setter method. If done anyway, the request will fail.
18846    ///
18847    /// # Additional Parameters
18848    ///
18849    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18850    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18851    /// * *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.
18852    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18853    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18854    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18855    /// * *alt* (query-string) - Data format for the response.
18856    pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceActionCall<'a, C, A>
18857                                                        where T: AsRef<str> {
18858        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
18859        self
18860    }
18861
18862    /// Identifies the authorization scope for the method you are building.
18863    ///
18864    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
18865    /// `Scope::DirectoryDeviceChromeo`.
18866    ///
18867    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18868    /// tokens for more than one scope.
18869    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
18870    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
18871    /// function for details).
18872    ///
18873    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18874    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18875    /// sufficient, a read-write scope will do as well.
18876    pub fn add_scope<T, S>(mut self, scope: T) -> ChromeosdeviceActionCall<'a, C, A>
18877                                                        where T: Into<Option<S>>,
18878                                                              S: AsRef<str> {
18879        match scope.into() {
18880          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
18881          None => None,
18882        };
18883        self
18884    }
18885}
18886
18887
18888/// Move or insert multiple Chrome OS Devices to organizational unit
18889///
18890/// A builder for the *moveDevicesToOu* method supported by a *chromeosdevice* resource.
18891/// It is not used directly, but through a `ChromeosdeviceMethods` instance.
18892///
18893/// # Example
18894///
18895/// Instantiate a resource method builder
18896///
18897/// ```test_harness,no_run
18898/// # extern crate hyper;
18899/// # extern crate hyper_rustls;
18900/// # extern crate yup_oauth2 as oauth2;
18901/// # extern crate google_admin1_directory as admin1_directory;
18902/// use admin1_directory::ChromeOsMoveDevicesToOu;
18903/// # #[test] fn egal() {
18904/// # use std::default::Default;
18905/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
18906/// # use admin1_directory::Directory;
18907/// 
18908/// # let secret: ApplicationSecret = Default::default();
18909/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
18910/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
18911/// #                               <MemoryStorage as Default>::default(), None);
18912/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
18913/// // As the method needs a request, you would usually fill it with the desired information
18914/// // into the respective structure. Some of the parts shown here might not be applicable !
18915/// // Values shown here are possibly random and not representative !
18916/// let mut req = ChromeOsMoveDevicesToOu::default();
18917/// 
18918/// // You can configure optional parameters by calling the respective setters at will, and
18919/// // execute the final call using `doit()`.
18920/// // Values shown here are possibly random and not representative !
18921/// let result = hub.chromeosdevices().move_devices_to_ou(req, "customerId", "orgUnitPath")
18922///              .doit();
18923/// # }
18924/// ```
18925pub struct ChromeosdeviceMoveDevicesToOuCall<'a, C, A>
18926    where C: 'a, A: 'a {
18927
18928    hub: &'a Directory<C, A>,
18929    _request: ChromeOsMoveDevicesToOu,
18930    _customer_id: String,
18931    _org_unit_path: String,
18932    _delegate: Option<&'a mut dyn Delegate>,
18933    _additional_params: HashMap<String, String>,
18934    _scopes: BTreeMap<String, ()>
18935}
18936
18937impl<'a, C, A> CallBuilder for ChromeosdeviceMoveDevicesToOuCall<'a, C, A> {}
18938
18939impl<'a, C, A> ChromeosdeviceMoveDevicesToOuCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
18940
18941
18942    /// Perform the operation you have build so far.
18943    pub fn doit(mut self) -> Result<hyper::client::Response> {
18944        use std::io::{Read, Seek};
18945        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
18946        let mut dd = DefaultDelegate;
18947        let mut dlg: &mut dyn Delegate = match self._delegate {
18948            Some(d) => d,
18949            None => &mut dd
18950        };
18951        dlg.begin(MethodInfo { id: "directory.chromeosdevices.moveDevicesToOu",
18952                               http_method: hyper::method::Method::Post });
18953        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
18954        params.push(("customerId", self._customer_id.to_string()));
18955        params.push(("orgUnitPath", self._org_unit_path.to_string()));
18956        for &field in ["customerId", "orgUnitPath"].iter() {
18957            if self._additional_params.contains_key(field) {
18958                dlg.finished(false);
18959                return Err(Error::FieldClash(field));
18960            }
18961        }
18962        for (name, value) in self._additional_params.iter() {
18963            params.push((&name, value.clone()));
18964        }
18965
18966
18967        let mut url = self.hub._base_url.clone() + "customer/{customerId}/devices/chromeos/moveDevicesToOu";
18968        if self._scopes.len() == 0 {
18969            self._scopes.insert(Scope::DirectoryDeviceChromeo.as_ref().to_string(), ());
18970        }
18971
18972        for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
18973            let mut replace_with: Option<&str> = None;
18974            for &(name, ref value) in params.iter() {
18975                if name == param_name {
18976                    replace_with = Some(value);
18977                    break;
18978                }
18979            }
18980            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
18981        }
18982        {
18983            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
18984            for param_name in ["customerId"].iter() {
18985                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
18986                    indices_for_removal.push(index);
18987                }
18988            }
18989            for &index in indices_for_removal.iter() {
18990                params.remove(index);
18991            }
18992        }
18993
18994        let url = hyper::Url::parse_with_params(&url, params).unwrap();
18995
18996        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
18997        let mut request_value_reader =
18998            {
18999                let mut value = json::value::to_value(&self._request).expect("serde to work");
19000                remove_json_null_values(&mut value);
19001                let mut dst = io::Cursor::new(Vec::with_capacity(128));
19002                json::to_writer(&mut dst, &value).unwrap();
19003                dst
19004            };
19005        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
19006        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
19007
19008
19009        loop {
19010            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
19011                Ok(token) => token,
19012                Err(err) => {
19013                    match  dlg.token(&*err) {
19014                        Some(token) => token,
19015                        None => {
19016                            dlg.finished(false);
19017                            return Err(Error::MissingToken(err))
19018                        }
19019                    }
19020                }
19021            };
19022            let auth_header = Authorization(Bearer { token: token.access_token });
19023            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
19024            let mut req_result = {
19025                let mut client = &mut *self.hub.client.borrow_mut();
19026                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
19027                    .header(UserAgent(self.hub._user_agent.clone()))
19028                    .header(auth_header.clone())
19029                    .header(ContentType(json_mime_type.clone()))
19030                    .header(ContentLength(request_size as u64))
19031                    .body(&mut request_value_reader);
19032
19033                dlg.pre_request();
19034                req.send()
19035            };
19036
19037            match req_result {
19038                Err(err) => {
19039                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
19040                        sleep(d);
19041                        continue;
19042                    }
19043                    dlg.finished(false);
19044                    return Err(Error::HttpError(err))
19045                }
19046                Ok(mut res) => {
19047                    if !res.status.is_success() {
19048                        let mut json_err = String::new();
19049                        res.read_to_string(&mut json_err).unwrap();
19050                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
19051                                                              json::from_str(&json_err).ok(),
19052                                                              json::from_str(&json_err).ok()) {
19053                            sleep(d);
19054                            continue;
19055                        }
19056                        dlg.finished(false);
19057                        return match json::from_str::<ErrorResponse>(&json_err){
19058                            Err(_) => Err(Error::Failure(res)),
19059                            Ok(serr) => Err(Error::BadRequest(serr))
19060                        }
19061                    }
19062                    let result_value = res;
19063
19064                    dlg.finished(true);
19065                    return Ok(result_value)
19066                }
19067            }
19068        }
19069    }
19070
19071
19072    ///
19073    /// Sets the *request* property to the given value.
19074    ///
19075    /// Even though the property as already been set when instantiating this call,
19076    /// we provide this method for API completeness.
19077    pub fn request(mut self, new_value: ChromeOsMoveDevicesToOu) -> ChromeosdeviceMoveDevicesToOuCall<'a, C, A> {
19078        self._request = new_value;
19079        self
19080    }
19081    /// Immutable ID of the G Suite account
19082    ///
19083    /// Sets the *customer id* path property to the given value.
19084    ///
19085    /// Even though the property as already been set when instantiating this call,
19086    /// we provide this method for API completeness.
19087    pub fn customer_id(mut self, new_value: &str) -> ChromeosdeviceMoveDevicesToOuCall<'a, C, A> {
19088        self._customer_id = new_value.to_string();
19089        self
19090    }
19091    /// Full path of the target organizational unit or its ID
19092    ///
19093    /// Sets the *org unit path* query property to the given value.
19094    ///
19095    /// Even though the property as already been set when instantiating this call,
19096    /// we provide this method for API completeness.
19097    pub fn org_unit_path(mut self, new_value: &str) -> ChromeosdeviceMoveDevicesToOuCall<'a, C, A> {
19098        self._org_unit_path = new_value.to_string();
19099        self
19100    }
19101    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19102    /// while executing the actual API request.
19103    /// 
19104    /// It should be used to handle progress information, and to implement a certain level of resilience.
19105    ///
19106    /// Sets the *delegate* property to the given value.
19107    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ChromeosdeviceMoveDevicesToOuCall<'a, C, A> {
19108        self._delegate = Some(new_value);
19109        self
19110    }
19111
19112    /// Set any additional parameter of the query string used in the request.
19113    /// It should be used to set parameters which are not yet available through their own
19114    /// setters.
19115    ///
19116    /// Please note that this method must not be used to set any of the known parameters
19117    /// which have their own setter method. If done anyway, the request will fail.
19118    ///
19119    /// # Additional Parameters
19120    ///
19121    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19122    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19123    /// * *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.
19124    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19125    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19126    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19127    /// * *alt* (query-string) - Data format for the response.
19128    pub fn param<T>(mut self, name: T, value: T) -> ChromeosdeviceMoveDevicesToOuCall<'a, C, A>
19129                                                        where T: AsRef<str> {
19130        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
19131        self
19132    }
19133
19134    /// Identifies the authorization scope for the method you are building.
19135    ///
19136    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
19137    /// `Scope::DirectoryDeviceChromeo`.
19138    ///
19139    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19140    /// tokens for more than one scope.
19141    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
19142    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
19143    /// function for details).
19144    ///
19145    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19146    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19147    /// sufficient, a read-write scope will do as well.
19148    pub fn add_scope<T, S>(mut self, scope: T) -> ChromeosdeviceMoveDevicesToOuCall<'a, C, A>
19149                                                        where T: Into<Option<S>>,
19150                                                              S: AsRef<str> {
19151        match scope.into() {
19152          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
19153          None => None,
19154        };
19155        self
19156    }
19157}
19158
19159
19160/// Checks whether the given user is a member of the group. Membership can be direct or nested.
19161///
19162/// A builder for the *hasMember* method supported by a *member* resource.
19163/// It is not used directly, but through a `MemberMethods` instance.
19164///
19165/// # Example
19166///
19167/// Instantiate a resource method builder
19168///
19169/// ```test_harness,no_run
19170/// # extern crate hyper;
19171/// # extern crate hyper_rustls;
19172/// # extern crate yup_oauth2 as oauth2;
19173/// # extern crate google_admin1_directory as admin1_directory;
19174/// # #[test] fn egal() {
19175/// # use std::default::Default;
19176/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
19177/// # use admin1_directory::Directory;
19178/// 
19179/// # let secret: ApplicationSecret = Default::default();
19180/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
19181/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
19182/// #                               <MemoryStorage as Default>::default(), None);
19183/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
19184/// // You can configure optional parameters by calling the respective setters at will, and
19185/// // execute the final call using `doit()`.
19186/// // Values shown here are possibly random and not representative !
19187/// let result = hub.members().has_member("groupKey", "memberKey")
19188///              .doit();
19189/// # }
19190/// ```
19191pub struct MemberHasMemberCall<'a, C, A>
19192    where C: 'a, A: 'a {
19193
19194    hub: &'a Directory<C, A>,
19195    _group_key: String,
19196    _member_key: String,
19197    _delegate: Option<&'a mut dyn Delegate>,
19198    _additional_params: HashMap<String, String>,
19199    _scopes: BTreeMap<String, ()>
19200}
19201
19202impl<'a, C, A> CallBuilder for MemberHasMemberCall<'a, C, A> {}
19203
19204impl<'a, C, A> MemberHasMemberCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
19205
19206
19207    /// Perform the operation you have build so far.
19208    pub fn doit(mut self) -> Result<(hyper::client::Response, MembersHasMember)> {
19209        use std::io::{Read, Seek};
19210        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
19211        let mut dd = DefaultDelegate;
19212        let mut dlg: &mut dyn Delegate = match self._delegate {
19213            Some(d) => d,
19214            None => &mut dd
19215        };
19216        dlg.begin(MethodInfo { id: "directory.members.hasMember",
19217                               http_method: hyper::method::Method::Get });
19218        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
19219        params.push(("groupKey", self._group_key.to_string()));
19220        params.push(("memberKey", self._member_key.to_string()));
19221        for &field in ["alt", "groupKey", "memberKey"].iter() {
19222            if self._additional_params.contains_key(field) {
19223                dlg.finished(false);
19224                return Err(Error::FieldClash(field));
19225            }
19226        }
19227        for (name, value) in self._additional_params.iter() {
19228            params.push((&name, value.clone()));
19229        }
19230
19231        params.push(("alt", "json".to_string()));
19232
19233        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/hasMember/{memberKey}";
19234        if self._scopes.len() == 0 {
19235            self._scopes.insert(Scope::DirectoryGroupMemberReadonly.as_ref().to_string(), ());
19236        }
19237
19238        for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
19239            let mut replace_with: Option<&str> = None;
19240            for &(name, ref value) in params.iter() {
19241                if name == param_name {
19242                    replace_with = Some(value);
19243                    break;
19244                }
19245            }
19246            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
19247        }
19248        {
19249            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
19250            for param_name in ["memberKey", "groupKey"].iter() {
19251                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
19252                    indices_for_removal.push(index);
19253                }
19254            }
19255            for &index in indices_for_removal.iter() {
19256                params.remove(index);
19257            }
19258        }
19259
19260        let url = hyper::Url::parse_with_params(&url, params).unwrap();
19261
19262
19263
19264        loop {
19265            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
19266                Ok(token) => token,
19267                Err(err) => {
19268                    match  dlg.token(&*err) {
19269                        Some(token) => token,
19270                        None => {
19271                            dlg.finished(false);
19272                            return Err(Error::MissingToken(err))
19273                        }
19274                    }
19275                }
19276            };
19277            let auth_header = Authorization(Bearer { token: token.access_token });
19278            let mut req_result = {
19279                let mut client = &mut *self.hub.client.borrow_mut();
19280                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
19281                    .header(UserAgent(self.hub._user_agent.clone()))
19282                    .header(auth_header.clone());
19283
19284                dlg.pre_request();
19285                req.send()
19286            };
19287
19288            match req_result {
19289                Err(err) => {
19290                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
19291                        sleep(d);
19292                        continue;
19293                    }
19294                    dlg.finished(false);
19295                    return Err(Error::HttpError(err))
19296                }
19297                Ok(mut res) => {
19298                    if !res.status.is_success() {
19299                        let mut json_err = String::new();
19300                        res.read_to_string(&mut json_err).unwrap();
19301                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
19302                                                              json::from_str(&json_err).ok(),
19303                                                              json::from_str(&json_err).ok()) {
19304                            sleep(d);
19305                            continue;
19306                        }
19307                        dlg.finished(false);
19308                        return match json::from_str::<ErrorResponse>(&json_err){
19309                            Err(_) => Err(Error::Failure(res)),
19310                            Ok(serr) => Err(Error::BadRequest(serr))
19311                        }
19312                    }
19313                    let result_value = {
19314                        let mut json_response = String::new();
19315                        res.read_to_string(&mut json_response).unwrap();
19316                        match json::from_str(&json_response) {
19317                            Ok(decoded) => (res, decoded),
19318                            Err(err) => {
19319                                dlg.response_json_decode_error(&json_response, &err);
19320                                return Err(Error::JsonDecodeError(json_response, err));
19321                            }
19322                        }
19323                    };
19324
19325                    dlg.finished(true);
19326                    return Ok(result_value)
19327                }
19328            }
19329        }
19330    }
19331
19332
19333    /// Identifies the group in the API request. The value can be the group's email address, group alias, or the unique group ID.
19334    ///
19335    /// Sets the *group key* path property to the given value.
19336    ///
19337    /// Even though the property as already been set when instantiating this call,
19338    /// we provide this method for API completeness.
19339    pub fn group_key(mut self, new_value: &str) -> MemberHasMemberCall<'a, C, A> {
19340        self._group_key = new_value.to_string();
19341        self
19342    }
19343    /// Identifies the user member in the API request. The value can be the user's primary email address, alias, or unique ID.
19344    ///
19345    /// Sets the *member key* path property to the given value.
19346    ///
19347    /// Even though the property as already been set when instantiating this call,
19348    /// we provide this method for API completeness.
19349    pub fn member_key(mut self, new_value: &str) -> MemberHasMemberCall<'a, C, A> {
19350        self._member_key = new_value.to_string();
19351        self
19352    }
19353    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19354    /// while executing the actual API request.
19355    /// 
19356    /// It should be used to handle progress information, and to implement a certain level of resilience.
19357    ///
19358    /// Sets the *delegate* property to the given value.
19359    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MemberHasMemberCall<'a, C, A> {
19360        self._delegate = Some(new_value);
19361        self
19362    }
19363
19364    /// Set any additional parameter of the query string used in the request.
19365    /// It should be used to set parameters which are not yet available through their own
19366    /// setters.
19367    ///
19368    /// Please note that this method must not be used to set any of the known parameters
19369    /// which have their own setter method. If done anyway, the request will fail.
19370    ///
19371    /// # Additional Parameters
19372    ///
19373    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19374    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19375    /// * *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.
19376    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19377    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19378    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19379    /// * *alt* (query-string) - Data format for the response.
19380    pub fn param<T>(mut self, name: T, value: T) -> MemberHasMemberCall<'a, C, A>
19381                                                        where T: AsRef<str> {
19382        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
19383        self
19384    }
19385
19386    /// Identifies the authorization scope for the method you are building.
19387    ///
19388    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
19389    /// `Scope::DirectoryGroupMemberReadonly`.
19390    ///
19391    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19392    /// tokens for more than one scope.
19393    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
19394    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
19395    /// function for details).
19396    ///
19397    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19398    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19399    /// sufficient, a read-write scope will do as well.
19400    pub fn add_scope<T, S>(mut self, scope: T) -> MemberHasMemberCall<'a, C, A>
19401                                                        where T: Into<Option<S>>,
19402                                                              S: AsRef<str> {
19403        match scope.into() {
19404          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
19405          None => None,
19406        };
19407        self
19408    }
19409}
19410
19411
19412/// Add user to the specified group.
19413///
19414/// A builder for the *insert* method supported by a *member* resource.
19415/// It is not used directly, but through a `MemberMethods` instance.
19416///
19417/// # Example
19418///
19419/// Instantiate a resource method builder
19420///
19421/// ```test_harness,no_run
19422/// # extern crate hyper;
19423/// # extern crate hyper_rustls;
19424/// # extern crate yup_oauth2 as oauth2;
19425/// # extern crate google_admin1_directory as admin1_directory;
19426/// use admin1_directory::Member;
19427/// # #[test] fn egal() {
19428/// # use std::default::Default;
19429/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
19430/// # use admin1_directory::Directory;
19431/// 
19432/// # let secret: ApplicationSecret = Default::default();
19433/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
19434/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
19435/// #                               <MemoryStorage as Default>::default(), None);
19436/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
19437/// // As the method needs a request, you would usually fill it with the desired information
19438/// // into the respective structure. Some of the parts shown here might not be applicable !
19439/// // Values shown here are possibly random and not representative !
19440/// let mut req = Member::default();
19441/// 
19442/// // You can configure optional parameters by calling the respective setters at will, and
19443/// // execute the final call using `doit()`.
19444/// // Values shown here are possibly random and not representative !
19445/// let result = hub.members().insert(req, "groupKey")
19446///              .doit();
19447/// # }
19448/// ```
19449pub struct MemberInsertCall<'a, C, A>
19450    where C: 'a, A: 'a {
19451
19452    hub: &'a Directory<C, A>,
19453    _request: Member,
19454    _group_key: String,
19455    _delegate: Option<&'a mut dyn Delegate>,
19456    _additional_params: HashMap<String, String>,
19457    _scopes: BTreeMap<String, ()>
19458}
19459
19460impl<'a, C, A> CallBuilder for MemberInsertCall<'a, C, A> {}
19461
19462impl<'a, C, A> MemberInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
19463
19464
19465    /// Perform the operation you have build so far.
19466    pub fn doit(mut self) -> Result<(hyper::client::Response, Member)> {
19467        use std::io::{Read, Seek};
19468        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
19469        let mut dd = DefaultDelegate;
19470        let mut dlg: &mut dyn Delegate = match self._delegate {
19471            Some(d) => d,
19472            None => &mut dd
19473        };
19474        dlg.begin(MethodInfo { id: "directory.members.insert",
19475                               http_method: hyper::method::Method::Post });
19476        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
19477        params.push(("groupKey", self._group_key.to_string()));
19478        for &field in ["alt", "groupKey"].iter() {
19479            if self._additional_params.contains_key(field) {
19480                dlg.finished(false);
19481                return Err(Error::FieldClash(field));
19482            }
19483        }
19484        for (name, value) in self._additional_params.iter() {
19485            params.push((&name, value.clone()));
19486        }
19487
19488        params.push(("alt", "json".to_string()));
19489
19490        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/members";
19491        if self._scopes.len() == 0 {
19492            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
19493        }
19494
19495        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
19496            let mut replace_with: Option<&str> = None;
19497            for &(name, ref value) in params.iter() {
19498                if name == param_name {
19499                    replace_with = Some(value);
19500                    break;
19501                }
19502            }
19503            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
19504        }
19505        {
19506            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
19507            for param_name in ["groupKey"].iter() {
19508                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
19509                    indices_for_removal.push(index);
19510                }
19511            }
19512            for &index in indices_for_removal.iter() {
19513                params.remove(index);
19514            }
19515        }
19516
19517        let url = hyper::Url::parse_with_params(&url, params).unwrap();
19518
19519        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
19520        let mut request_value_reader =
19521            {
19522                let mut value = json::value::to_value(&self._request).expect("serde to work");
19523                remove_json_null_values(&mut value);
19524                let mut dst = io::Cursor::new(Vec::with_capacity(128));
19525                json::to_writer(&mut dst, &value).unwrap();
19526                dst
19527            };
19528        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
19529        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
19530
19531
19532        loop {
19533            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
19534                Ok(token) => token,
19535                Err(err) => {
19536                    match  dlg.token(&*err) {
19537                        Some(token) => token,
19538                        None => {
19539                            dlg.finished(false);
19540                            return Err(Error::MissingToken(err))
19541                        }
19542                    }
19543                }
19544            };
19545            let auth_header = Authorization(Bearer { token: token.access_token });
19546            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
19547            let mut req_result = {
19548                let mut client = &mut *self.hub.client.borrow_mut();
19549                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
19550                    .header(UserAgent(self.hub._user_agent.clone()))
19551                    .header(auth_header.clone())
19552                    .header(ContentType(json_mime_type.clone()))
19553                    .header(ContentLength(request_size as u64))
19554                    .body(&mut request_value_reader);
19555
19556                dlg.pre_request();
19557                req.send()
19558            };
19559
19560            match req_result {
19561                Err(err) => {
19562                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
19563                        sleep(d);
19564                        continue;
19565                    }
19566                    dlg.finished(false);
19567                    return Err(Error::HttpError(err))
19568                }
19569                Ok(mut res) => {
19570                    if !res.status.is_success() {
19571                        let mut json_err = String::new();
19572                        res.read_to_string(&mut json_err).unwrap();
19573                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
19574                                                              json::from_str(&json_err).ok(),
19575                                                              json::from_str(&json_err).ok()) {
19576                            sleep(d);
19577                            continue;
19578                        }
19579                        dlg.finished(false);
19580                        return match json::from_str::<ErrorResponse>(&json_err){
19581                            Err(_) => Err(Error::Failure(res)),
19582                            Ok(serr) => Err(Error::BadRequest(serr))
19583                        }
19584                    }
19585                    let result_value = {
19586                        let mut json_response = String::new();
19587                        res.read_to_string(&mut json_response).unwrap();
19588                        match json::from_str(&json_response) {
19589                            Ok(decoded) => (res, decoded),
19590                            Err(err) => {
19591                                dlg.response_json_decode_error(&json_response, &err);
19592                                return Err(Error::JsonDecodeError(json_response, err));
19593                            }
19594                        }
19595                    };
19596
19597                    dlg.finished(true);
19598                    return Ok(result_value)
19599                }
19600            }
19601        }
19602    }
19603
19604
19605    ///
19606    /// Sets the *request* property to the given value.
19607    ///
19608    /// Even though the property as already been set when instantiating this call,
19609    /// we provide this method for API completeness.
19610    pub fn request(mut self, new_value: Member) -> MemberInsertCall<'a, C, A> {
19611        self._request = new_value;
19612        self
19613    }
19614    /// Email or immutable ID of the group
19615    ///
19616    /// Sets the *group key* path property to the given value.
19617    ///
19618    /// Even though the property as already been set when instantiating this call,
19619    /// we provide this method for API completeness.
19620    pub fn group_key(mut self, new_value: &str) -> MemberInsertCall<'a, C, A> {
19621        self._group_key = new_value.to_string();
19622        self
19623    }
19624    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19625    /// while executing the actual API request.
19626    /// 
19627    /// It should be used to handle progress information, and to implement a certain level of resilience.
19628    ///
19629    /// Sets the *delegate* property to the given value.
19630    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MemberInsertCall<'a, C, A> {
19631        self._delegate = Some(new_value);
19632        self
19633    }
19634
19635    /// Set any additional parameter of the query string used in the request.
19636    /// It should be used to set parameters which are not yet available through their own
19637    /// setters.
19638    ///
19639    /// Please note that this method must not be used to set any of the known parameters
19640    /// which have their own setter method. If done anyway, the request will fail.
19641    ///
19642    /// # Additional Parameters
19643    ///
19644    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19645    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19646    /// * *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.
19647    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19648    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19649    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19650    /// * *alt* (query-string) - Data format for the response.
19651    pub fn param<T>(mut self, name: T, value: T) -> MemberInsertCall<'a, C, A>
19652                                                        where T: AsRef<str> {
19653        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
19654        self
19655    }
19656
19657    /// Identifies the authorization scope for the method you are building.
19658    ///
19659    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
19660    /// `Scope::DirectoryGroup`.
19661    ///
19662    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19663    /// tokens for more than one scope.
19664    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
19665    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
19666    /// function for details).
19667    ///
19668    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19669    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19670    /// sufficient, a read-write scope will do as well.
19671    pub fn add_scope<T, S>(mut self, scope: T) -> MemberInsertCall<'a, C, A>
19672                                                        where T: Into<Option<S>>,
19673                                                              S: AsRef<str> {
19674        match scope.into() {
19675          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
19676          None => None,
19677        };
19678        self
19679    }
19680}
19681
19682
19683/// Update membership of a user in the specified group. This method supports patch semantics.
19684///
19685/// A builder for the *patch* method supported by a *member* resource.
19686/// It is not used directly, but through a `MemberMethods` instance.
19687///
19688/// # Example
19689///
19690/// Instantiate a resource method builder
19691///
19692/// ```test_harness,no_run
19693/// # extern crate hyper;
19694/// # extern crate hyper_rustls;
19695/// # extern crate yup_oauth2 as oauth2;
19696/// # extern crate google_admin1_directory as admin1_directory;
19697/// use admin1_directory::Member;
19698/// # #[test] fn egal() {
19699/// # use std::default::Default;
19700/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
19701/// # use admin1_directory::Directory;
19702/// 
19703/// # let secret: ApplicationSecret = Default::default();
19704/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
19705/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
19706/// #                               <MemoryStorage as Default>::default(), None);
19707/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
19708/// // As the method needs a request, you would usually fill it with the desired information
19709/// // into the respective structure. Some of the parts shown here might not be applicable !
19710/// // Values shown here are possibly random and not representative !
19711/// let mut req = Member::default();
19712/// 
19713/// // You can configure optional parameters by calling the respective setters at will, and
19714/// // execute the final call using `doit()`.
19715/// // Values shown here are possibly random and not representative !
19716/// let result = hub.members().patch(req, "groupKey", "memberKey")
19717///              .doit();
19718/// # }
19719/// ```
19720pub struct MemberPatchCall<'a, C, A>
19721    where C: 'a, A: 'a {
19722
19723    hub: &'a Directory<C, A>,
19724    _request: Member,
19725    _group_key: String,
19726    _member_key: String,
19727    _delegate: Option<&'a mut dyn Delegate>,
19728    _additional_params: HashMap<String, String>,
19729    _scopes: BTreeMap<String, ()>
19730}
19731
19732impl<'a, C, A> CallBuilder for MemberPatchCall<'a, C, A> {}
19733
19734impl<'a, C, A> MemberPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
19735
19736
19737    /// Perform the operation you have build so far.
19738    pub fn doit(mut self) -> Result<(hyper::client::Response, Member)> {
19739        use std::io::{Read, Seek};
19740        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
19741        let mut dd = DefaultDelegate;
19742        let mut dlg: &mut dyn Delegate = match self._delegate {
19743            Some(d) => d,
19744            None => &mut dd
19745        };
19746        dlg.begin(MethodInfo { id: "directory.members.patch",
19747                               http_method: hyper::method::Method::Patch });
19748        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
19749        params.push(("groupKey", self._group_key.to_string()));
19750        params.push(("memberKey", self._member_key.to_string()));
19751        for &field in ["alt", "groupKey", "memberKey"].iter() {
19752            if self._additional_params.contains_key(field) {
19753                dlg.finished(false);
19754                return Err(Error::FieldClash(field));
19755            }
19756        }
19757        for (name, value) in self._additional_params.iter() {
19758            params.push((&name, value.clone()));
19759        }
19760
19761        params.push(("alt", "json".to_string()));
19762
19763        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/members/{memberKey}";
19764        if self._scopes.len() == 0 {
19765            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
19766        }
19767
19768        for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
19769            let mut replace_with: Option<&str> = None;
19770            for &(name, ref value) in params.iter() {
19771                if name == param_name {
19772                    replace_with = Some(value);
19773                    break;
19774                }
19775            }
19776            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
19777        }
19778        {
19779            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
19780            for param_name in ["memberKey", "groupKey"].iter() {
19781                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
19782                    indices_for_removal.push(index);
19783                }
19784            }
19785            for &index in indices_for_removal.iter() {
19786                params.remove(index);
19787            }
19788        }
19789
19790        let url = hyper::Url::parse_with_params(&url, params).unwrap();
19791
19792        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
19793        let mut request_value_reader =
19794            {
19795                let mut value = json::value::to_value(&self._request).expect("serde to work");
19796                remove_json_null_values(&mut value);
19797                let mut dst = io::Cursor::new(Vec::with_capacity(128));
19798                json::to_writer(&mut dst, &value).unwrap();
19799                dst
19800            };
19801        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
19802        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
19803
19804
19805        loop {
19806            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
19807                Ok(token) => token,
19808                Err(err) => {
19809                    match  dlg.token(&*err) {
19810                        Some(token) => token,
19811                        None => {
19812                            dlg.finished(false);
19813                            return Err(Error::MissingToken(err))
19814                        }
19815                    }
19816                }
19817            };
19818            let auth_header = Authorization(Bearer { token: token.access_token });
19819            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
19820            let mut req_result = {
19821                let mut client = &mut *self.hub.client.borrow_mut();
19822                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
19823                    .header(UserAgent(self.hub._user_agent.clone()))
19824                    .header(auth_header.clone())
19825                    .header(ContentType(json_mime_type.clone()))
19826                    .header(ContentLength(request_size as u64))
19827                    .body(&mut request_value_reader);
19828
19829                dlg.pre_request();
19830                req.send()
19831            };
19832
19833            match req_result {
19834                Err(err) => {
19835                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
19836                        sleep(d);
19837                        continue;
19838                    }
19839                    dlg.finished(false);
19840                    return Err(Error::HttpError(err))
19841                }
19842                Ok(mut res) => {
19843                    if !res.status.is_success() {
19844                        let mut json_err = String::new();
19845                        res.read_to_string(&mut json_err).unwrap();
19846                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
19847                                                              json::from_str(&json_err).ok(),
19848                                                              json::from_str(&json_err).ok()) {
19849                            sleep(d);
19850                            continue;
19851                        }
19852                        dlg.finished(false);
19853                        return match json::from_str::<ErrorResponse>(&json_err){
19854                            Err(_) => Err(Error::Failure(res)),
19855                            Ok(serr) => Err(Error::BadRequest(serr))
19856                        }
19857                    }
19858                    let result_value = {
19859                        let mut json_response = String::new();
19860                        res.read_to_string(&mut json_response).unwrap();
19861                        match json::from_str(&json_response) {
19862                            Ok(decoded) => (res, decoded),
19863                            Err(err) => {
19864                                dlg.response_json_decode_error(&json_response, &err);
19865                                return Err(Error::JsonDecodeError(json_response, err));
19866                            }
19867                        }
19868                    };
19869
19870                    dlg.finished(true);
19871                    return Ok(result_value)
19872                }
19873            }
19874        }
19875    }
19876
19877
19878    ///
19879    /// Sets the *request* property to the given value.
19880    ///
19881    /// Even though the property as already been set when instantiating this call,
19882    /// we provide this method for API completeness.
19883    pub fn request(mut self, new_value: Member) -> MemberPatchCall<'a, C, A> {
19884        self._request = new_value;
19885        self
19886    }
19887    /// Email or immutable ID of the group. If ID, it should match with id of group object
19888    ///
19889    /// Sets the *group key* path property to the given value.
19890    ///
19891    /// Even though the property as already been set when instantiating this call,
19892    /// we provide this method for API completeness.
19893    pub fn group_key(mut self, new_value: &str) -> MemberPatchCall<'a, C, A> {
19894        self._group_key = new_value.to_string();
19895        self
19896    }
19897    /// Email or immutable ID of the user. If ID, it should match with id of member object
19898    ///
19899    /// Sets the *member key* path property to the given value.
19900    ///
19901    /// Even though the property as already been set when instantiating this call,
19902    /// we provide this method for API completeness.
19903    pub fn member_key(mut self, new_value: &str) -> MemberPatchCall<'a, C, A> {
19904        self._member_key = new_value.to_string();
19905        self
19906    }
19907    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19908    /// while executing the actual API request.
19909    /// 
19910    /// It should be used to handle progress information, and to implement a certain level of resilience.
19911    ///
19912    /// Sets the *delegate* property to the given value.
19913    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MemberPatchCall<'a, C, A> {
19914        self._delegate = Some(new_value);
19915        self
19916    }
19917
19918    /// Set any additional parameter of the query string used in the request.
19919    /// It should be used to set parameters which are not yet available through their own
19920    /// setters.
19921    ///
19922    /// Please note that this method must not be used to set any of the known parameters
19923    /// which have their own setter method. If done anyway, the request will fail.
19924    ///
19925    /// # Additional Parameters
19926    ///
19927    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19928    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19929    /// * *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.
19930    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19931    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19932    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19933    /// * *alt* (query-string) - Data format for the response.
19934    pub fn param<T>(mut self, name: T, value: T) -> MemberPatchCall<'a, C, A>
19935                                                        where T: AsRef<str> {
19936        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
19937        self
19938    }
19939
19940    /// Identifies the authorization scope for the method you are building.
19941    ///
19942    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
19943    /// `Scope::DirectoryGroup`.
19944    ///
19945    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19946    /// tokens for more than one scope.
19947    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
19948    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
19949    /// function for details).
19950    ///
19951    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19952    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19953    /// sufficient, a read-write scope will do as well.
19954    pub fn add_scope<T, S>(mut self, scope: T) -> MemberPatchCall<'a, C, A>
19955                                                        where T: Into<Option<S>>,
19956                                                              S: AsRef<str> {
19957        match scope.into() {
19958          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
19959          None => None,
19960        };
19961        self
19962    }
19963}
19964
19965
19966/// Update membership of a user in the specified group.
19967///
19968/// A builder for the *update* method supported by a *member* resource.
19969/// It is not used directly, but through a `MemberMethods` instance.
19970///
19971/// # Example
19972///
19973/// Instantiate a resource method builder
19974///
19975/// ```test_harness,no_run
19976/// # extern crate hyper;
19977/// # extern crate hyper_rustls;
19978/// # extern crate yup_oauth2 as oauth2;
19979/// # extern crate google_admin1_directory as admin1_directory;
19980/// use admin1_directory::Member;
19981/// # #[test] fn egal() {
19982/// # use std::default::Default;
19983/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
19984/// # use admin1_directory::Directory;
19985/// 
19986/// # let secret: ApplicationSecret = Default::default();
19987/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
19988/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
19989/// #                               <MemoryStorage as Default>::default(), None);
19990/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
19991/// // As the method needs a request, you would usually fill it with the desired information
19992/// // into the respective structure. Some of the parts shown here might not be applicable !
19993/// // Values shown here are possibly random and not representative !
19994/// let mut req = Member::default();
19995/// 
19996/// // You can configure optional parameters by calling the respective setters at will, and
19997/// // execute the final call using `doit()`.
19998/// // Values shown here are possibly random and not representative !
19999/// let result = hub.members().update(req, "groupKey", "memberKey")
20000///              .doit();
20001/// # }
20002/// ```
20003pub struct MemberUpdateCall<'a, C, A>
20004    where C: 'a, A: 'a {
20005
20006    hub: &'a Directory<C, A>,
20007    _request: Member,
20008    _group_key: String,
20009    _member_key: String,
20010    _delegate: Option<&'a mut dyn Delegate>,
20011    _additional_params: HashMap<String, String>,
20012    _scopes: BTreeMap<String, ()>
20013}
20014
20015impl<'a, C, A> CallBuilder for MemberUpdateCall<'a, C, A> {}
20016
20017impl<'a, C, A> MemberUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
20018
20019
20020    /// Perform the operation you have build so far.
20021    pub fn doit(mut self) -> Result<(hyper::client::Response, Member)> {
20022        use std::io::{Read, Seek};
20023        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
20024        let mut dd = DefaultDelegate;
20025        let mut dlg: &mut dyn Delegate = match self._delegate {
20026            Some(d) => d,
20027            None => &mut dd
20028        };
20029        dlg.begin(MethodInfo { id: "directory.members.update",
20030                               http_method: hyper::method::Method::Put });
20031        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
20032        params.push(("groupKey", self._group_key.to_string()));
20033        params.push(("memberKey", self._member_key.to_string()));
20034        for &field in ["alt", "groupKey", "memberKey"].iter() {
20035            if self._additional_params.contains_key(field) {
20036                dlg.finished(false);
20037                return Err(Error::FieldClash(field));
20038            }
20039        }
20040        for (name, value) in self._additional_params.iter() {
20041            params.push((&name, value.clone()));
20042        }
20043
20044        params.push(("alt", "json".to_string()));
20045
20046        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/members/{memberKey}";
20047        if self._scopes.len() == 0 {
20048            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
20049        }
20050
20051        for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
20052            let mut replace_with: Option<&str> = None;
20053            for &(name, ref value) in params.iter() {
20054                if name == param_name {
20055                    replace_with = Some(value);
20056                    break;
20057                }
20058            }
20059            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
20060        }
20061        {
20062            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
20063            for param_name in ["memberKey", "groupKey"].iter() {
20064                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
20065                    indices_for_removal.push(index);
20066                }
20067            }
20068            for &index in indices_for_removal.iter() {
20069                params.remove(index);
20070            }
20071        }
20072
20073        let url = hyper::Url::parse_with_params(&url, params).unwrap();
20074
20075        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
20076        let mut request_value_reader =
20077            {
20078                let mut value = json::value::to_value(&self._request).expect("serde to work");
20079                remove_json_null_values(&mut value);
20080                let mut dst = io::Cursor::new(Vec::with_capacity(128));
20081                json::to_writer(&mut dst, &value).unwrap();
20082                dst
20083            };
20084        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
20085        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
20086
20087
20088        loop {
20089            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
20090                Ok(token) => token,
20091                Err(err) => {
20092                    match  dlg.token(&*err) {
20093                        Some(token) => token,
20094                        None => {
20095                            dlg.finished(false);
20096                            return Err(Error::MissingToken(err))
20097                        }
20098                    }
20099                }
20100            };
20101            let auth_header = Authorization(Bearer { token: token.access_token });
20102            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
20103            let mut req_result = {
20104                let mut client = &mut *self.hub.client.borrow_mut();
20105                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
20106                    .header(UserAgent(self.hub._user_agent.clone()))
20107                    .header(auth_header.clone())
20108                    .header(ContentType(json_mime_type.clone()))
20109                    .header(ContentLength(request_size as u64))
20110                    .body(&mut request_value_reader);
20111
20112                dlg.pre_request();
20113                req.send()
20114            };
20115
20116            match req_result {
20117                Err(err) => {
20118                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
20119                        sleep(d);
20120                        continue;
20121                    }
20122                    dlg.finished(false);
20123                    return Err(Error::HttpError(err))
20124                }
20125                Ok(mut res) => {
20126                    if !res.status.is_success() {
20127                        let mut json_err = String::new();
20128                        res.read_to_string(&mut json_err).unwrap();
20129                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
20130                                                              json::from_str(&json_err).ok(),
20131                                                              json::from_str(&json_err).ok()) {
20132                            sleep(d);
20133                            continue;
20134                        }
20135                        dlg.finished(false);
20136                        return match json::from_str::<ErrorResponse>(&json_err){
20137                            Err(_) => Err(Error::Failure(res)),
20138                            Ok(serr) => Err(Error::BadRequest(serr))
20139                        }
20140                    }
20141                    let result_value = {
20142                        let mut json_response = String::new();
20143                        res.read_to_string(&mut json_response).unwrap();
20144                        match json::from_str(&json_response) {
20145                            Ok(decoded) => (res, decoded),
20146                            Err(err) => {
20147                                dlg.response_json_decode_error(&json_response, &err);
20148                                return Err(Error::JsonDecodeError(json_response, err));
20149                            }
20150                        }
20151                    };
20152
20153                    dlg.finished(true);
20154                    return Ok(result_value)
20155                }
20156            }
20157        }
20158    }
20159
20160
20161    ///
20162    /// Sets the *request* property to the given value.
20163    ///
20164    /// Even though the property as already been set when instantiating this call,
20165    /// we provide this method for API completeness.
20166    pub fn request(mut self, new_value: Member) -> MemberUpdateCall<'a, C, A> {
20167        self._request = new_value;
20168        self
20169    }
20170    /// Email or immutable ID of the group. If ID, it should match with id of group object
20171    ///
20172    /// Sets the *group key* path property to the given value.
20173    ///
20174    /// Even though the property as already been set when instantiating this call,
20175    /// we provide this method for API completeness.
20176    pub fn group_key(mut self, new_value: &str) -> MemberUpdateCall<'a, C, A> {
20177        self._group_key = new_value.to_string();
20178        self
20179    }
20180    /// Email or immutable ID of the user. If ID, it should match with id of member object
20181    ///
20182    /// Sets the *member key* path property to the given value.
20183    ///
20184    /// Even though the property as already been set when instantiating this call,
20185    /// we provide this method for API completeness.
20186    pub fn member_key(mut self, new_value: &str) -> MemberUpdateCall<'a, C, A> {
20187        self._member_key = new_value.to_string();
20188        self
20189    }
20190    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20191    /// while executing the actual API request.
20192    /// 
20193    /// It should be used to handle progress information, and to implement a certain level of resilience.
20194    ///
20195    /// Sets the *delegate* property to the given value.
20196    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MemberUpdateCall<'a, C, A> {
20197        self._delegate = Some(new_value);
20198        self
20199    }
20200
20201    /// Set any additional parameter of the query string used in the request.
20202    /// It should be used to set parameters which are not yet available through their own
20203    /// setters.
20204    ///
20205    /// Please note that this method must not be used to set any of the known parameters
20206    /// which have their own setter method. If done anyway, the request will fail.
20207    ///
20208    /// # Additional Parameters
20209    ///
20210    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20211    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20212    /// * *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.
20213    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20214    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20215    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20216    /// * *alt* (query-string) - Data format for the response.
20217    pub fn param<T>(mut self, name: T, value: T) -> MemberUpdateCall<'a, C, A>
20218                                                        where T: AsRef<str> {
20219        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
20220        self
20221    }
20222
20223    /// Identifies the authorization scope for the method you are building.
20224    ///
20225    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
20226    /// `Scope::DirectoryGroup`.
20227    ///
20228    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20229    /// tokens for more than one scope.
20230    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
20231    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
20232    /// function for details).
20233    ///
20234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20236    /// sufficient, a read-write scope will do as well.
20237    pub fn add_scope<T, S>(mut self, scope: T) -> MemberUpdateCall<'a, C, A>
20238                                                        where T: Into<Option<S>>,
20239                                                              S: AsRef<str> {
20240        match scope.into() {
20241          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
20242          None => None,
20243        };
20244        self
20245    }
20246}
20247
20248
20249/// Retrieve all members in a group (paginated)
20250///
20251/// A builder for the *list* method supported by a *member* resource.
20252/// It is not used directly, but through a `MemberMethods` instance.
20253///
20254/// # Example
20255///
20256/// Instantiate a resource method builder
20257///
20258/// ```test_harness,no_run
20259/// # extern crate hyper;
20260/// # extern crate hyper_rustls;
20261/// # extern crate yup_oauth2 as oauth2;
20262/// # extern crate google_admin1_directory as admin1_directory;
20263/// # #[test] fn egal() {
20264/// # use std::default::Default;
20265/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
20266/// # use admin1_directory::Directory;
20267/// 
20268/// # let secret: ApplicationSecret = Default::default();
20269/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
20270/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
20271/// #                               <MemoryStorage as Default>::default(), None);
20272/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
20273/// // You can configure optional parameters by calling the respective setters at will, and
20274/// // execute the final call using `doit()`.
20275/// // Values shown here are possibly random and not representative !
20276/// let result = hub.members().list("groupKey")
20277///              .roles("sed")
20278///              .page_token("sit")
20279///              .max_results(-8)
20280///              .include_derived_membership(true)
20281///              .doit();
20282/// # }
20283/// ```
20284pub struct MemberListCall<'a, C, A>
20285    where C: 'a, A: 'a {
20286
20287    hub: &'a Directory<C, A>,
20288    _group_key: String,
20289    _roles: Option<String>,
20290    _page_token: Option<String>,
20291    _max_results: Option<i32>,
20292    _include_derived_membership: Option<bool>,
20293    _delegate: Option<&'a mut dyn Delegate>,
20294    _additional_params: HashMap<String, String>,
20295    _scopes: BTreeMap<String, ()>
20296}
20297
20298impl<'a, C, A> CallBuilder for MemberListCall<'a, C, A> {}
20299
20300impl<'a, C, A> MemberListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
20301
20302
20303    /// Perform the operation you have build so far.
20304    pub fn doit(mut self) -> Result<(hyper::client::Response, Members)> {
20305        use std::io::{Read, Seek};
20306        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
20307        let mut dd = DefaultDelegate;
20308        let mut dlg: &mut dyn Delegate = match self._delegate {
20309            Some(d) => d,
20310            None => &mut dd
20311        };
20312        dlg.begin(MethodInfo { id: "directory.members.list",
20313                               http_method: hyper::method::Method::Get });
20314        let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len());
20315        params.push(("groupKey", self._group_key.to_string()));
20316        if let Some(value) = self._roles {
20317            params.push(("roles", value.to_string()));
20318        }
20319        if let Some(value) = self._page_token {
20320            params.push(("pageToken", value.to_string()));
20321        }
20322        if let Some(value) = self._max_results {
20323            params.push(("maxResults", value.to_string()));
20324        }
20325        if let Some(value) = self._include_derived_membership {
20326            params.push(("includeDerivedMembership", value.to_string()));
20327        }
20328        for &field in ["alt", "groupKey", "roles", "pageToken", "maxResults", "includeDerivedMembership"].iter() {
20329            if self._additional_params.contains_key(field) {
20330                dlg.finished(false);
20331                return Err(Error::FieldClash(field));
20332            }
20333        }
20334        for (name, value) in self._additional_params.iter() {
20335            params.push((&name, value.clone()));
20336        }
20337
20338        params.push(("alt", "json".to_string()));
20339
20340        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/members";
20341        if self._scopes.len() == 0 {
20342            self._scopes.insert(Scope::DirectoryGroupMemberReadonly.as_ref().to_string(), ());
20343        }
20344
20345        for &(find_this, param_name) in [("{groupKey}", "groupKey")].iter() {
20346            let mut replace_with: Option<&str> = None;
20347            for &(name, ref value) in params.iter() {
20348                if name == param_name {
20349                    replace_with = Some(value);
20350                    break;
20351                }
20352            }
20353            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
20354        }
20355        {
20356            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
20357            for param_name in ["groupKey"].iter() {
20358                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
20359                    indices_for_removal.push(index);
20360                }
20361            }
20362            for &index in indices_for_removal.iter() {
20363                params.remove(index);
20364            }
20365        }
20366
20367        let url = hyper::Url::parse_with_params(&url, params).unwrap();
20368
20369
20370
20371        loop {
20372            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
20373                Ok(token) => token,
20374                Err(err) => {
20375                    match  dlg.token(&*err) {
20376                        Some(token) => token,
20377                        None => {
20378                            dlg.finished(false);
20379                            return Err(Error::MissingToken(err))
20380                        }
20381                    }
20382                }
20383            };
20384            let auth_header = Authorization(Bearer { token: token.access_token });
20385            let mut req_result = {
20386                let mut client = &mut *self.hub.client.borrow_mut();
20387                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
20388                    .header(UserAgent(self.hub._user_agent.clone()))
20389                    .header(auth_header.clone());
20390
20391                dlg.pre_request();
20392                req.send()
20393            };
20394
20395            match req_result {
20396                Err(err) => {
20397                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
20398                        sleep(d);
20399                        continue;
20400                    }
20401                    dlg.finished(false);
20402                    return Err(Error::HttpError(err))
20403                }
20404                Ok(mut res) => {
20405                    if !res.status.is_success() {
20406                        let mut json_err = String::new();
20407                        res.read_to_string(&mut json_err).unwrap();
20408                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
20409                                                              json::from_str(&json_err).ok(),
20410                                                              json::from_str(&json_err).ok()) {
20411                            sleep(d);
20412                            continue;
20413                        }
20414                        dlg.finished(false);
20415                        return match json::from_str::<ErrorResponse>(&json_err){
20416                            Err(_) => Err(Error::Failure(res)),
20417                            Ok(serr) => Err(Error::BadRequest(serr))
20418                        }
20419                    }
20420                    let result_value = {
20421                        let mut json_response = String::new();
20422                        res.read_to_string(&mut json_response).unwrap();
20423                        match json::from_str(&json_response) {
20424                            Ok(decoded) => (res, decoded),
20425                            Err(err) => {
20426                                dlg.response_json_decode_error(&json_response, &err);
20427                                return Err(Error::JsonDecodeError(json_response, err));
20428                            }
20429                        }
20430                    };
20431
20432                    dlg.finished(true);
20433                    return Ok(result_value)
20434                }
20435            }
20436        }
20437    }
20438
20439
20440    /// Email or immutable ID of the group
20441    ///
20442    /// Sets the *group key* path property to the given value.
20443    ///
20444    /// Even though the property as already been set when instantiating this call,
20445    /// we provide this method for API completeness.
20446    pub fn group_key(mut self, new_value: &str) -> MemberListCall<'a, C, A> {
20447        self._group_key = new_value.to_string();
20448        self
20449    }
20450    /// Comma separated role values to filter list results on.
20451    ///
20452    /// Sets the *roles* query property to the given value.
20453    pub fn roles(mut self, new_value: &str) -> MemberListCall<'a, C, A> {
20454        self._roles = Some(new_value.to_string());
20455        self
20456    }
20457    /// Token to specify next page in the list
20458    ///
20459    /// Sets the *page token* query property to the given value.
20460    pub fn page_token(mut self, new_value: &str) -> MemberListCall<'a, C, A> {
20461        self._page_token = Some(new_value.to_string());
20462        self
20463    }
20464    /// Maximum number of results to return. Max allowed value is 200.
20465    ///
20466    /// Sets the *max results* query property to the given value.
20467    pub fn max_results(mut self, new_value: i32) -> MemberListCall<'a, C, A> {
20468        self._max_results = Some(new_value);
20469        self
20470    }
20471    /// Whether to list indirect memberships. Default: false.
20472    ///
20473    /// Sets the *include derived membership* query property to the given value.
20474    pub fn include_derived_membership(mut self, new_value: bool) -> MemberListCall<'a, C, A> {
20475        self._include_derived_membership = Some(new_value);
20476        self
20477    }
20478    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20479    /// while executing the actual API request.
20480    /// 
20481    /// It should be used to handle progress information, and to implement a certain level of resilience.
20482    ///
20483    /// Sets the *delegate* property to the given value.
20484    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MemberListCall<'a, C, A> {
20485        self._delegate = Some(new_value);
20486        self
20487    }
20488
20489    /// Set any additional parameter of the query string used in the request.
20490    /// It should be used to set parameters which are not yet available through their own
20491    /// setters.
20492    ///
20493    /// Please note that this method must not be used to set any of the known parameters
20494    /// which have their own setter method. If done anyway, the request will fail.
20495    ///
20496    /// # Additional Parameters
20497    ///
20498    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20499    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20500    /// * *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.
20501    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20502    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20503    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20504    /// * *alt* (query-string) - Data format for the response.
20505    pub fn param<T>(mut self, name: T, value: T) -> MemberListCall<'a, C, A>
20506                                                        where T: AsRef<str> {
20507        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
20508        self
20509    }
20510
20511    /// Identifies the authorization scope for the method you are building.
20512    ///
20513    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
20514    /// `Scope::DirectoryGroupMemberReadonly`.
20515    ///
20516    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20517    /// tokens for more than one scope.
20518    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
20519    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
20520    /// function for details).
20521    ///
20522    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20523    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20524    /// sufficient, a read-write scope will do as well.
20525    pub fn add_scope<T, S>(mut self, scope: T) -> MemberListCall<'a, C, A>
20526                                                        where T: Into<Option<S>>,
20527                                                              S: AsRef<str> {
20528        match scope.into() {
20529          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
20530          None => None,
20531        };
20532        self
20533    }
20534}
20535
20536
20537/// Retrieve Group Member
20538///
20539/// A builder for the *get* method supported by a *member* resource.
20540/// It is not used directly, but through a `MemberMethods` instance.
20541///
20542/// # Example
20543///
20544/// Instantiate a resource method builder
20545///
20546/// ```test_harness,no_run
20547/// # extern crate hyper;
20548/// # extern crate hyper_rustls;
20549/// # extern crate yup_oauth2 as oauth2;
20550/// # extern crate google_admin1_directory as admin1_directory;
20551/// # #[test] fn egal() {
20552/// # use std::default::Default;
20553/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
20554/// # use admin1_directory::Directory;
20555/// 
20556/// # let secret: ApplicationSecret = Default::default();
20557/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
20558/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
20559/// #                               <MemoryStorage as Default>::default(), None);
20560/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
20561/// // You can configure optional parameters by calling the respective setters at will, and
20562/// // execute the final call using `doit()`.
20563/// // Values shown here are possibly random and not representative !
20564/// let result = hub.members().get("groupKey", "memberKey")
20565///              .doit();
20566/// # }
20567/// ```
20568pub struct MemberGetCall<'a, C, A>
20569    where C: 'a, A: 'a {
20570
20571    hub: &'a Directory<C, A>,
20572    _group_key: String,
20573    _member_key: String,
20574    _delegate: Option<&'a mut dyn Delegate>,
20575    _additional_params: HashMap<String, String>,
20576    _scopes: BTreeMap<String, ()>
20577}
20578
20579impl<'a, C, A> CallBuilder for MemberGetCall<'a, C, A> {}
20580
20581impl<'a, C, A> MemberGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
20582
20583
20584    /// Perform the operation you have build so far.
20585    pub fn doit(mut self) -> Result<(hyper::client::Response, Member)> {
20586        use std::io::{Read, Seek};
20587        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
20588        let mut dd = DefaultDelegate;
20589        let mut dlg: &mut dyn Delegate = match self._delegate {
20590            Some(d) => d,
20591            None => &mut dd
20592        };
20593        dlg.begin(MethodInfo { id: "directory.members.get",
20594                               http_method: hyper::method::Method::Get });
20595        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
20596        params.push(("groupKey", self._group_key.to_string()));
20597        params.push(("memberKey", self._member_key.to_string()));
20598        for &field in ["alt", "groupKey", "memberKey"].iter() {
20599            if self._additional_params.contains_key(field) {
20600                dlg.finished(false);
20601                return Err(Error::FieldClash(field));
20602            }
20603        }
20604        for (name, value) in self._additional_params.iter() {
20605            params.push((&name, value.clone()));
20606        }
20607
20608        params.push(("alt", "json".to_string()));
20609
20610        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/members/{memberKey}";
20611        if self._scopes.len() == 0 {
20612            self._scopes.insert(Scope::DirectoryGroupMemberReadonly.as_ref().to_string(), ());
20613        }
20614
20615        for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
20616            let mut replace_with: Option<&str> = None;
20617            for &(name, ref value) in params.iter() {
20618                if name == param_name {
20619                    replace_with = Some(value);
20620                    break;
20621                }
20622            }
20623            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
20624        }
20625        {
20626            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
20627            for param_name in ["memberKey", "groupKey"].iter() {
20628                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
20629                    indices_for_removal.push(index);
20630                }
20631            }
20632            for &index in indices_for_removal.iter() {
20633                params.remove(index);
20634            }
20635        }
20636
20637        let url = hyper::Url::parse_with_params(&url, params).unwrap();
20638
20639
20640
20641        loop {
20642            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
20643                Ok(token) => token,
20644                Err(err) => {
20645                    match  dlg.token(&*err) {
20646                        Some(token) => token,
20647                        None => {
20648                            dlg.finished(false);
20649                            return Err(Error::MissingToken(err))
20650                        }
20651                    }
20652                }
20653            };
20654            let auth_header = Authorization(Bearer { token: token.access_token });
20655            let mut req_result = {
20656                let mut client = &mut *self.hub.client.borrow_mut();
20657                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
20658                    .header(UserAgent(self.hub._user_agent.clone()))
20659                    .header(auth_header.clone());
20660
20661                dlg.pre_request();
20662                req.send()
20663            };
20664
20665            match req_result {
20666                Err(err) => {
20667                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
20668                        sleep(d);
20669                        continue;
20670                    }
20671                    dlg.finished(false);
20672                    return Err(Error::HttpError(err))
20673                }
20674                Ok(mut res) => {
20675                    if !res.status.is_success() {
20676                        let mut json_err = String::new();
20677                        res.read_to_string(&mut json_err).unwrap();
20678                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
20679                                                              json::from_str(&json_err).ok(),
20680                                                              json::from_str(&json_err).ok()) {
20681                            sleep(d);
20682                            continue;
20683                        }
20684                        dlg.finished(false);
20685                        return match json::from_str::<ErrorResponse>(&json_err){
20686                            Err(_) => Err(Error::Failure(res)),
20687                            Ok(serr) => Err(Error::BadRequest(serr))
20688                        }
20689                    }
20690                    let result_value = {
20691                        let mut json_response = String::new();
20692                        res.read_to_string(&mut json_response).unwrap();
20693                        match json::from_str(&json_response) {
20694                            Ok(decoded) => (res, decoded),
20695                            Err(err) => {
20696                                dlg.response_json_decode_error(&json_response, &err);
20697                                return Err(Error::JsonDecodeError(json_response, err));
20698                            }
20699                        }
20700                    };
20701
20702                    dlg.finished(true);
20703                    return Ok(result_value)
20704                }
20705            }
20706        }
20707    }
20708
20709
20710    /// Email or immutable ID of the group
20711    ///
20712    /// Sets the *group key* path property to the given value.
20713    ///
20714    /// Even though the property as already been set when instantiating this call,
20715    /// we provide this method for API completeness.
20716    pub fn group_key(mut self, new_value: &str) -> MemberGetCall<'a, C, A> {
20717        self._group_key = new_value.to_string();
20718        self
20719    }
20720    /// Email or immutable ID of the member
20721    ///
20722    /// Sets the *member key* path property to the given value.
20723    ///
20724    /// Even though the property as already been set when instantiating this call,
20725    /// we provide this method for API completeness.
20726    pub fn member_key(mut self, new_value: &str) -> MemberGetCall<'a, C, A> {
20727        self._member_key = new_value.to_string();
20728        self
20729    }
20730    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20731    /// while executing the actual API request.
20732    /// 
20733    /// It should be used to handle progress information, and to implement a certain level of resilience.
20734    ///
20735    /// Sets the *delegate* property to the given value.
20736    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MemberGetCall<'a, C, A> {
20737        self._delegate = Some(new_value);
20738        self
20739    }
20740
20741    /// Set any additional parameter of the query string used in the request.
20742    /// It should be used to set parameters which are not yet available through their own
20743    /// setters.
20744    ///
20745    /// Please note that this method must not be used to set any of the known parameters
20746    /// which have their own setter method. If done anyway, the request will fail.
20747    ///
20748    /// # Additional Parameters
20749    ///
20750    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20751    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20752    /// * *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.
20753    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20754    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20755    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20756    /// * *alt* (query-string) - Data format for the response.
20757    pub fn param<T>(mut self, name: T, value: T) -> MemberGetCall<'a, C, A>
20758                                                        where T: AsRef<str> {
20759        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
20760        self
20761    }
20762
20763    /// Identifies the authorization scope for the method you are building.
20764    ///
20765    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
20766    /// `Scope::DirectoryGroupMemberReadonly`.
20767    ///
20768    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20769    /// tokens for more than one scope.
20770    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
20771    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
20772    /// function for details).
20773    ///
20774    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20775    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20776    /// sufficient, a read-write scope will do as well.
20777    pub fn add_scope<T, S>(mut self, scope: T) -> MemberGetCall<'a, C, A>
20778                                                        where T: Into<Option<S>>,
20779                                                              S: AsRef<str> {
20780        match scope.into() {
20781          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
20782          None => None,
20783        };
20784        self
20785    }
20786}
20787
20788
20789/// Remove membership.
20790///
20791/// A builder for the *delete* method supported by a *member* resource.
20792/// It is not used directly, but through a `MemberMethods` instance.
20793///
20794/// # Example
20795///
20796/// Instantiate a resource method builder
20797///
20798/// ```test_harness,no_run
20799/// # extern crate hyper;
20800/// # extern crate hyper_rustls;
20801/// # extern crate yup_oauth2 as oauth2;
20802/// # extern crate google_admin1_directory as admin1_directory;
20803/// # #[test] fn egal() {
20804/// # use std::default::Default;
20805/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
20806/// # use admin1_directory::Directory;
20807/// 
20808/// # let secret: ApplicationSecret = Default::default();
20809/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
20810/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
20811/// #                               <MemoryStorage as Default>::default(), None);
20812/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
20813/// // You can configure optional parameters by calling the respective setters at will, and
20814/// // execute the final call using `doit()`.
20815/// // Values shown here are possibly random and not representative !
20816/// let result = hub.members().delete("groupKey", "memberKey")
20817///              .doit();
20818/// # }
20819/// ```
20820pub struct MemberDeleteCall<'a, C, A>
20821    where C: 'a, A: 'a {
20822
20823    hub: &'a Directory<C, A>,
20824    _group_key: String,
20825    _member_key: String,
20826    _delegate: Option<&'a mut dyn Delegate>,
20827    _additional_params: HashMap<String, String>,
20828    _scopes: BTreeMap<String, ()>
20829}
20830
20831impl<'a, C, A> CallBuilder for MemberDeleteCall<'a, C, A> {}
20832
20833impl<'a, C, A> MemberDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
20834
20835
20836    /// Perform the operation you have build so far.
20837    pub fn doit(mut self) -> Result<hyper::client::Response> {
20838        use std::io::{Read, Seek};
20839        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
20840        let mut dd = DefaultDelegate;
20841        let mut dlg: &mut dyn Delegate = match self._delegate {
20842            Some(d) => d,
20843            None => &mut dd
20844        };
20845        dlg.begin(MethodInfo { id: "directory.members.delete",
20846                               http_method: hyper::method::Method::Delete });
20847        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
20848        params.push(("groupKey", self._group_key.to_string()));
20849        params.push(("memberKey", self._member_key.to_string()));
20850        for &field in ["groupKey", "memberKey"].iter() {
20851            if self._additional_params.contains_key(field) {
20852                dlg.finished(false);
20853                return Err(Error::FieldClash(field));
20854            }
20855        }
20856        for (name, value) in self._additional_params.iter() {
20857            params.push((&name, value.clone()));
20858        }
20859
20860
20861        let mut url = self.hub._base_url.clone() + "groups/{groupKey}/members/{memberKey}";
20862        if self._scopes.len() == 0 {
20863            self._scopes.insert(Scope::DirectoryGroup.as_ref().to_string(), ());
20864        }
20865
20866        for &(find_this, param_name) in [("{groupKey}", "groupKey"), ("{memberKey}", "memberKey")].iter() {
20867            let mut replace_with: Option<&str> = None;
20868            for &(name, ref value) in params.iter() {
20869                if name == param_name {
20870                    replace_with = Some(value);
20871                    break;
20872                }
20873            }
20874            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
20875        }
20876        {
20877            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
20878            for param_name in ["memberKey", "groupKey"].iter() {
20879                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
20880                    indices_for_removal.push(index);
20881                }
20882            }
20883            for &index in indices_for_removal.iter() {
20884                params.remove(index);
20885            }
20886        }
20887
20888        let url = hyper::Url::parse_with_params(&url, params).unwrap();
20889
20890
20891
20892        loop {
20893            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
20894                Ok(token) => token,
20895                Err(err) => {
20896                    match  dlg.token(&*err) {
20897                        Some(token) => token,
20898                        None => {
20899                            dlg.finished(false);
20900                            return Err(Error::MissingToken(err))
20901                        }
20902                    }
20903                }
20904            };
20905            let auth_header = Authorization(Bearer { token: token.access_token });
20906            let mut req_result = {
20907                let mut client = &mut *self.hub.client.borrow_mut();
20908                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
20909                    .header(UserAgent(self.hub._user_agent.clone()))
20910                    .header(auth_header.clone());
20911
20912                dlg.pre_request();
20913                req.send()
20914            };
20915
20916            match req_result {
20917                Err(err) => {
20918                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
20919                        sleep(d);
20920                        continue;
20921                    }
20922                    dlg.finished(false);
20923                    return Err(Error::HttpError(err))
20924                }
20925                Ok(mut res) => {
20926                    if !res.status.is_success() {
20927                        let mut json_err = String::new();
20928                        res.read_to_string(&mut json_err).unwrap();
20929                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
20930                                                              json::from_str(&json_err).ok(),
20931                                                              json::from_str(&json_err).ok()) {
20932                            sleep(d);
20933                            continue;
20934                        }
20935                        dlg.finished(false);
20936                        return match json::from_str::<ErrorResponse>(&json_err){
20937                            Err(_) => Err(Error::Failure(res)),
20938                            Ok(serr) => Err(Error::BadRequest(serr))
20939                        }
20940                    }
20941                    let result_value = res;
20942
20943                    dlg.finished(true);
20944                    return Ok(result_value)
20945                }
20946            }
20947        }
20948    }
20949
20950
20951    /// Email or immutable ID of the group
20952    ///
20953    /// Sets the *group key* path property to the given value.
20954    ///
20955    /// Even though the property as already been set when instantiating this call,
20956    /// we provide this method for API completeness.
20957    pub fn group_key(mut self, new_value: &str) -> MemberDeleteCall<'a, C, A> {
20958        self._group_key = new_value.to_string();
20959        self
20960    }
20961    /// Email or immutable ID of the member
20962    ///
20963    /// Sets the *member key* path property to the given value.
20964    ///
20965    /// Even though the property as already been set when instantiating this call,
20966    /// we provide this method for API completeness.
20967    pub fn member_key(mut self, new_value: &str) -> MemberDeleteCall<'a, C, A> {
20968        self._member_key = new_value.to_string();
20969        self
20970    }
20971    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20972    /// while executing the actual API request.
20973    /// 
20974    /// It should be used to handle progress information, and to implement a certain level of resilience.
20975    ///
20976    /// Sets the *delegate* property to the given value.
20977    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> MemberDeleteCall<'a, C, A> {
20978        self._delegate = Some(new_value);
20979        self
20980    }
20981
20982    /// Set any additional parameter of the query string used in the request.
20983    /// It should be used to set parameters which are not yet available through their own
20984    /// setters.
20985    ///
20986    /// Please note that this method must not be used to set any of the known parameters
20987    /// which have their own setter method. If done anyway, the request will fail.
20988    ///
20989    /// # Additional Parameters
20990    ///
20991    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20992    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20993    /// * *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.
20994    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20995    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20996    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20997    /// * *alt* (query-string) - Data format for the response.
20998    pub fn param<T>(mut self, name: T, value: T) -> MemberDeleteCall<'a, C, A>
20999                                                        where T: AsRef<str> {
21000        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
21001        self
21002    }
21003
21004    /// Identifies the authorization scope for the method you are building.
21005    ///
21006    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
21007    /// `Scope::DirectoryGroup`.
21008    ///
21009    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21010    /// tokens for more than one scope.
21011    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
21012    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
21013    /// function for details).
21014    ///
21015    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21016    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21017    /// sufficient, a read-write scope will do as well.
21018    pub fn add_scope<T, S>(mut self, scope: T) -> MemberDeleteCall<'a, C, A>
21019                                                        where T: Into<Option<S>>,
21020                                                              S: AsRef<str> {
21021        match scope.into() {
21022          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
21023          None => None,
21024        };
21025        self
21026    }
21027}
21028
21029
21030/// Get information about an ASP issued by a user.
21031///
21032/// A builder for the *get* method supported by a *asp* resource.
21033/// It is not used directly, but through a `AspMethods` instance.
21034///
21035/// # Example
21036///
21037/// Instantiate a resource method builder
21038///
21039/// ```test_harness,no_run
21040/// # extern crate hyper;
21041/// # extern crate hyper_rustls;
21042/// # extern crate yup_oauth2 as oauth2;
21043/// # extern crate google_admin1_directory as admin1_directory;
21044/// # #[test] fn egal() {
21045/// # use std::default::Default;
21046/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
21047/// # use admin1_directory::Directory;
21048/// 
21049/// # let secret: ApplicationSecret = Default::default();
21050/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
21051/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
21052/// #                               <MemoryStorage as Default>::default(), None);
21053/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
21054/// // You can configure optional parameters by calling the respective setters at will, and
21055/// // execute the final call using `doit()`.
21056/// // Values shown here are possibly random and not representative !
21057/// let result = hub.asps().get("userKey", -36)
21058///              .doit();
21059/// # }
21060/// ```
21061pub struct AspGetCall<'a, C, A>
21062    where C: 'a, A: 'a {
21063
21064    hub: &'a Directory<C, A>,
21065    _user_key: String,
21066    _code_id: i32,
21067    _delegate: Option<&'a mut dyn Delegate>,
21068    _additional_params: HashMap<String, String>,
21069    _scopes: BTreeMap<String, ()>
21070}
21071
21072impl<'a, C, A> CallBuilder for AspGetCall<'a, C, A> {}
21073
21074impl<'a, C, A> AspGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
21075
21076
21077    /// Perform the operation you have build so far.
21078    pub fn doit(mut self) -> Result<(hyper::client::Response, Asp)> {
21079        use std::io::{Read, Seek};
21080        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
21081        let mut dd = DefaultDelegate;
21082        let mut dlg: &mut dyn Delegate = match self._delegate {
21083            Some(d) => d,
21084            None => &mut dd
21085        };
21086        dlg.begin(MethodInfo { id: "directory.asps.get",
21087                               http_method: hyper::method::Method::Get });
21088        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
21089        params.push(("userKey", self._user_key.to_string()));
21090        params.push(("codeId", self._code_id.to_string()));
21091        for &field in ["alt", "userKey", "codeId"].iter() {
21092            if self._additional_params.contains_key(field) {
21093                dlg.finished(false);
21094                return Err(Error::FieldClash(field));
21095            }
21096        }
21097        for (name, value) in self._additional_params.iter() {
21098            params.push((&name, value.clone()));
21099        }
21100
21101        params.push(("alt", "json".to_string()));
21102
21103        let mut url = self.hub._base_url.clone() + "users/{userKey}/asps/{codeId}";
21104        if self._scopes.len() == 0 {
21105            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
21106        }
21107
21108        for &(find_this, param_name) in [("{userKey}", "userKey"), ("{codeId}", "codeId")].iter() {
21109            let mut replace_with: Option<&str> = None;
21110            for &(name, ref value) in params.iter() {
21111                if name == param_name {
21112                    replace_with = Some(value);
21113                    break;
21114                }
21115            }
21116            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
21117        }
21118        {
21119            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
21120            for param_name in ["codeId", "userKey"].iter() {
21121                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
21122                    indices_for_removal.push(index);
21123                }
21124            }
21125            for &index in indices_for_removal.iter() {
21126                params.remove(index);
21127            }
21128        }
21129
21130        let url = hyper::Url::parse_with_params(&url, params).unwrap();
21131
21132
21133
21134        loop {
21135            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
21136                Ok(token) => token,
21137                Err(err) => {
21138                    match  dlg.token(&*err) {
21139                        Some(token) => token,
21140                        None => {
21141                            dlg.finished(false);
21142                            return Err(Error::MissingToken(err))
21143                        }
21144                    }
21145                }
21146            };
21147            let auth_header = Authorization(Bearer { token: token.access_token });
21148            let mut req_result = {
21149                let mut client = &mut *self.hub.client.borrow_mut();
21150                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
21151                    .header(UserAgent(self.hub._user_agent.clone()))
21152                    .header(auth_header.clone());
21153
21154                dlg.pre_request();
21155                req.send()
21156            };
21157
21158            match req_result {
21159                Err(err) => {
21160                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
21161                        sleep(d);
21162                        continue;
21163                    }
21164                    dlg.finished(false);
21165                    return Err(Error::HttpError(err))
21166                }
21167                Ok(mut res) => {
21168                    if !res.status.is_success() {
21169                        let mut json_err = String::new();
21170                        res.read_to_string(&mut json_err).unwrap();
21171                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
21172                                                              json::from_str(&json_err).ok(),
21173                                                              json::from_str(&json_err).ok()) {
21174                            sleep(d);
21175                            continue;
21176                        }
21177                        dlg.finished(false);
21178                        return match json::from_str::<ErrorResponse>(&json_err){
21179                            Err(_) => Err(Error::Failure(res)),
21180                            Ok(serr) => Err(Error::BadRequest(serr))
21181                        }
21182                    }
21183                    let result_value = {
21184                        let mut json_response = String::new();
21185                        res.read_to_string(&mut json_response).unwrap();
21186                        match json::from_str(&json_response) {
21187                            Ok(decoded) => (res, decoded),
21188                            Err(err) => {
21189                                dlg.response_json_decode_error(&json_response, &err);
21190                                return Err(Error::JsonDecodeError(json_response, err));
21191                            }
21192                        }
21193                    };
21194
21195                    dlg.finished(true);
21196                    return Ok(result_value)
21197                }
21198            }
21199        }
21200    }
21201
21202
21203    /// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
21204    ///
21205    /// Sets the *user key* path property to the given value.
21206    ///
21207    /// Even though the property as already been set when instantiating this call,
21208    /// we provide this method for API completeness.
21209    pub fn user_key(mut self, new_value: &str) -> AspGetCall<'a, C, A> {
21210        self._user_key = new_value.to_string();
21211        self
21212    }
21213    /// The unique ID of the ASP.
21214    ///
21215    /// Sets the *code id* path property to the given value.
21216    ///
21217    /// Even though the property as already been set when instantiating this call,
21218    /// we provide this method for API completeness.
21219    pub fn code_id(mut self, new_value: i32) -> AspGetCall<'a, C, A> {
21220        self._code_id = new_value;
21221        self
21222    }
21223    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21224    /// while executing the actual API request.
21225    /// 
21226    /// It should be used to handle progress information, and to implement a certain level of resilience.
21227    ///
21228    /// Sets the *delegate* property to the given value.
21229    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> AspGetCall<'a, C, A> {
21230        self._delegate = Some(new_value);
21231        self
21232    }
21233
21234    /// Set any additional parameter of the query string used in the request.
21235    /// It should be used to set parameters which are not yet available through their own
21236    /// setters.
21237    ///
21238    /// Please note that this method must not be used to set any of the known parameters
21239    /// which have their own setter method. If done anyway, the request will fail.
21240    ///
21241    /// # Additional Parameters
21242    ///
21243    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21244    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21245    /// * *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.
21246    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21247    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21248    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21249    /// * *alt* (query-string) - Data format for the response.
21250    pub fn param<T>(mut self, name: T, value: T) -> AspGetCall<'a, C, A>
21251                                                        where T: AsRef<str> {
21252        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
21253        self
21254    }
21255
21256    /// Identifies the authorization scope for the method you are building.
21257    ///
21258    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
21259    /// `Scope::DirectoryUserSecurity`.
21260    ///
21261    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21262    /// tokens for more than one scope.
21263    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
21264    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
21265    /// function for details).
21266    ///
21267    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21268    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21269    /// sufficient, a read-write scope will do as well.
21270    pub fn add_scope<T, S>(mut self, scope: T) -> AspGetCall<'a, C, A>
21271                                                        where T: Into<Option<S>>,
21272                                                              S: AsRef<str> {
21273        match scope.into() {
21274          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
21275          None => None,
21276        };
21277        self
21278    }
21279}
21280
21281
21282/// Delete an ASP issued by a user.
21283///
21284/// A builder for the *delete* method supported by a *asp* resource.
21285/// It is not used directly, but through a `AspMethods` instance.
21286///
21287/// # Example
21288///
21289/// Instantiate a resource method builder
21290///
21291/// ```test_harness,no_run
21292/// # extern crate hyper;
21293/// # extern crate hyper_rustls;
21294/// # extern crate yup_oauth2 as oauth2;
21295/// # extern crate google_admin1_directory as admin1_directory;
21296/// # #[test] fn egal() {
21297/// # use std::default::Default;
21298/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
21299/// # use admin1_directory::Directory;
21300/// 
21301/// # let secret: ApplicationSecret = Default::default();
21302/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
21303/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
21304/// #                               <MemoryStorage as Default>::default(), None);
21305/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
21306/// // You can configure optional parameters by calling the respective setters at will, and
21307/// // execute the final call using `doit()`.
21308/// // Values shown here are possibly random and not representative !
21309/// let result = hub.asps().delete("userKey", -51)
21310///              .doit();
21311/// # }
21312/// ```
21313pub struct AspDeleteCall<'a, C, A>
21314    where C: 'a, A: 'a {
21315
21316    hub: &'a Directory<C, A>,
21317    _user_key: String,
21318    _code_id: i32,
21319    _delegate: Option<&'a mut dyn Delegate>,
21320    _additional_params: HashMap<String, String>,
21321    _scopes: BTreeMap<String, ()>
21322}
21323
21324impl<'a, C, A> CallBuilder for AspDeleteCall<'a, C, A> {}
21325
21326impl<'a, C, A> AspDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
21327
21328
21329    /// Perform the operation you have build so far.
21330    pub fn doit(mut self) -> Result<hyper::client::Response> {
21331        use std::io::{Read, Seek};
21332        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
21333        let mut dd = DefaultDelegate;
21334        let mut dlg: &mut dyn Delegate = match self._delegate {
21335            Some(d) => d,
21336            None => &mut dd
21337        };
21338        dlg.begin(MethodInfo { id: "directory.asps.delete",
21339                               http_method: hyper::method::Method::Delete });
21340        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
21341        params.push(("userKey", self._user_key.to_string()));
21342        params.push(("codeId", self._code_id.to_string()));
21343        for &field in ["userKey", "codeId"].iter() {
21344            if self._additional_params.contains_key(field) {
21345                dlg.finished(false);
21346                return Err(Error::FieldClash(field));
21347            }
21348        }
21349        for (name, value) in self._additional_params.iter() {
21350            params.push((&name, value.clone()));
21351        }
21352
21353
21354        let mut url = self.hub._base_url.clone() + "users/{userKey}/asps/{codeId}";
21355        if self._scopes.len() == 0 {
21356            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
21357        }
21358
21359        for &(find_this, param_name) in [("{userKey}", "userKey"), ("{codeId}", "codeId")].iter() {
21360            let mut replace_with: Option<&str> = None;
21361            for &(name, ref value) in params.iter() {
21362                if name == param_name {
21363                    replace_with = Some(value);
21364                    break;
21365                }
21366            }
21367            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
21368        }
21369        {
21370            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
21371            for param_name in ["codeId", "userKey"].iter() {
21372                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
21373                    indices_for_removal.push(index);
21374                }
21375            }
21376            for &index in indices_for_removal.iter() {
21377                params.remove(index);
21378            }
21379        }
21380
21381        let url = hyper::Url::parse_with_params(&url, params).unwrap();
21382
21383
21384
21385        loop {
21386            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
21387                Ok(token) => token,
21388                Err(err) => {
21389                    match  dlg.token(&*err) {
21390                        Some(token) => token,
21391                        None => {
21392                            dlg.finished(false);
21393                            return Err(Error::MissingToken(err))
21394                        }
21395                    }
21396                }
21397            };
21398            let auth_header = Authorization(Bearer { token: token.access_token });
21399            let mut req_result = {
21400                let mut client = &mut *self.hub.client.borrow_mut();
21401                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
21402                    .header(UserAgent(self.hub._user_agent.clone()))
21403                    .header(auth_header.clone());
21404
21405                dlg.pre_request();
21406                req.send()
21407            };
21408
21409            match req_result {
21410                Err(err) => {
21411                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
21412                        sleep(d);
21413                        continue;
21414                    }
21415                    dlg.finished(false);
21416                    return Err(Error::HttpError(err))
21417                }
21418                Ok(mut res) => {
21419                    if !res.status.is_success() {
21420                        let mut json_err = String::new();
21421                        res.read_to_string(&mut json_err).unwrap();
21422                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
21423                                                              json::from_str(&json_err).ok(),
21424                                                              json::from_str(&json_err).ok()) {
21425                            sleep(d);
21426                            continue;
21427                        }
21428                        dlg.finished(false);
21429                        return match json::from_str::<ErrorResponse>(&json_err){
21430                            Err(_) => Err(Error::Failure(res)),
21431                            Ok(serr) => Err(Error::BadRequest(serr))
21432                        }
21433                    }
21434                    let result_value = res;
21435
21436                    dlg.finished(true);
21437                    return Ok(result_value)
21438                }
21439            }
21440        }
21441    }
21442
21443
21444    /// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
21445    ///
21446    /// Sets the *user key* path property to the given value.
21447    ///
21448    /// Even though the property as already been set when instantiating this call,
21449    /// we provide this method for API completeness.
21450    pub fn user_key(mut self, new_value: &str) -> AspDeleteCall<'a, C, A> {
21451        self._user_key = new_value.to_string();
21452        self
21453    }
21454    /// The unique ID of the ASP to be deleted.
21455    ///
21456    /// Sets the *code id* path property to the given value.
21457    ///
21458    /// Even though the property as already been set when instantiating this call,
21459    /// we provide this method for API completeness.
21460    pub fn code_id(mut self, new_value: i32) -> AspDeleteCall<'a, C, A> {
21461        self._code_id = new_value;
21462        self
21463    }
21464    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21465    /// while executing the actual API request.
21466    /// 
21467    /// It should be used to handle progress information, and to implement a certain level of resilience.
21468    ///
21469    /// Sets the *delegate* property to the given value.
21470    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> AspDeleteCall<'a, C, A> {
21471        self._delegate = Some(new_value);
21472        self
21473    }
21474
21475    /// Set any additional parameter of the query string used in the request.
21476    /// It should be used to set parameters which are not yet available through their own
21477    /// setters.
21478    ///
21479    /// Please note that this method must not be used to set any of the known parameters
21480    /// which have their own setter method. If done anyway, the request will fail.
21481    ///
21482    /// # Additional Parameters
21483    ///
21484    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21485    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21486    /// * *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.
21487    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21488    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21489    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21490    /// * *alt* (query-string) - Data format for the response.
21491    pub fn param<T>(mut self, name: T, value: T) -> AspDeleteCall<'a, C, A>
21492                                                        where T: AsRef<str> {
21493        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
21494        self
21495    }
21496
21497    /// Identifies the authorization scope for the method you are building.
21498    ///
21499    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
21500    /// `Scope::DirectoryUserSecurity`.
21501    ///
21502    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21503    /// tokens for more than one scope.
21504    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
21505    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
21506    /// function for details).
21507    ///
21508    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21509    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21510    /// sufficient, a read-write scope will do as well.
21511    pub fn add_scope<T, S>(mut self, scope: T) -> AspDeleteCall<'a, C, A>
21512                                                        where T: Into<Option<S>>,
21513                                                              S: AsRef<str> {
21514        match scope.into() {
21515          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
21516          None => None,
21517        };
21518        self
21519    }
21520}
21521
21522
21523/// List the ASPs issued by a user.
21524///
21525/// A builder for the *list* method supported by a *asp* resource.
21526/// It is not used directly, but through a `AspMethods` instance.
21527///
21528/// # Example
21529///
21530/// Instantiate a resource method builder
21531///
21532/// ```test_harness,no_run
21533/// # extern crate hyper;
21534/// # extern crate hyper_rustls;
21535/// # extern crate yup_oauth2 as oauth2;
21536/// # extern crate google_admin1_directory as admin1_directory;
21537/// # #[test] fn egal() {
21538/// # use std::default::Default;
21539/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
21540/// # use admin1_directory::Directory;
21541/// 
21542/// # let secret: ApplicationSecret = Default::default();
21543/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
21544/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
21545/// #                               <MemoryStorage as Default>::default(), None);
21546/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
21547/// // You can configure optional parameters by calling the respective setters at will, and
21548/// // execute the final call using `doit()`.
21549/// // Values shown here are possibly random and not representative !
21550/// let result = hub.asps().list("userKey")
21551///              .doit();
21552/// # }
21553/// ```
21554pub struct AspListCall<'a, C, A>
21555    where C: 'a, A: 'a {
21556
21557    hub: &'a Directory<C, A>,
21558    _user_key: String,
21559    _delegate: Option<&'a mut dyn Delegate>,
21560    _additional_params: HashMap<String, String>,
21561    _scopes: BTreeMap<String, ()>
21562}
21563
21564impl<'a, C, A> CallBuilder for AspListCall<'a, C, A> {}
21565
21566impl<'a, C, A> AspListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
21567
21568
21569    /// Perform the operation you have build so far.
21570    pub fn doit(mut self) -> Result<(hyper::client::Response, Asps)> {
21571        use std::io::{Read, Seek};
21572        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
21573        let mut dd = DefaultDelegate;
21574        let mut dlg: &mut dyn Delegate = match self._delegate {
21575            Some(d) => d,
21576            None => &mut dd
21577        };
21578        dlg.begin(MethodInfo { id: "directory.asps.list",
21579                               http_method: hyper::method::Method::Get });
21580        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
21581        params.push(("userKey", self._user_key.to_string()));
21582        for &field in ["alt", "userKey"].iter() {
21583            if self._additional_params.contains_key(field) {
21584                dlg.finished(false);
21585                return Err(Error::FieldClash(field));
21586            }
21587        }
21588        for (name, value) in self._additional_params.iter() {
21589            params.push((&name, value.clone()));
21590        }
21591
21592        params.push(("alt", "json".to_string()));
21593
21594        let mut url = self.hub._base_url.clone() + "users/{userKey}/asps";
21595        if self._scopes.len() == 0 {
21596            self._scopes.insert(Scope::DirectoryUserSecurity.as_ref().to_string(), ());
21597        }
21598
21599        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
21600            let mut replace_with: Option<&str> = None;
21601            for &(name, ref value) in params.iter() {
21602                if name == param_name {
21603                    replace_with = Some(value);
21604                    break;
21605                }
21606            }
21607            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
21608        }
21609        {
21610            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
21611            for param_name in ["userKey"].iter() {
21612                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
21613                    indices_for_removal.push(index);
21614                }
21615            }
21616            for &index in indices_for_removal.iter() {
21617                params.remove(index);
21618            }
21619        }
21620
21621        let url = hyper::Url::parse_with_params(&url, params).unwrap();
21622
21623
21624
21625        loop {
21626            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
21627                Ok(token) => token,
21628                Err(err) => {
21629                    match  dlg.token(&*err) {
21630                        Some(token) => token,
21631                        None => {
21632                            dlg.finished(false);
21633                            return Err(Error::MissingToken(err))
21634                        }
21635                    }
21636                }
21637            };
21638            let auth_header = Authorization(Bearer { token: token.access_token });
21639            let mut req_result = {
21640                let mut client = &mut *self.hub.client.borrow_mut();
21641                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
21642                    .header(UserAgent(self.hub._user_agent.clone()))
21643                    .header(auth_header.clone());
21644
21645                dlg.pre_request();
21646                req.send()
21647            };
21648
21649            match req_result {
21650                Err(err) => {
21651                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
21652                        sleep(d);
21653                        continue;
21654                    }
21655                    dlg.finished(false);
21656                    return Err(Error::HttpError(err))
21657                }
21658                Ok(mut res) => {
21659                    if !res.status.is_success() {
21660                        let mut json_err = String::new();
21661                        res.read_to_string(&mut json_err).unwrap();
21662                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
21663                                                              json::from_str(&json_err).ok(),
21664                                                              json::from_str(&json_err).ok()) {
21665                            sleep(d);
21666                            continue;
21667                        }
21668                        dlg.finished(false);
21669                        return match json::from_str::<ErrorResponse>(&json_err){
21670                            Err(_) => Err(Error::Failure(res)),
21671                            Ok(serr) => Err(Error::BadRequest(serr))
21672                        }
21673                    }
21674                    let result_value = {
21675                        let mut json_response = String::new();
21676                        res.read_to_string(&mut json_response).unwrap();
21677                        match json::from_str(&json_response) {
21678                            Ok(decoded) => (res, decoded),
21679                            Err(err) => {
21680                                dlg.response_json_decode_error(&json_response, &err);
21681                                return Err(Error::JsonDecodeError(json_response, err));
21682                            }
21683                        }
21684                    };
21685
21686                    dlg.finished(true);
21687                    return Ok(result_value)
21688                }
21689            }
21690        }
21691    }
21692
21693
21694    /// Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
21695    ///
21696    /// Sets the *user key* path property to the given value.
21697    ///
21698    /// Even though the property as already been set when instantiating this call,
21699    /// we provide this method for API completeness.
21700    pub fn user_key(mut self, new_value: &str) -> AspListCall<'a, C, A> {
21701        self._user_key = new_value.to_string();
21702        self
21703    }
21704    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21705    /// while executing the actual API request.
21706    /// 
21707    /// It should be used to handle progress information, and to implement a certain level of resilience.
21708    ///
21709    /// Sets the *delegate* property to the given value.
21710    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> AspListCall<'a, C, A> {
21711        self._delegate = Some(new_value);
21712        self
21713    }
21714
21715    /// Set any additional parameter of the query string used in the request.
21716    /// It should be used to set parameters which are not yet available through their own
21717    /// setters.
21718    ///
21719    /// Please note that this method must not be used to set any of the known parameters
21720    /// which have their own setter method. If done anyway, the request will fail.
21721    ///
21722    /// # Additional Parameters
21723    ///
21724    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21725    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21726    /// * *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.
21727    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21728    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21729    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21730    /// * *alt* (query-string) - Data format for the response.
21731    pub fn param<T>(mut self, name: T, value: T) -> AspListCall<'a, C, A>
21732                                                        where T: AsRef<str> {
21733        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
21734        self
21735    }
21736
21737    /// Identifies the authorization scope for the method you are building.
21738    ///
21739    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
21740    /// `Scope::DirectoryUserSecurity`.
21741    ///
21742    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21743    /// tokens for more than one scope.
21744    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
21745    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
21746    /// function for details).
21747    ///
21748    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21749    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21750    /// sufficient, a read-write scope will do as well.
21751    pub fn add_scope<T, S>(mut self, scope: T) -> AspListCall<'a, C, A>
21752                                                        where T: Into<Option<S>>,
21753                                                              S: AsRef<str> {
21754        match scope.into() {
21755          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
21756          None => None,
21757        };
21758        self
21759    }
21760}
21761
21762
21763/// Lists the domains of the customer.
21764///
21765/// A builder for the *list* method supported by a *domain* resource.
21766/// It is not used directly, but through a `DomainMethods` instance.
21767///
21768/// # Example
21769///
21770/// Instantiate a resource method builder
21771///
21772/// ```test_harness,no_run
21773/// # extern crate hyper;
21774/// # extern crate hyper_rustls;
21775/// # extern crate yup_oauth2 as oauth2;
21776/// # extern crate google_admin1_directory as admin1_directory;
21777/// # #[test] fn egal() {
21778/// # use std::default::Default;
21779/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
21780/// # use admin1_directory::Directory;
21781/// 
21782/// # let secret: ApplicationSecret = Default::default();
21783/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
21784/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
21785/// #                               <MemoryStorage as Default>::default(), None);
21786/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
21787/// // You can configure optional parameters by calling the respective setters at will, and
21788/// // execute the final call using `doit()`.
21789/// // Values shown here are possibly random and not representative !
21790/// let result = hub.domains().list("customer")
21791///              .doit();
21792/// # }
21793/// ```
21794pub struct DomainListCall<'a, C, A>
21795    where C: 'a, A: 'a {
21796
21797    hub: &'a Directory<C, A>,
21798    _customer: String,
21799    _delegate: Option<&'a mut dyn Delegate>,
21800    _additional_params: HashMap<String, String>,
21801    _scopes: BTreeMap<String, ()>
21802}
21803
21804impl<'a, C, A> CallBuilder for DomainListCall<'a, C, A> {}
21805
21806impl<'a, C, A> DomainListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
21807
21808
21809    /// Perform the operation you have build so far.
21810    pub fn doit(mut self) -> Result<(hyper::client::Response, Domains2)> {
21811        use std::io::{Read, Seek};
21812        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
21813        let mut dd = DefaultDelegate;
21814        let mut dlg: &mut dyn Delegate = match self._delegate {
21815            Some(d) => d,
21816            None => &mut dd
21817        };
21818        dlg.begin(MethodInfo { id: "directory.domains.list",
21819                               http_method: hyper::method::Method::Get });
21820        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
21821        params.push(("customer", self._customer.to_string()));
21822        for &field in ["alt", "customer"].iter() {
21823            if self._additional_params.contains_key(field) {
21824                dlg.finished(false);
21825                return Err(Error::FieldClash(field));
21826            }
21827        }
21828        for (name, value) in self._additional_params.iter() {
21829            params.push((&name, value.clone()));
21830        }
21831
21832        params.push(("alt", "json".to_string()));
21833
21834        let mut url = self.hub._base_url.clone() + "customer/{customer}/domains";
21835        if self._scopes.len() == 0 {
21836            self._scopes.insert(Scope::DirectoryDomainReadonly.as_ref().to_string(), ());
21837        }
21838
21839        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
21840            let mut replace_with: Option<&str> = None;
21841            for &(name, ref value) in params.iter() {
21842                if name == param_name {
21843                    replace_with = Some(value);
21844                    break;
21845                }
21846            }
21847            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
21848        }
21849        {
21850            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
21851            for param_name in ["customer"].iter() {
21852                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
21853                    indices_for_removal.push(index);
21854                }
21855            }
21856            for &index in indices_for_removal.iter() {
21857                params.remove(index);
21858            }
21859        }
21860
21861        let url = hyper::Url::parse_with_params(&url, params).unwrap();
21862
21863
21864
21865        loop {
21866            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
21867                Ok(token) => token,
21868                Err(err) => {
21869                    match  dlg.token(&*err) {
21870                        Some(token) => token,
21871                        None => {
21872                            dlg.finished(false);
21873                            return Err(Error::MissingToken(err))
21874                        }
21875                    }
21876                }
21877            };
21878            let auth_header = Authorization(Bearer { token: token.access_token });
21879            let mut req_result = {
21880                let mut client = &mut *self.hub.client.borrow_mut();
21881                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
21882                    .header(UserAgent(self.hub._user_agent.clone()))
21883                    .header(auth_header.clone());
21884
21885                dlg.pre_request();
21886                req.send()
21887            };
21888
21889            match req_result {
21890                Err(err) => {
21891                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
21892                        sleep(d);
21893                        continue;
21894                    }
21895                    dlg.finished(false);
21896                    return Err(Error::HttpError(err))
21897                }
21898                Ok(mut res) => {
21899                    if !res.status.is_success() {
21900                        let mut json_err = String::new();
21901                        res.read_to_string(&mut json_err).unwrap();
21902                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
21903                                                              json::from_str(&json_err).ok(),
21904                                                              json::from_str(&json_err).ok()) {
21905                            sleep(d);
21906                            continue;
21907                        }
21908                        dlg.finished(false);
21909                        return match json::from_str::<ErrorResponse>(&json_err){
21910                            Err(_) => Err(Error::Failure(res)),
21911                            Ok(serr) => Err(Error::BadRequest(serr))
21912                        }
21913                    }
21914                    let result_value = {
21915                        let mut json_response = String::new();
21916                        res.read_to_string(&mut json_response).unwrap();
21917                        match json::from_str(&json_response) {
21918                            Ok(decoded) => (res, decoded),
21919                            Err(err) => {
21920                                dlg.response_json_decode_error(&json_response, &err);
21921                                return Err(Error::JsonDecodeError(json_response, err));
21922                            }
21923                        }
21924                    };
21925
21926                    dlg.finished(true);
21927                    return Ok(result_value)
21928                }
21929            }
21930        }
21931    }
21932
21933
21934    /// Immutable ID of the G Suite account.
21935    ///
21936    /// Sets the *customer* path property to the given value.
21937    ///
21938    /// Even though the property as already been set when instantiating this call,
21939    /// we provide this method for API completeness.
21940    pub fn customer(mut self, new_value: &str) -> DomainListCall<'a, C, A> {
21941        self._customer = new_value.to_string();
21942        self
21943    }
21944    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21945    /// while executing the actual API request.
21946    /// 
21947    /// It should be used to handle progress information, and to implement a certain level of resilience.
21948    ///
21949    /// Sets the *delegate* property to the given value.
21950    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainListCall<'a, C, A> {
21951        self._delegate = Some(new_value);
21952        self
21953    }
21954
21955    /// Set any additional parameter of the query string used in the request.
21956    /// It should be used to set parameters which are not yet available through their own
21957    /// setters.
21958    ///
21959    /// Please note that this method must not be used to set any of the known parameters
21960    /// which have their own setter method. If done anyway, the request will fail.
21961    ///
21962    /// # Additional Parameters
21963    ///
21964    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21965    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21966    /// * *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.
21967    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21968    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21969    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21970    /// * *alt* (query-string) - Data format for the response.
21971    pub fn param<T>(mut self, name: T, value: T) -> DomainListCall<'a, C, A>
21972                                                        where T: AsRef<str> {
21973        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
21974        self
21975    }
21976
21977    /// Identifies the authorization scope for the method you are building.
21978    ///
21979    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
21980    /// `Scope::DirectoryDomainReadonly`.
21981    ///
21982    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21983    /// tokens for more than one scope.
21984    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
21985    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
21986    /// function for details).
21987    ///
21988    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21989    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21990    /// sufficient, a read-write scope will do as well.
21991    pub fn add_scope<T, S>(mut self, scope: T) -> DomainListCall<'a, C, A>
21992                                                        where T: Into<Option<S>>,
21993                                                              S: AsRef<str> {
21994        match scope.into() {
21995          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
21996          None => None,
21997        };
21998        self
21999    }
22000}
22001
22002
22003/// Retrieves a domain of the customer.
22004///
22005/// A builder for the *get* method supported by a *domain* resource.
22006/// It is not used directly, but through a `DomainMethods` instance.
22007///
22008/// # Example
22009///
22010/// Instantiate a resource method builder
22011///
22012/// ```test_harness,no_run
22013/// # extern crate hyper;
22014/// # extern crate hyper_rustls;
22015/// # extern crate yup_oauth2 as oauth2;
22016/// # extern crate google_admin1_directory as admin1_directory;
22017/// # #[test] fn egal() {
22018/// # use std::default::Default;
22019/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
22020/// # use admin1_directory::Directory;
22021/// 
22022/// # let secret: ApplicationSecret = Default::default();
22023/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
22024/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
22025/// #                               <MemoryStorage as Default>::default(), None);
22026/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
22027/// // You can configure optional parameters by calling the respective setters at will, and
22028/// // execute the final call using `doit()`.
22029/// // Values shown here are possibly random and not representative !
22030/// let result = hub.domains().get("customer", "domainName")
22031///              .doit();
22032/// # }
22033/// ```
22034pub struct DomainGetCall<'a, C, A>
22035    where C: 'a, A: 'a {
22036
22037    hub: &'a Directory<C, A>,
22038    _customer: String,
22039    _domain_name: String,
22040    _delegate: Option<&'a mut dyn Delegate>,
22041    _additional_params: HashMap<String, String>,
22042    _scopes: BTreeMap<String, ()>
22043}
22044
22045impl<'a, C, A> CallBuilder for DomainGetCall<'a, C, A> {}
22046
22047impl<'a, C, A> DomainGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
22048
22049
22050    /// Perform the operation you have build so far.
22051    pub fn doit(mut self) -> Result<(hyper::client::Response, Domains)> {
22052        use std::io::{Read, Seek};
22053        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
22054        let mut dd = DefaultDelegate;
22055        let mut dlg: &mut dyn Delegate = match self._delegate {
22056            Some(d) => d,
22057            None => &mut dd
22058        };
22059        dlg.begin(MethodInfo { id: "directory.domains.get",
22060                               http_method: hyper::method::Method::Get });
22061        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
22062        params.push(("customer", self._customer.to_string()));
22063        params.push(("domainName", self._domain_name.to_string()));
22064        for &field in ["alt", "customer", "domainName"].iter() {
22065            if self._additional_params.contains_key(field) {
22066                dlg.finished(false);
22067                return Err(Error::FieldClash(field));
22068            }
22069        }
22070        for (name, value) in self._additional_params.iter() {
22071            params.push((&name, value.clone()));
22072        }
22073
22074        params.push(("alt", "json".to_string()));
22075
22076        let mut url = self.hub._base_url.clone() + "customer/{customer}/domains/{domainName}";
22077        if self._scopes.len() == 0 {
22078            self._scopes.insert(Scope::DirectoryDomainReadonly.as_ref().to_string(), ());
22079        }
22080
22081        for &(find_this, param_name) in [("{customer}", "customer"), ("{domainName}", "domainName")].iter() {
22082            let mut replace_with: Option<&str> = None;
22083            for &(name, ref value) in params.iter() {
22084                if name == param_name {
22085                    replace_with = Some(value);
22086                    break;
22087                }
22088            }
22089            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
22090        }
22091        {
22092            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
22093            for param_name in ["domainName", "customer"].iter() {
22094                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
22095                    indices_for_removal.push(index);
22096                }
22097            }
22098            for &index in indices_for_removal.iter() {
22099                params.remove(index);
22100            }
22101        }
22102
22103        let url = hyper::Url::parse_with_params(&url, params).unwrap();
22104
22105
22106
22107        loop {
22108            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
22109                Ok(token) => token,
22110                Err(err) => {
22111                    match  dlg.token(&*err) {
22112                        Some(token) => token,
22113                        None => {
22114                            dlg.finished(false);
22115                            return Err(Error::MissingToken(err))
22116                        }
22117                    }
22118                }
22119            };
22120            let auth_header = Authorization(Bearer { token: token.access_token });
22121            let mut req_result = {
22122                let mut client = &mut *self.hub.client.borrow_mut();
22123                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
22124                    .header(UserAgent(self.hub._user_agent.clone()))
22125                    .header(auth_header.clone());
22126
22127                dlg.pre_request();
22128                req.send()
22129            };
22130
22131            match req_result {
22132                Err(err) => {
22133                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
22134                        sleep(d);
22135                        continue;
22136                    }
22137                    dlg.finished(false);
22138                    return Err(Error::HttpError(err))
22139                }
22140                Ok(mut res) => {
22141                    if !res.status.is_success() {
22142                        let mut json_err = String::new();
22143                        res.read_to_string(&mut json_err).unwrap();
22144                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
22145                                                              json::from_str(&json_err).ok(),
22146                                                              json::from_str(&json_err).ok()) {
22147                            sleep(d);
22148                            continue;
22149                        }
22150                        dlg.finished(false);
22151                        return match json::from_str::<ErrorResponse>(&json_err){
22152                            Err(_) => Err(Error::Failure(res)),
22153                            Ok(serr) => Err(Error::BadRequest(serr))
22154                        }
22155                    }
22156                    let result_value = {
22157                        let mut json_response = String::new();
22158                        res.read_to_string(&mut json_response).unwrap();
22159                        match json::from_str(&json_response) {
22160                            Ok(decoded) => (res, decoded),
22161                            Err(err) => {
22162                                dlg.response_json_decode_error(&json_response, &err);
22163                                return Err(Error::JsonDecodeError(json_response, err));
22164                            }
22165                        }
22166                    };
22167
22168                    dlg.finished(true);
22169                    return Ok(result_value)
22170                }
22171            }
22172        }
22173    }
22174
22175
22176    /// Immutable ID of the G Suite account.
22177    ///
22178    /// Sets the *customer* path property to the given value.
22179    ///
22180    /// Even though the property as already been set when instantiating this call,
22181    /// we provide this method for API completeness.
22182    pub fn customer(mut self, new_value: &str) -> DomainGetCall<'a, C, A> {
22183        self._customer = new_value.to_string();
22184        self
22185    }
22186    /// Name of domain to be retrieved
22187    ///
22188    /// Sets the *domain name* path property to the given value.
22189    ///
22190    /// Even though the property as already been set when instantiating this call,
22191    /// we provide this method for API completeness.
22192    pub fn domain_name(mut self, new_value: &str) -> DomainGetCall<'a, C, A> {
22193        self._domain_name = new_value.to_string();
22194        self
22195    }
22196    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22197    /// while executing the actual API request.
22198    /// 
22199    /// It should be used to handle progress information, and to implement a certain level of resilience.
22200    ///
22201    /// Sets the *delegate* property to the given value.
22202    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainGetCall<'a, C, A> {
22203        self._delegate = Some(new_value);
22204        self
22205    }
22206
22207    /// Set any additional parameter of the query string used in the request.
22208    /// It should be used to set parameters which are not yet available through their own
22209    /// setters.
22210    ///
22211    /// Please note that this method must not be used to set any of the known parameters
22212    /// which have their own setter method. If done anyway, the request will fail.
22213    ///
22214    /// # Additional Parameters
22215    ///
22216    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22217    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22218    /// * *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.
22219    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22220    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22221    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22222    /// * *alt* (query-string) - Data format for the response.
22223    pub fn param<T>(mut self, name: T, value: T) -> DomainGetCall<'a, C, A>
22224                                                        where T: AsRef<str> {
22225        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
22226        self
22227    }
22228
22229    /// Identifies the authorization scope for the method you are building.
22230    ///
22231    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
22232    /// `Scope::DirectoryDomainReadonly`.
22233    ///
22234    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22235    /// tokens for more than one scope.
22236    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
22237    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
22238    /// function for details).
22239    ///
22240    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22241    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22242    /// sufficient, a read-write scope will do as well.
22243    pub fn add_scope<T, S>(mut self, scope: T) -> DomainGetCall<'a, C, A>
22244                                                        where T: Into<Option<S>>,
22245                                                              S: AsRef<str> {
22246        match scope.into() {
22247          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
22248          None => None,
22249        };
22250        self
22251    }
22252}
22253
22254
22255/// Inserts a domain of the customer.
22256///
22257/// A builder for the *insert* method supported by a *domain* resource.
22258/// It is not used directly, but through a `DomainMethods` instance.
22259///
22260/// # Example
22261///
22262/// Instantiate a resource method builder
22263///
22264/// ```test_harness,no_run
22265/// # extern crate hyper;
22266/// # extern crate hyper_rustls;
22267/// # extern crate yup_oauth2 as oauth2;
22268/// # extern crate google_admin1_directory as admin1_directory;
22269/// use admin1_directory::Domains;
22270/// # #[test] fn egal() {
22271/// # use std::default::Default;
22272/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
22273/// # use admin1_directory::Directory;
22274/// 
22275/// # let secret: ApplicationSecret = Default::default();
22276/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
22277/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
22278/// #                               <MemoryStorage as Default>::default(), None);
22279/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
22280/// // As the method needs a request, you would usually fill it with the desired information
22281/// // into the respective structure. Some of the parts shown here might not be applicable !
22282/// // Values shown here are possibly random and not representative !
22283/// let mut req = Domains::default();
22284/// 
22285/// // You can configure optional parameters by calling the respective setters at will, and
22286/// // execute the final call using `doit()`.
22287/// // Values shown here are possibly random and not representative !
22288/// let result = hub.domains().insert(req, "customer")
22289///              .doit();
22290/// # }
22291/// ```
22292pub struct DomainInsertCall<'a, C, A>
22293    where C: 'a, A: 'a {
22294
22295    hub: &'a Directory<C, A>,
22296    _request: Domains,
22297    _customer: String,
22298    _delegate: Option<&'a mut dyn Delegate>,
22299    _additional_params: HashMap<String, String>,
22300    _scopes: BTreeMap<String, ()>
22301}
22302
22303impl<'a, C, A> CallBuilder for DomainInsertCall<'a, C, A> {}
22304
22305impl<'a, C, A> DomainInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
22306
22307
22308    /// Perform the operation you have build so far.
22309    pub fn doit(mut self) -> Result<(hyper::client::Response, Domains)> {
22310        use std::io::{Read, Seek};
22311        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
22312        let mut dd = DefaultDelegate;
22313        let mut dlg: &mut dyn Delegate = match self._delegate {
22314            Some(d) => d,
22315            None => &mut dd
22316        };
22317        dlg.begin(MethodInfo { id: "directory.domains.insert",
22318                               http_method: hyper::method::Method::Post });
22319        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
22320        params.push(("customer", self._customer.to_string()));
22321        for &field in ["alt", "customer"].iter() {
22322            if self._additional_params.contains_key(field) {
22323                dlg.finished(false);
22324                return Err(Error::FieldClash(field));
22325            }
22326        }
22327        for (name, value) in self._additional_params.iter() {
22328            params.push((&name, value.clone()));
22329        }
22330
22331        params.push(("alt", "json".to_string()));
22332
22333        let mut url = self.hub._base_url.clone() + "customer/{customer}/domains";
22334        if self._scopes.len() == 0 {
22335            self._scopes.insert(Scope::DirectoryDomain.as_ref().to_string(), ());
22336        }
22337
22338        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
22339            let mut replace_with: Option<&str> = None;
22340            for &(name, ref value) in params.iter() {
22341                if name == param_name {
22342                    replace_with = Some(value);
22343                    break;
22344                }
22345            }
22346            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
22347        }
22348        {
22349            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
22350            for param_name in ["customer"].iter() {
22351                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
22352                    indices_for_removal.push(index);
22353                }
22354            }
22355            for &index in indices_for_removal.iter() {
22356                params.remove(index);
22357            }
22358        }
22359
22360        let url = hyper::Url::parse_with_params(&url, params).unwrap();
22361
22362        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
22363        let mut request_value_reader =
22364            {
22365                let mut value = json::value::to_value(&self._request).expect("serde to work");
22366                remove_json_null_values(&mut value);
22367                let mut dst = io::Cursor::new(Vec::with_capacity(128));
22368                json::to_writer(&mut dst, &value).unwrap();
22369                dst
22370            };
22371        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
22372        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
22373
22374
22375        loop {
22376            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
22377                Ok(token) => token,
22378                Err(err) => {
22379                    match  dlg.token(&*err) {
22380                        Some(token) => token,
22381                        None => {
22382                            dlg.finished(false);
22383                            return Err(Error::MissingToken(err))
22384                        }
22385                    }
22386                }
22387            };
22388            let auth_header = Authorization(Bearer { token: token.access_token });
22389            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
22390            let mut req_result = {
22391                let mut client = &mut *self.hub.client.borrow_mut();
22392                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
22393                    .header(UserAgent(self.hub._user_agent.clone()))
22394                    .header(auth_header.clone())
22395                    .header(ContentType(json_mime_type.clone()))
22396                    .header(ContentLength(request_size as u64))
22397                    .body(&mut request_value_reader);
22398
22399                dlg.pre_request();
22400                req.send()
22401            };
22402
22403            match req_result {
22404                Err(err) => {
22405                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
22406                        sleep(d);
22407                        continue;
22408                    }
22409                    dlg.finished(false);
22410                    return Err(Error::HttpError(err))
22411                }
22412                Ok(mut res) => {
22413                    if !res.status.is_success() {
22414                        let mut json_err = String::new();
22415                        res.read_to_string(&mut json_err).unwrap();
22416                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
22417                                                              json::from_str(&json_err).ok(),
22418                                                              json::from_str(&json_err).ok()) {
22419                            sleep(d);
22420                            continue;
22421                        }
22422                        dlg.finished(false);
22423                        return match json::from_str::<ErrorResponse>(&json_err){
22424                            Err(_) => Err(Error::Failure(res)),
22425                            Ok(serr) => Err(Error::BadRequest(serr))
22426                        }
22427                    }
22428                    let result_value = {
22429                        let mut json_response = String::new();
22430                        res.read_to_string(&mut json_response).unwrap();
22431                        match json::from_str(&json_response) {
22432                            Ok(decoded) => (res, decoded),
22433                            Err(err) => {
22434                                dlg.response_json_decode_error(&json_response, &err);
22435                                return Err(Error::JsonDecodeError(json_response, err));
22436                            }
22437                        }
22438                    };
22439
22440                    dlg.finished(true);
22441                    return Ok(result_value)
22442                }
22443            }
22444        }
22445    }
22446
22447
22448    ///
22449    /// Sets the *request* property to the given value.
22450    ///
22451    /// Even though the property as already been set when instantiating this call,
22452    /// we provide this method for API completeness.
22453    pub fn request(mut self, new_value: Domains) -> DomainInsertCall<'a, C, A> {
22454        self._request = new_value;
22455        self
22456    }
22457    /// Immutable ID of the G Suite account.
22458    ///
22459    /// Sets the *customer* path property to the given value.
22460    ///
22461    /// Even though the property as already been set when instantiating this call,
22462    /// we provide this method for API completeness.
22463    pub fn customer(mut self, new_value: &str) -> DomainInsertCall<'a, C, A> {
22464        self._customer = new_value.to_string();
22465        self
22466    }
22467    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22468    /// while executing the actual API request.
22469    /// 
22470    /// It should be used to handle progress information, and to implement a certain level of resilience.
22471    ///
22472    /// Sets the *delegate* property to the given value.
22473    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainInsertCall<'a, C, A> {
22474        self._delegate = Some(new_value);
22475        self
22476    }
22477
22478    /// Set any additional parameter of the query string used in the request.
22479    /// It should be used to set parameters which are not yet available through their own
22480    /// setters.
22481    ///
22482    /// Please note that this method must not be used to set any of the known parameters
22483    /// which have their own setter method. If done anyway, the request will fail.
22484    ///
22485    /// # Additional Parameters
22486    ///
22487    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22488    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22489    /// * *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.
22490    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22491    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22492    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22493    /// * *alt* (query-string) - Data format for the response.
22494    pub fn param<T>(mut self, name: T, value: T) -> DomainInsertCall<'a, C, A>
22495                                                        where T: AsRef<str> {
22496        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
22497        self
22498    }
22499
22500    /// Identifies the authorization scope for the method you are building.
22501    ///
22502    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
22503    /// `Scope::DirectoryDomain`.
22504    ///
22505    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22506    /// tokens for more than one scope.
22507    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
22508    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
22509    /// function for details).
22510    ///
22511    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22512    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22513    /// sufficient, a read-write scope will do as well.
22514    pub fn add_scope<T, S>(mut self, scope: T) -> DomainInsertCall<'a, C, A>
22515                                                        where T: Into<Option<S>>,
22516                                                              S: AsRef<str> {
22517        match scope.into() {
22518          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
22519          None => None,
22520        };
22521        self
22522    }
22523}
22524
22525
22526/// Deletes a domain of the customer.
22527///
22528/// A builder for the *delete* method supported by a *domain* resource.
22529/// It is not used directly, but through a `DomainMethods` instance.
22530///
22531/// # Example
22532///
22533/// Instantiate a resource method builder
22534///
22535/// ```test_harness,no_run
22536/// # extern crate hyper;
22537/// # extern crate hyper_rustls;
22538/// # extern crate yup_oauth2 as oauth2;
22539/// # extern crate google_admin1_directory as admin1_directory;
22540/// # #[test] fn egal() {
22541/// # use std::default::Default;
22542/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
22543/// # use admin1_directory::Directory;
22544/// 
22545/// # let secret: ApplicationSecret = Default::default();
22546/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
22547/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
22548/// #                               <MemoryStorage as Default>::default(), None);
22549/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
22550/// // You can configure optional parameters by calling the respective setters at will, and
22551/// // execute the final call using `doit()`.
22552/// // Values shown here are possibly random and not representative !
22553/// let result = hub.domains().delete("customer", "domainName")
22554///              .doit();
22555/// # }
22556/// ```
22557pub struct DomainDeleteCall<'a, C, A>
22558    where C: 'a, A: 'a {
22559
22560    hub: &'a Directory<C, A>,
22561    _customer: String,
22562    _domain_name: String,
22563    _delegate: Option<&'a mut dyn Delegate>,
22564    _additional_params: HashMap<String, String>,
22565    _scopes: BTreeMap<String, ()>
22566}
22567
22568impl<'a, C, A> CallBuilder for DomainDeleteCall<'a, C, A> {}
22569
22570impl<'a, C, A> DomainDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
22571
22572
22573    /// Perform the operation you have build so far.
22574    pub fn doit(mut self) -> Result<hyper::client::Response> {
22575        use std::io::{Read, Seek};
22576        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
22577        let mut dd = DefaultDelegate;
22578        let mut dlg: &mut dyn Delegate = match self._delegate {
22579            Some(d) => d,
22580            None => &mut dd
22581        };
22582        dlg.begin(MethodInfo { id: "directory.domains.delete",
22583                               http_method: hyper::method::Method::Delete });
22584        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
22585        params.push(("customer", self._customer.to_string()));
22586        params.push(("domainName", self._domain_name.to_string()));
22587        for &field in ["customer", "domainName"].iter() {
22588            if self._additional_params.contains_key(field) {
22589                dlg.finished(false);
22590                return Err(Error::FieldClash(field));
22591            }
22592        }
22593        for (name, value) in self._additional_params.iter() {
22594            params.push((&name, value.clone()));
22595        }
22596
22597
22598        let mut url = self.hub._base_url.clone() + "customer/{customer}/domains/{domainName}";
22599        if self._scopes.len() == 0 {
22600            self._scopes.insert(Scope::DirectoryDomain.as_ref().to_string(), ());
22601        }
22602
22603        for &(find_this, param_name) in [("{customer}", "customer"), ("{domainName}", "domainName")].iter() {
22604            let mut replace_with: Option<&str> = None;
22605            for &(name, ref value) in params.iter() {
22606                if name == param_name {
22607                    replace_with = Some(value);
22608                    break;
22609                }
22610            }
22611            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
22612        }
22613        {
22614            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
22615            for param_name in ["domainName", "customer"].iter() {
22616                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
22617                    indices_for_removal.push(index);
22618                }
22619            }
22620            for &index in indices_for_removal.iter() {
22621                params.remove(index);
22622            }
22623        }
22624
22625        let url = hyper::Url::parse_with_params(&url, params).unwrap();
22626
22627
22628
22629        loop {
22630            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
22631                Ok(token) => token,
22632                Err(err) => {
22633                    match  dlg.token(&*err) {
22634                        Some(token) => token,
22635                        None => {
22636                            dlg.finished(false);
22637                            return Err(Error::MissingToken(err))
22638                        }
22639                    }
22640                }
22641            };
22642            let auth_header = Authorization(Bearer { token: token.access_token });
22643            let mut req_result = {
22644                let mut client = &mut *self.hub.client.borrow_mut();
22645                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
22646                    .header(UserAgent(self.hub._user_agent.clone()))
22647                    .header(auth_header.clone());
22648
22649                dlg.pre_request();
22650                req.send()
22651            };
22652
22653            match req_result {
22654                Err(err) => {
22655                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
22656                        sleep(d);
22657                        continue;
22658                    }
22659                    dlg.finished(false);
22660                    return Err(Error::HttpError(err))
22661                }
22662                Ok(mut res) => {
22663                    if !res.status.is_success() {
22664                        let mut json_err = String::new();
22665                        res.read_to_string(&mut json_err).unwrap();
22666                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
22667                                                              json::from_str(&json_err).ok(),
22668                                                              json::from_str(&json_err).ok()) {
22669                            sleep(d);
22670                            continue;
22671                        }
22672                        dlg.finished(false);
22673                        return match json::from_str::<ErrorResponse>(&json_err){
22674                            Err(_) => Err(Error::Failure(res)),
22675                            Ok(serr) => Err(Error::BadRequest(serr))
22676                        }
22677                    }
22678                    let result_value = res;
22679
22680                    dlg.finished(true);
22681                    return Ok(result_value)
22682                }
22683            }
22684        }
22685    }
22686
22687
22688    /// Immutable ID of the G Suite account.
22689    ///
22690    /// Sets the *customer* path property to the given value.
22691    ///
22692    /// Even though the property as already been set when instantiating this call,
22693    /// we provide this method for API completeness.
22694    pub fn customer(mut self, new_value: &str) -> DomainDeleteCall<'a, C, A> {
22695        self._customer = new_value.to_string();
22696        self
22697    }
22698    /// Name of domain to be deleted
22699    ///
22700    /// Sets the *domain name* path property to the given value.
22701    ///
22702    /// Even though the property as already been set when instantiating this call,
22703    /// we provide this method for API completeness.
22704    pub fn domain_name(mut self, new_value: &str) -> DomainDeleteCall<'a, C, A> {
22705        self._domain_name = new_value.to_string();
22706        self
22707    }
22708    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22709    /// while executing the actual API request.
22710    /// 
22711    /// It should be used to handle progress information, and to implement a certain level of resilience.
22712    ///
22713    /// Sets the *delegate* property to the given value.
22714    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainDeleteCall<'a, C, A> {
22715        self._delegate = Some(new_value);
22716        self
22717    }
22718
22719    /// Set any additional parameter of the query string used in the request.
22720    /// It should be used to set parameters which are not yet available through their own
22721    /// setters.
22722    ///
22723    /// Please note that this method must not be used to set any of the known parameters
22724    /// which have their own setter method. If done anyway, the request will fail.
22725    ///
22726    /// # Additional Parameters
22727    ///
22728    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22729    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22730    /// * *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.
22731    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22732    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22733    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22734    /// * *alt* (query-string) - Data format for the response.
22735    pub fn param<T>(mut self, name: T, value: T) -> DomainDeleteCall<'a, C, A>
22736                                                        where T: AsRef<str> {
22737        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
22738        self
22739    }
22740
22741    /// Identifies the authorization scope for the method you are building.
22742    ///
22743    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
22744    /// `Scope::DirectoryDomain`.
22745    ///
22746    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22747    /// tokens for more than one scope.
22748    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
22749    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
22750    /// function for details).
22751    ///
22752    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22753    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22754    /// sufficient, a read-write scope will do as well.
22755    pub fn add_scope<T, S>(mut self, scope: T) -> DomainDeleteCall<'a, C, A>
22756                                                        where T: Into<Option<S>>,
22757                                                              S: AsRef<str> {
22758        match scope.into() {
22759          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
22760          None => None,
22761        };
22762        self
22763    }
22764}
22765
22766
22767/// Inserts a Domain alias of the customer.
22768///
22769/// A builder for the *insert* method supported by a *domainAliase* resource.
22770/// It is not used directly, but through a `DomainAliaseMethods` instance.
22771///
22772/// # Example
22773///
22774/// Instantiate a resource method builder
22775///
22776/// ```test_harness,no_run
22777/// # extern crate hyper;
22778/// # extern crate hyper_rustls;
22779/// # extern crate yup_oauth2 as oauth2;
22780/// # extern crate google_admin1_directory as admin1_directory;
22781/// use admin1_directory::DomainAlias;
22782/// # #[test] fn egal() {
22783/// # use std::default::Default;
22784/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
22785/// # use admin1_directory::Directory;
22786/// 
22787/// # let secret: ApplicationSecret = Default::default();
22788/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
22789/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
22790/// #                               <MemoryStorage as Default>::default(), None);
22791/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
22792/// // As the method needs a request, you would usually fill it with the desired information
22793/// // into the respective structure. Some of the parts shown here might not be applicable !
22794/// // Values shown here are possibly random and not representative !
22795/// let mut req = DomainAlias::default();
22796/// 
22797/// // You can configure optional parameters by calling the respective setters at will, and
22798/// // execute the final call using `doit()`.
22799/// // Values shown here are possibly random and not representative !
22800/// let result = hub.domain_aliases().insert(req, "customer")
22801///              .doit();
22802/// # }
22803/// ```
22804pub struct DomainAliaseInsertCall<'a, C, A>
22805    where C: 'a, A: 'a {
22806
22807    hub: &'a Directory<C, A>,
22808    _request: DomainAlias,
22809    _customer: String,
22810    _delegate: Option<&'a mut dyn Delegate>,
22811    _additional_params: HashMap<String, String>,
22812    _scopes: BTreeMap<String, ()>
22813}
22814
22815impl<'a, C, A> CallBuilder for DomainAliaseInsertCall<'a, C, A> {}
22816
22817impl<'a, C, A> DomainAliaseInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
22818
22819
22820    /// Perform the operation you have build so far.
22821    pub fn doit(mut self) -> Result<(hyper::client::Response, DomainAlias)> {
22822        use std::io::{Read, Seek};
22823        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
22824        let mut dd = DefaultDelegate;
22825        let mut dlg: &mut dyn Delegate = match self._delegate {
22826            Some(d) => d,
22827            None => &mut dd
22828        };
22829        dlg.begin(MethodInfo { id: "directory.domainAliases.insert",
22830                               http_method: hyper::method::Method::Post });
22831        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
22832        params.push(("customer", self._customer.to_string()));
22833        for &field in ["alt", "customer"].iter() {
22834            if self._additional_params.contains_key(field) {
22835                dlg.finished(false);
22836                return Err(Error::FieldClash(field));
22837            }
22838        }
22839        for (name, value) in self._additional_params.iter() {
22840            params.push((&name, value.clone()));
22841        }
22842
22843        params.push(("alt", "json".to_string()));
22844
22845        let mut url = self.hub._base_url.clone() + "customer/{customer}/domainaliases";
22846        if self._scopes.len() == 0 {
22847            self._scopes.insert(Scope::DirectoryDomain.as_ref().to_string(), ());
22848        }
22849
22850        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
22851            let mut replace_with: Option<&str> = None;
22852            for &(name, ref value) in params.iter() {
22853                if name == param_name {
22854                    replace_with = Some(value);
22855                    break;
22856                }
22857            }
22858            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
22859        }
22860        {
22861            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
22862            for param_name in ["customer"].iter() {
22863                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
22864                    indices_for_removal.push(index);
22865                }
22866            }
22867            for &index in indices_for_removal.iter() {
22868                params.remove(index);
22869            }
22870        }
22871
22872        let url = hyper::Url::parse_with_params(&url, params).unwrap();
22873
22874        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
22875        let mut request_value_reader =
22876            {
22877                let mut value = json::value::to_value(&self._request).expect("serde to work");
22878                remove_json_null_values(&mut value);
22879                let mut dst = io::Cursor::new(Vec::with_capacity(128));
22880                json::to_writer(&mut dst, &value).unwrap();
22881                dst
22882            };
22883        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
22884        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
22885
22886
22887        loop {
22888            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
22889                Ok(token) => token,
22890                Err(err) => {
22891                    match  dlg.token(&*err) {
22892                        Some(token) => token,
22893                        None => {
22894                            dlg.finished(false);
22895                            return Err(Error::MissingToken(err))
22896                        }
22897                    }
22898                }
22899            };
22900            let auth_header = Authorization(Bearer { token: token.access_token });
22901            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
22902            let mut req_result = {
22903                let mut client = &mut *self.hub.client.borrow_mut();
22904                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
22905                    .header(UserAgent(self.hub._user_agent.clone()))
22906                    .header(auth_header.clone())
22907                    .header(ContentType(json_mime_type.clone()))
22908                    .header(ContentLength(request_size as u64))
22909                    .body(&mut request_value_reader);
22910
22911                dlg.pre_request();
22912                req.send()
22913            };
22914
22915            match req_result {
22916                Err(err) => {
22917                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
22918                        sleep(d);
22919                        continue;
22920                    }
22921                    dlg.finished(false);
22922                    return Err(Error::HttpError(err))
22923                }
22924                Ok(mut res) => {
22925                    if !res.status.is_success() {
22926                        let mut json_err = String::new();
22927                        res.read_to_string(&mut json_err).unwrap();
22928                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
22929                                                              json::from_str(&json_err).ok(),
22930                                                              json::from_str(&json_err).ok()) {
22931                            sleep(d);
22932                            continue;
22933                        }
22934                        dlg.finished(false);
22935                        return match json::from_str::<ErrorResponse>(&json_err){
22936                            Err(_) => Err(Error::Failure(res)),
22937                            Ok(serr) => Err(Error::BadRequest(serr))
22938                        }
22939                    }
22940                    let result_value = {
22941                        let mut json_response = String::new();
22942                        res.read_to_string(&mut json_response).unwrap();
22943                        match json::from_str(&json_response) {
22944                            Ok(decoded) => (res, decoded),
22945                            Err(err) => {
22946                                dlg.response_json_decode_error(&json_response, &err);
22947                                return Err(Error::JsonDecodeError(json_response, err));
22948                            }
22949                        }
22950                    };
22951
22952                    dlg.finished(true);
22953                    return Ok(result_value)
22954                }
22955            }
22956        }
22957    }
22958
22959
22960    ///
22961    /// Sets the *request* property to the given value.
22962    ///
22963    /// Even though the property as already been set when instantiating this call,
22964    /// we provide this method for API completeness.
22965    pub fn request(mut self, new_value: DomainAlias) -> DomainAliaseInsertCall<'a, C, A> {
22966        self._request = new_value;
22967        self
22968    }
22969    /// Immutable ID of the G Suite account.
22970    ///
22971    /// Sets the *customer* path property to the given value.
22972    ///
22973    /// Even though the property as already been set when instantiating this call,
22974    /// we provide this method for API completeness.
22975    pub fn customer(mut self, new_value: &str) -> DomainAliaseInsertCall<'a, C, A> {
22976        self._customer = new_value.to_string();
22977        self
22978    }
22979    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22980    /// while executing the actual API request.
22981    /// 
22982    /// It should be used to handle progress information, and to implement a certain level of resilience.
22983    ///
22984    /// Sets the *delegate* property to the given value.
22985    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainAliaseInsertCall<'a, C, A> {
22986        self._delegate = Some(new_value);
22987        self
22988    }
22989
22990    /// Set any additional parameter of the query string used in the request.
22991    /// It should be used to set parameters which are not yet available through their own
22992    /// setters.
22993    ///
22994    /// Please note that this method must not be used to set any of the known parameters
22995    /// which have their own setter method. If done anyway, the request will fail.
22996    ///
22997    /// # Additional Parameters
22998    ///
22999    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23000    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23001    /// * *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.
23002    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23003    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23004    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23005    /// * *alt* (query-string) - Data format for the response.
23006    pub fn param<T>(mut self, name: T, value: T) -> DomainAliaseInsertCall<'a, C, A>
23007                                                        where T: AsRef<str> {
23008        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
23009        self
23010    }
23011
23012    /// Identifies the authorization scope for the method you are building.
23013    ///
23014    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
23015    /// `Scope::DirectoryDomain`.
23016    ///
23017    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23018    /// tokens for more than one scope.
23019    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
23020    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
23021    /// function for details).
23022    ///
23023    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23024    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23025    /// sufficient, a read-write scope will do as well.
23026    pub fn add_scope<T, S>(mut self, scope: T) -> DomainAliaseInsertCall<'a, C, A>
23027                                                        where T: Into<Option<S>>,
23028                                                              S: AsRef<str> {
23029        match scope.into() {
23030          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
23031          None => None,
23032        };
23033        self
23034    }
23035}
23036
23037
23038/// Retrieves a domain alias of the customer.
23039///
23040/// A builder for the *get* method supported by a *domainAliase* resource.
23041/// It is not used directly, but through a `DomainAliaseMethods` instance.
23042///
23043/// # Example
23044///
23045/// Instantiate a resource method builder
23046///
23047/// ```test_harness,no_run
23048/// # extern crate hyper;
23049/// # extern crate hyper_rustls;
23050/// # extern crate yup_oauth2 as oauth2;
23051/// # extern crate google_admin1_directory as admin1_directory;
23052/// # #[test] fn egal() {
23053/// # use std::default::Default;
23054/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
23055/// # use admin1_directory::Directory;
23056/// 
23057/// # let secret: ApplicationSecret = Default::default();
23058/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
23059/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
23060/// #                               <MemoryStorage as Default>::default(), None);
23061/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
23062/// // You can configure optional parameters by calling the respective setters at will, and
23063/// // execute the final call using `doit()`.
23064/// // Values shown here are possibly random and not representative !
23065/// let result = hub.domain_aliases().get("customer", "domainAliasName")
23066///              .doit();
23067/// # }
23068/// ```
23069pub struct DomainAliaseGetCall<'a, C, A>
23070    where C: 'a, A: 'a {
23071
23072    hub: &'a Directory<C, A>,
23073    _customer: String,
23074    _domain_alias_name: String,
23075    _delegate: Option<&'a mut dyn Delegate>,
23076    _additional_params: HashMap<String, String>,
23077    _scopes: BTreeMap<String, ()>
23078}
23079
23080impl<'a, C, A> CallBuilder for DomainAliaseGetCall<'a, C, A> {}
23081
23082impl<'a, C, A> DomainAliaseGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
23083
23084
23085    /// Perform the operation you have build so far.
23086    pub fn doit(mut self) -> Result<(hyper::client::Response, DomainAlias)> {
23087        use std::io::{Read, Seek};
23088        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
23089        let mut dd = DefaultDelegate;
23090        let mut dlg: &mut dyn Delegate = match self._delegate {
23091            Some(d) => d,
23092            None => &mut dd
23093        };
23094        dlg.begin(MethodInfo { id: "directory.domainAliases.get",
23095                               http_method: hyper::method::Method::Get });
23096        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
23097        params.push(("customer", self._customer.to_string()));
23098        params.push(("domainAliasName", self._domain_alias_name.to_string()));
23099        for &field in ["alt", "customer", "domainAliasName"].iter() {
23100            if self._additional_params.contains_key(field) {
23101                dlg.finished(false);
23102                return Err(Error::FieldClash(field));
23103            }
23104        }
23105        for (name, value) in self._additional_params.iter() {
23106            params.push((&name, value.clone()));
23107        }
23108
23109        params.push(("alt", "json".to_string()));
23110
23111        let mut url = self.hub._base_url.clone() + "customer/{customer}/domainaliases/{domainAliasName}";
23112        if self._scopes.len() == 0 {
23113            self._scopes.insert(Scope::DirectoryDomainReadonly.as_ref().to_string(), ());
23114        }
23115
23116        for &(find_this, param_name) in [("{customer}", "customer"), ("{domainAliasName}", "domainAliasName")].iter() {
23117            let mut replace_with: Option<&str> = None;
23118            for &(name, ref value) in params.iter() {
23119                if name == param_name {
23120                    replace_with = Some(value);
23121                    break;
23122                }
23123            }
23124            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
23125        }
23126        {
23127            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
23128            for param_name in ["domainAliasName", "customer"].iter() {
23129                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
23130                    indices_for_removal.push(index);
23131                }
23132            }
23133            for &index in indices_for_removal.iter() {
23134                params.remove(index);
23135            }
23136        }
23137
23138        let url = hyper::Url::parse_with_params(&url, params).unwrap();
23139
23140
23141
23142        loop {
23143            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
23144                Ok(token) => token,
23145                Err(err) => {
23146                    match  dlg.token(&*err) {
23147                        Some(token) => token,
23148                        None => {
23149                            dlg.finished(false);
23150                            return Err(Error::MissingToken(err))
23151                        }
23152                    }
23153                }
23154            };
23155            let auth_header = Authorization(Bearer { token: token.access_token });
23156            let mut req_result = {
23157                let mut client = &mut *self.hub.client.borrow_mut();
23158                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
23159                    .header(UserAgent(self.hub._user_agent.clone()))
23160                    .header(auth_header.clone());
23161
23162                dlg.pre_request();
23163                req.send()
23164            };
23165
23166            match req_result {
23167                Err(err) => {
23168                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
23169                        sleep(d);
23170                        continue;
23171                    }
23172                    dlg.finished(false);
23173                    return Err(Error::HttpError(err))
23174                }
23175                Ok(mut res) => {
23176                    if !res.status.is_success() {
23177                        let mut json_err = String::new();
23178                        res.read_to_string(&mut json_err).unwrap();
23179                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
23180                                                              json::from_str(&json_err).ok(),
23181                                                              json::from_str(&json_err).ok()) {
23182                            sleep(d);
23183                            continue;
23184                        }
23185                        dlg.finished(false);
23186                        return match json::from_str::<ErrorResponse>(&json_err){
23187                            Err(_) => Err(Error::Failure(res)),
23188                            Ok(serr) => Err(Error::BadRequest(serr))
23189                        }
23190                    }
23191                    let result_value = {
23192                        let mut json_response = String::new();
23193                        res.read_to_string(&mut json_response).unwrap();
23194                        match json::from_str(&json_response) {
23195                            Ok(decoded) => (res, decoded),
23196                            Err(err) => {
23197                                dlg.response_json_decode_error(&json_response, &err);
23198                                return Err(Error::JsonDecodeError(json_response, err));
23199                            }
23200                        }
23201                    };
23202
23203                    dlg.finished(true);
23204                    return Ok(result_value)
23205                }
23206            }
23207        }
23208    }
23209
23210
23211    /// Immutable ID of the G Suite account.
23212    ///
23213    /// Sets the *customer* path property to the given value.
23214    ///
23215    /// Even though the property as already been set when instantiating this call,
23216    /// we provide this method for API completeness.
23217    pub fn customer(mut self, new_value: &str) -> DomainAliaseGetCall<'a, C, A> {
23218        self._customer = new_value.to_string();
23219        self
23220    }
23221    /// Name of domain alias to be retrieved.
23222    ///
23223    /// Sets the *domain alias name* path property to the given value.
23224    ///
23225    /// Even though the property as already been set when instantiating this call,
23226    /// we provide this method for API completeness.
23227    pub fn domain_alias_name(mut self, new_value: &str) -> DomainAliaseGetCall<'a, C, A> {
23228        self._domain_alias_name = new_value.to_string();
23229        self
23230    }
23231    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23232    /// while executing the actual API request.
23233    /// 
23234    /// It should be used to handle progress information, and to implement a certain level of resilience.
23235    ///
23236    /// Sets the *delegate* property to the given value.
23237    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainAliaseGetCall<'a, C, A> {
23238        self._delegate = Some(new_value);
23239        self
23240    }
23241
23242    /// Set any additional parameter of the query string used in the request.
23243    /// It should be used to set parameters which are not yet available through their own
23244    /// setters.
23245    ///
23246    /// Please note that this method must not be used to set any of the known parameters
23247    /// which have their own setter method. If done anyway, the request will fail.
23248    ///
23249    /// # Additional Parameters
23250    ///
23251    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23252    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23253    /// * *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.
23254    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23255    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23256    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23257    /// * *alt* (query-string) - Data format for the response.
23258    pub fn param<T>(mut self, name: T, value: T) -> DomainAliaseGetCall<'a, C, A>
23259                                                        where T: AsRef<str> {
23260        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
23261        self
23262    }
23263
23264    /// Identifies the authorization scope for the method you are building.
23265    ///
23266    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
23267    /// `Scope::DirectoryDomainReadonly`.
23268    ///
23269    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23270    /// tokens for more than one scope.
23271    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
23272    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
23273    /// function for details).
23274    ///
23275    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23276    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23277    /// sufficient, a read-write scope will do as well.
23278    pub fn add_scope<T, S>(mut self, scope: T) -> DomainAliaseGetCall<'a, C, A>
23279                                                        where T: Into<Option<S>>,
23280                                                              S: AsRef<str> {
23281        match scope.into() {
23282          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
23283          None => None,
23284        };
23285        self
23286    }
23287}
23288
23289
23290/// Lists the domain aliases of the customer.
23291///
23292/// A builder for the *list* method supported by a *domainAliase* resource.
23293/// It is not used directly, but through a `DomainAliaseMethods` instance.
23294///
23295/// # Example
23296///
23297/// Instantiate a resource method builder
23298///
23299/// ```test_harness,no_run
23300/// # extern crate hyper;
23301/// # extern crate hyper_rustls;
23302/// # extern crate yup_oauth2 as oauth2;
23303/// # extern crate google_admin1_directory as admin1_directory;
23304/// # #[test] fn egal() {
23305/// # use std::default::Default;
23306/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
23307/// # use admin1_directory::Directory;
23308/// 
23309/// # let secret: ApplicationSecret = Default::default();
23310/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
23311/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
23312/// #                               <MemoryStorage as Default>::default(), None);
23313/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
23314/// // You can configure optional parameters by calling the respective setters at will, and
23315/// // execute the final call using `doit()`.
23316/// // Values shown here are possibly random and not representative !
23317/// let result = hub.domain_aliases().list("customer")
23318///              .parent_domain_name("vero")
23319///              .doit();
23320/// # }
23321/// ```
23322pub struct DomainAliaseListCall<'a, C, A>
23323    where C: 'a, A: 'a {
23324
23325    hub: &'a Directory<C, A>,
23326    _customer: String,
23327    _parent_domain_name: Option<String>,
23328    _delegate: Option<&'a mut dyn Delegate>,
23329    _additional_params: HashMap<String, String>,
23330    _scopes: BTreeMap<String, ()>
23331}
23332
23333impl<'a, C, A> CallBuilder for DomainAliaseListCall<'a, C, A> {}
23334
23335impl<'a, C, A> DomainAliaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
23336
23337
23338    /// Perform the operation you have build so far.
23339    pub fn doit(mut self) -> Result<(hyper::client::Response, DomainAliases)> {
23340        use std::io::{Read, Seek};
23341        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
23342        let mut dd = DefaultDelegate;
23343        let mut dlg: &mut dyn Delegate = match self._delegate {
23344            Some(d) => d,
23345            None => &mut dd
23346        };
23347        dlg.begin(MethodInfo { id: "directory.domainAliases.list",
23348                               http_method: hyper::method::Method::Get });
23349        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
23350        params.push(("customer", self._customer.to_string()));
23351        if let Some(value) = self._parent_domain_name {
23352            params.push(("parentDomainName", value.to_string()));
23353        }
23354        for &field in ["alt", "customer", "parentDomainName"].iter() {
23355            if self._additional_params.contains_key(field) {
23356                dlg.finished(false);
23357                return Err(Error::FieldClash(field));
23358            }
23359        }
23360        for (name, value) in self._additional_params.iter() {
23361            params.push((&name, value.clone()));
23362        }
23363
23364        params.push(("alt", "json".to_string()));
23365
23366        let mut url = self.hub._base_url.clone() + "customer/{customer}/domainaliases";
23367        if self._scopes.len() == 0 {
23368            self._scopes.insert(Scope::DirectoryDomainReadonly.as_ref().to_string(), ());
23369        }
23370
23371        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
23372            let mut replace_with: Option<&str> = None;
23373            for &(name, ref value) in params.iter() {
23374                if name == param_name {
23375                    replace_with = Some(value);
23376                    break;
23377                }
23378            }
23379            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
23380        }
23381        {
23382            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
23383            for param_name in ["customer"].iter() {
23384                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
23385                    indices_for_removal.push(index);
23386                }
23387            }
23388            for &index in indices_for_removal.iter() {
23389                params.remove(index);
23390            }
23391        }
23392
23393        let url = hyper::Url::parse_with_params(&url, params).unwrap();
23394
23395
23396
23397        loop {
23398            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
23399                Ok(token) => token,
23400                Err(err) => {
23401                    match  dlg.token(&*err) {
23402                        Some(token) => token,
23403                        None => {
23404                            dlg.finished(false);
23405                            return Err(Error::MissingToken(err))
23406                        }
23407                    }
23408                }
23409            };
23410            let auth_header = Authorization(Bearer { token: token.access_token });
23411            let mut req_result = {
23412                let mut client = &mut *self.hub.client.borrow_mut();
23413                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
23414                    .header(UserAgent(self.hub._user_agent.clone()))
23415                    .header(auth_header.clone());
23416
23417                dlg.pre_request();
23418                req.send()
23419            };
23420
23421            match req_result {
23422                Err(err) => {
23423                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
23424                        sleep(d);
23425                        continue;
23426                    }
23427                    dlg.finished(false);
23428                    return Err(Error::HttpError(err))
23429                }
23430                Ok(mut res) => {
23431                    if !res.status.is_success() {
23432                        let mut json_err = String::new();
23433                        res.read_to_string(&mut json_err).unwrap();
23434                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
23435                                                              json::from_str(&json_err).ok(),
23436                                                              json::from_str(&json_err).ok()) {
23437                            sleep(d);
23438                            continue;
23439                        }
23440                        dlg.finished(false);
23441                        return match json::from_str::<ErrorResponse>(&json_err){
23442                            Err(_) => Err(Error::Failure(res)),
23443                            Ok(serr) => Err(Error::BadRequest(serr))
23444                        }
23445                    }
23446                    let result_value = {
23447                        let mut json_response = String::new();
23448                        res.read_to_string(&mut json_response).unwrap();
23449                        match json::from_str(&json_response) {
23450                            Ok(decoded) => (res, decoded),
23451                            Err(err) => {
23452                                dlg.response_json_decode_error(&json_response, &err);
23453                                return Err(Error::JsonDecodeError(json_response, err));
23454                            }
23455                        }
23456                    };
23457
23458                    dlg.finished(true);
23459                    return Ok(result_value)
23460                }
23461            }
23462        }
23463    }
23464
23465
23466    /// Immutable ID of the G Suite account.
23467    ///
23468    /// Sets the *customer* path property to the given value.
23469    ///
23470    /// Even though the property as already been set when instantiating this call,
23471    /// we provide this method for API completeness.
23472    pub fn customer(mut self, new_value: &str) -> DomainAliaseListCall<'a, C, A> {
23473        self._customer = new_value.to_string();
23474        self
23475    }
23476    /// Name of the parent domain for which domain aliases are to be fetched.
23477    ///
23478    /// Sets the *parent domain name* query property to the given value.
23479    pub fn parent_domain_name(mut self, new_value: &str) -> DomainAliaseListCall<'a, C, A> {
23480        self._parent_domain_name = Some(new_value.to_string());
23481        self
23482    }
23483    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23484    /// while executing the actual API request.
23485    /// 
23486    /// It should be used to handle progress information, and to implement a certain level of resilience.
23487    ///
23488    /// Sets the *delegate* property to the given value.
23489    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainAliaseListCall<'a, C, A> {
23490        self._delegate = Some(new_value);
23491        self
23492    }
23493
23494    /// Set any additional parameter of the query string used in the request.
23495    /// It should be used to set parameters which are not yet available through their own
23496    /// setters.
23497    ///
23498    /// Please note that this method must not be used to set any of the known parameters
23499    /// which have their own setter method. If done anyway, the request will fail.
23500    ///
23501    /// # Additional Parameters
23502    ///
23503    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23504    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23505    /// * *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.
23506    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23507    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23508    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23509    /// * *alt* (query-string) - Data format for the response.
23510    pub fn param<T>(mut self, name: T, value: T) -> DomainAliaseListCall<'a, C, A>
23511                                                        where T: AsRef<str> {
23512        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
23513        self
23514    }
23515
23516    /// Identifies the authorization scope for the method you are building.
23517    ///
23518    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
23519    /// `Scope::DirectoryDomainReadonly`.
23520    ///
23521    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23522    /// tokens for more than one scope.
23523    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
23524    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
23525    /// function for details).
23526    ///
23527    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23528    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23529    /// sufficient, a read-write scope will do as well.
23530    pub fn add_scope<T, S>(mut self, scope: T) -> DomainAliaseListCall<'a, C, A>
23531                                                        where T: Into<Option<S>>,
23532                                                              S: AsRef<str> {
23533        match scope.into() {
23534          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
23535          None => None,
23536        };
23537        self
23538    }
23539}
23540
23541
23542/// Deletes a Domain Alias of the customer.
23543///
23544/// A builder for the *delete* method supported by a *domainAliase* resource.
23545/// It is not used directly, but through a `DomainAliaseMethods` instance.
23546///
23547/// # Example
23548///
23549/// Instantiate a resource method builder
23550///
23551/// ```test_harness,no_run
23552/// # extern crate hyper;
23553/// # extern crate hyper_rustls;
23554/// # extern crate yup_oauth2 as oauth2;
23555/// # extern crate google_admin1_directory as admin1_directory;
23556/// # #[test] fn egal() {
23557/// # use std::default::Default;
23558/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
23559/// # use admin1_directory::Directory;
23560/// 
23561/// # let secret: ApplicationSecret = Default::default();
23562/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
23563/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
23564/// #                               <MemoryStorage as Default>::default(), None);
23565/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
23566/// // You can configure optional parameters by calling the respective setters at will, and
23567/// // execute the final call using `doit()`.
23568/// // Values shown here are possibly random and not representative !
23569/// let result = hub.domain_aliases().delete("customer", "domainAliasName")
23570///              .doit();
23571/// # }
23572/// ```
23573pub struct DomainAliaseDeleteCall<'a, C, A>
23574    where C: 'a, A: 'a {
23575
23576    hub: &'a Directory<C, A>,
23577    _customer: String,
23578    _domain_alias_name: String,
23579    _delegate: Option<&'a mut dyn Delegate>,
23580    _additional_params: HashMap<String, String>,
23581    _scopes: BTreeMap<String, ()>
23582}
23583
23584impl<'a, C, A> CallBuilder for DomainAliaseDeleteCall<'a, C, A> {}
23585
23586impl<'a, C, A> DomainAliaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
23587
23588
23589    /// Perform the operation you have build so far.
23590    pub fn doit(mut self) -> Result<hyper::client::Response> {
23591        use std::io::{Read, Seek};
23592        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
23593        let mut dd = DefaultDelegate;
23594        let mut dlg: &mut dyn Delegate = match self._delegate {
23595            Some(d) => d,
23596            None => &mut dd
23597        };
23598        dlg.begin(MethodInfo { id: "directory.domainAliases.delete",
23599                               http_method: hyper::method::Method::Delete });
23600        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
23601        params.push(("customer", self._customer.to_string()));
23602        params.push(("domainAliasName", self._domain_alias_name.to_string()));
23603        for &field in ["customer", "domainAliasName"].iter() {
23604            if self._additional_params.contains_key(field) {
23605                dlg.finished(false);
23606                return Err(Error::FieldClash(field));
23607            }
23608        }
23609        for (name, value) in self._additional_params.iter() {
23610            params.push((&name, value.clone()));
23611        }
23612
23613
23614        let mut url = self.hub._base_url.clone() + "customer/{customer}/domainaliases/{domainAliasName}";
23615        if self._scopes.len() == 0 {
23616            self._scopes.insert(Scope::DirectoryDomain.as_ref().to_string(), ());
23617        }
23618
23619        for &(find_this, param_name) in [("{customer}", "customer"), ("{domainAliasName}", "domainAliasName")].iter() {
23620            let mut replace_with: Option<&str> = None;
23621            for &(name, ref value) in params.iter() {
23622                if name == param_name {
23623                    replace_with = Some(value);
23624                    break;
23625                }
23626            }
23627            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
23628        }
23629        {
23630            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
23631            for param_name in ["domainAliasName", "customer"].iter() {
23632                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
23633                    indices_for_removal.push(index);
23634                }
23635            }
23636            for &index in indices_for_removal.iter() {
23637                params.remove(index);
23638            }
23639        }
23640
23641        let url = hyper::Url::parse_with_params(&url, params).unwrap();
23642
23643
23644
23645        loop {
23646            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
23647                Ok(token) => token,
23648                Err(err) => {
23649                    match  dlg.token(&*err) {
23650                        Some(token) => token,
23651                        None => {
23652                            dlg.finished(false);
23653                            return Err(Error::MissingToken(err))
23654                        }
23655                    }
23656                }
23657            };
23658            let auth_header = Authorization(Bearer { token: token.access_token });
23659            let mut req_result = {
23660                let mut client = &mut *self.hub.client.borrow_mut();
23661                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
23662                    .header(UserAgent(self.hub._user_agent.clone()))
23663                    .header(auth_header.clone());
23664
23665                dlg.pre_request();
23666                req.send()
23667            };
23668
23669            match req_result {
23670                Err(err) => {
23671                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
23672                        sleep(d);
23673                        continue;
23674                    }
23675                    dlg.finished(false);
23676                    return Err(Error::HttpError(err))
23677                }
23678                Ok(mut res) => {
23679                    if !res.status.is_success() {
23680                        let mut json_err = String::new();
23681                        res.read_to_string(&mut json_err).unwrap();
23682                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
23683                                                              json::from_str(&json_err).ok(),
23684                                                              json::from_str(&json_err).ok()) {
23685                            sleep(d);
23686                            continue;
23687                        }
23688                        dlg.finished(false);
23689                        return match json::from_str::<ErrorResponse>(&json_err){
23690                            Err(_) => Err(Error::Failure(res)),
23691                            Ok(serr) => Err(Error::BadRequest(serr))
23692                        }
23693                    }
23694                    let result_value = res;
23695
23696                    dlg.finished(true);
23697                    return Ok(result_value)
23698                }
23699            }
23700        }
23701    }
23702
23703
23704    /// Immutable ID of the G Suite account.
23705    ///
23706    /// Sets the *customer* path property to the given value.
23707    ///
23708    /// Even though the property as already been set when instantiating this call,
23709    /// we provide this method for API completeness.
23710    pub fn customer(mut self, new_value: &str) -> DomainAliaseDeleteCall<'a, C, A> {
23711        self._customer = new_value.to_string();
23712        self
23713    }
23714    /// Name of domain alias to be retrieved.
23715    ///
23716    /// Sets the *domain alias name* path property to the given value.
23717    ///
23718    /// Even though the property as already been set when instantiating this call,
23719    /// we provide this method for API completeness.
23720    pub fn domain_alias_name(mut self, new_value: &str) -> DomainAliaseDeleteCall<'a, C, A> {
23721        self._domain_alias_name = new_value.to_string();
23722        self
23723    }
23724    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23725    /// while executing the actual API request.
23726    /// 
23727    /// It should be used to handle progress information, and to implement a certain level of resilience.
23728    ///
23729    /// Sets the *delegate* property to the given value.
23730    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> DomainAliaseDeleteCall<'a, C, A> {
23731        self._delegate = Some(new_value);
23732        self
23733    }
23734
23735    /// Set any additional parameter of the query string used in the request.
23736    /// It should be used to set parameters which are not yet available through their own
23737    /// setters.
23738    ///
23739    /// Please note that this method must not be used to set any of the known parameters
23740    /// which have their own setter method. If done anyway, the request will fail.
23741    ///
23742    /// # Additional Parameters
23743    ///
23744    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23745    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23746    /// * *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.
23747    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23748    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23749    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23750    /// * *alt* (query-string) - Data format for the response.
23751    pub fn param<T>(mut self, name: T, value: T) -> DomainAliaseDeleteCall<'a, C, A>
23752                                                        where T: AsRef<str> {
23753        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
23754        self
23755    }
23756
23757    /// Identifies the authorization scope for the method you are building.
23758    ///
23759    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
23760    /// `Scope::DirectoryDomain`.
23761    ///
23762    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23763    /// tokens for more than one scope.
23764    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
23765    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
23766    /// function for details).
23767    ///
23768    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23769    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23770    /// sufficient, a read-write scope will do as well.
23771    pub fn add_scope<T, S>(mut self, scope: T) -> DomainAliaseDeleteCall<'a, C, A>
23772                                                        where T: Into<Option<S>>,
23773                                                              S: AsRef<str> {
23774        match scope.into() {
23775          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
23776          None => None,
23777        };
23778        self
23779    }
23780}
23781
23782
23783/// Retrieve schema
23784///
23785/// A builder for the *get* method supported by a *schema* resource.
23786/// It is not used directly, but through a `SchemaMethods` instance.
23787///
23788/// # Example
23789///
23790/// Instantiate a resource method builder
23791///
23792/// ```test_harness,no_run
23793/// # extern crate hyper;
23794/// # extern crate hyper_rustls;
23795/// # extern crate yup_oauth2 as oauth2;
23796/// # extern crate google_admin1_directory as admin1_directory;
23797/// # #[test] fn egal() {
23798/// # use std::default::Default;
23799/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
23800/// # use admin1_directory::Directory;
23801/// 
23802/// # let secret: ApplicationSecret = Default::default();
23803/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
23804/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
23805/// #                               <MemoryStorage as Default>::default(), None);
23806/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
23807/// // You can configure optional parameters by calling the respective setters at will, and
23808/// // execute the final call using `doit()`.
23809/// // Values shown here are possibly random and not representative !
23810/// let result = hub.schemas().get("customerId", "schemaKey")
23811///              .doit();
23812/// # }
23813/// ```
23814pub struct SchemaGetCall<'a, C, A>
23815    where C: 'a, A: 'a {
23816
23817    hub: &'a Directory<C, A>,
23818    _customer_id: String,
23819    _schema_key: String,
23820    _delegate: Option<&'a mut dyn Delegate>,
23821    _additional_params: HashMap<String, String>,
23822    _scopes: BTreeMap<String, ()>
23823}
23824
23825impl<'a, C, A> CallBuilder for SchemaGetCall<'a, C, A> {}
23826
23827impl<'a, C, A> SchemaGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
23828
23829
23830    /// Perform the operation you have build so far.
23831    pub fn doit(mut self) -> Result<(hyper::client::Response, Schema)> {
23832        use std::io::{Read, Seek};
23833        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
23834        let mut dd = DefaultDelegate;
23835        let mut dlg: &mut dyn Delegate = match self._delegate {
23836            Some(d) => d,
23837            None => &mut dd
23838        };
23839        dlg.begin(MethodInfo { id: "directory.schemas.get",
23840                               http_method: hyper::method::Method::Get });
23841        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
23842        params.push(("customerId", self._customer_id.to_string()));
23843        params.push(("schemaKey", self._schema_key.to_string()));
23844        for &field in ["alt", "customerId", "schemaKey"].iter() {
23845            if self._additional_params.contains_key(field) {
23846                dlg.finished(false);
23847                return Err(Error::FieldClash(field));
23848            }
23849        }
23850        for (name, value) in self._additional_params.iter() {
23851            params.push((&name, value.clone()));
23852        }
23853
23854        params.push(("alt", "json".to_string()));
23855
23856        let mut url = self.hub._base_url.clone() + "customer/{customerId}/schemas/{schemaKey}";
23857        if self._scopes.len() == 0 {
23858            self._scopes.insert(Scope::DirectoryUserschemaReadonly.as_ref().to_string(), ());
23859        }
23860
23861        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
23862            let mut replace_with: Option<&str> = None;
23863            for &(name, ref value) in params.iter() {
23864                if name == param_name {
23865                    replace_with = Some(value);
23866                    break;
23867                }
23868            }
23869            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
23870        }
23871        {
23872            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
23873            for param_name in ["schemaKey", "customerId"].iter() {
23874                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
23875                    indices_for_removal.push(index);
23876                }
23877            }
23878            for &index in indices_for_removal.iter() {
23879                params.remove(index);
23880            }
23881        }
23882
23883        let url = hyper::Url::parse_with_params(&url, params).unwrap();
23884
23885
23886
23887        loop {
23888            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
23889                Ok(token) => token,
23890                Err(err) => {
23891                    match  dlg.token(&*err) {
23892                        Some(token) => token,
23893                        None => {
23894                            dlg.finished(false);
23895                            return Err(Error::MissingToken(err))
23896                        }
23897                    }
23898                }
23899            };
23900            let auth_header = Authorization(Bearer { token: token.access_token });
23901            let mut req_result = {
23902                let mut client = &mut *self.hub.client.borrow_mut();
23903                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
23904                    .header(UserAgent(self.hub._user_agent.clone()))
23905                    .header(auth_header.clone());
23906
23907                dlg.pre_request();
23908                req.send()
23909            };
23910
23911            match req_result {
23912                Err(err) => {
23913                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
23914                        sleep(d);
23915                        continue;
23916                    }
23917                    dlg.finished(false);
23918                    return Err(Error::HttpError(err))
23919                }
23920                Ok(mut res) => {
23921                    if !res.status.is_success() {
23922                        let mut json_err = String::new();
23923                        res.read_to_string(&mut json_err).unwrap();
23924                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
23925                                                              json::from_str(&json_err).ok(),
23926                                                              json::from_str(&json_err).ok()) {
23927                            sleep(d);
23928                            continue;
23929                        }
23930                        dlg.finished(false);
23931                        return match json::from_str::<ErrorResponse>(&json_err){
23932                            Err(_) => Err(Error::Failure(res)),
23933                            Ok(serr) => Err(Error::BadRequest(serr))
23934                        }
23935                    }
23936                    let result_value = {
23937                        let mut json_response = String::new();
23938                        res.read_to_string(&mut json_response).unwrap();
23939                        match json::from_str(&json_response) {
23940                            Ok(decoded) => (res, decoded),
23941                            Err(err) => {
23942                                dlg.response_json_decode_error(&json_response, &err);
23943                                return Err(Error::JsonDecodeError(json_response, err));
23944                            }
23945                        }
23946                    };
23947
23948                    dlg.finished(true);
23949                    return Ok(result_value)
23950                }
23951            }
23952        }
23953    }
23954
23955
23956    /// Immutable ID of the G Suite account
23957    ///
23958    /// Sets the *customer id* path property to the given value.
23959    ///
23960    /// Even though the property as already been set when instantiating this call,
23961    /// we provide this method for API completeness.
23962    pub fn customer_id(mut self, new_value: &str) -> SchemaGetCall<'a, C, A> {
23963        self._customer_id = new_value.to_string();
23964        self
23965    }
23966    /// Name or immutable ID of the schema
23967    ///
23968    /// Sets the *schema key* path property to the given value.
23969    ///
23970    /// Even though the property as already been set when instantiating this call,
23971    /// we provide this method for API completeness.
23972    pub fn schema_key(mut self, new_value: &str) -> SchemaGetCall<'a, C, A> {
23973        self._schema_key = new_value.to_string();
23974        self
23975    }
23976    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23977    /// while executing the actual API request.
23978    /// 
23979    /// It should be used to handle progress information, and to implement a certain level of resilience.
23980    ///
23981    /// Sets the *delegate* property to the given value.
23982    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SchemaGetCall<'a, C, A> {
23983        self._delegate = Some(new_value);
23984        self
23985    }
23986
23987    /// Set any additional parameter of the query string used in the request.
23988    /// It should be used to set parameters which are not yet available through their own
23989    /// setters.
23990    ///
23991    /// Please note that this method must not be used to set any of the known parameters
23992    /// which have their own setter method. If done anyway, the request will fail.
23993    ///
23994    /// # Additional Parameters
23995    ///
23996    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23997    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23998    /// * *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.
23999    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24000    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24001    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24002    /// * *alt* (query-string) - Data format for the response.
24003    pub fn param<T>(mut self, name: T, value: T) -> SchemaGetCall<'a, C, A>
24004                                                        where T: AsRef<str> {
24005        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
24006        self
24007    }
24008
24009    /// Identifies the authorization scope for the method you are building.
24010    ///
24011    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
24012    /// `Scope::DirectoryUserschemaReadonly`.
24013    ///
24014    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24015    /// tokens for more than one scope.
24016    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
24017    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
24018    /// function for details).
24019    ///
24020    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24021    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24022    /// sufficient, a read-write scope will do as well.
24023    pub fn add_scope<T, S>(mut self, scope: T) -> SchemaGetCall<'a, C, A>
24024                                                        where T: Into<Option<S>>,
24025                                                              S: AsRef<str> {
24026        match scope.into() {
24027          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
24028          None => None,
24029        };
24030        self
24031    }
24032}
24033
24034
24035/// Update schema
24036///
24037/// A builder for the *update* method supported by a *schema* resource.
24038/// It is not used directly, but through a `SchemaMethods` instance.
24039///
24040/// # Example
24041///
24042/// Instantiate a resource method builder
24043///
24044/// ```test_harness,no_run
24045/// # extern crate hyper;
24046/// # extern crate hyper_rustls;
24047/// # extern crate yup_oauth2 as oauth2;
24048/// # extern crate google_admin1_directory as admin1_directory;
24049/// use admin1_directory::Schema;
24050/// # #[test] fn egal() {
24051/// # use std::default::Default;
24052/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
24053/// # use admin1_directory::Directory;
24054/// 
24055/// # let secret: ApplicationSecret = Default::default();
24056/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
24057/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
24058/// #                               <MemoryStorage as Default>::default(), None);
24059/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
24060/// // As the method needs a request, you would usually fill it with the desired information
24061/// // into the respective structure. Some of the parts shown here might not be applicable !
24062/// // Values shown here are possibly random and not representative !
24063/// let mut req = Schema::default();
24064/// 
24065/// // You can configure optional parameters by calling the respective setters at will, and
24066/// // execute the final call using `doit()`.
24067/// // Values shown here are possibly random and not representative !
24068/// let result = hub.schemas().update(req, "customerId", "schemaKey")
24069///              .doit();
24070/// # }
24071/// ```
24072pub struct SchemaUpdateCall<'a, C, A>
24073    where C: 'a, A: 'a {
24074
24075    hub: &'a Directory<C, A>,
24076    _request: Schema,
24077    _customer_id: String,
24078    _schema_key: String,
24079    _delegate: Option<&'a mut dyn Delegate>,
24080    _additional_params: HashMap<String, String>,
24081    _scopes: BTreeMap<String, ()>
24082}
24083
24084impl<'a, C, A> CallBuilder for SchemaUpdateCall<'a, C, A> {}
24085
24086impl<'a, C, A> SchemaUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
24087
24088
24089    /// Perform the operation you have build so far.
24090    pub fn doit(mut self) -> Result<(hyper::client::Response, Schema)> {
24091        use std::io::{Read, Seek};
24092        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
24093        let mut dd = DefaultDelegate;
24094        let mut dlg: &mut dyn Delegate = match self._delegate {
24095            Some(d) => d,
24096            None => &mut dd
24097        };
24098        dlg.begin(MethodInfo { id: "directory.schemas.update",
24099                               http_method: hyper::method::Method::Put });
24100        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
24101        params.push(("customerId", self._customer_id.to_string()));
24102        params.push(("schemaKey", self._schema_key.to_string()));
24103        for &field in ["alt", "customerId", "schemaKey"].iter() {
24104            if self._additional_params.contains_key(field) {
24105                dlg.finished(false);
24106                return Err(Error::FieldClash(field));
24107            }
24108        }
24109        for (name, value) in self._additional_params.iter() {
24110            params.push((&name, value.clone()));
24111        }
24112
24113        params.push(("alt", "json".to_string()));
24114
24115        let mut url = self.hub._base_url.clone() + "customer/{customerId}/schemas/{schemaKey}";
24116        if self._scopes.len() == 0 {
24117            self._scopes.insert(Scope::DirectoryUserschema.as_ref().to_string(), ());
24118        }
24119
24120        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
24121            let mut replace_with: Option<&str> = None;
24122            for &(name, ref value) in params.iter() {
24123                if name == param_name {
24124                    replace_with = Some(value);
24125                    break;
24126                }
24127            }
24128            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
24129        }
24130        {
24131            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
24132            for param_name in ["schemaKey", "customerId"].iter() {
24133                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
24134                    indices_for_removal.push(index);
24135                }
24136            }
24137            for &index in indices_for_removal.iter() {
24138                params.remove(index);
24139            }
24140        }
24141
24142        let url = hyper::Url::parse_with_params(&url, params).unwrap();
24143
24144        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
24145        let mut request_value_reader =
24146            {
24147                let mut value = json::value::to_value(&self._request).expect("serde to work");
24148                remove_json_null_values(&mut value);
24149                let mut dst = io::Cursor::new(Vec::with_capacity(128));
24150                json::to_writer(&mut dst, &value).unwrap();
24151                dst
24152            };
24153        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
24154        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
24155
24156
24157        loop {
24158            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
24159                Ok(token) => token,
24160                Err(err) => {
24161                    match  dlg.token(&*err) {
24162                        Some(token) => token,
24163                        None => {
24164                            dlg.finished(false);
24165                            return Err(Error::MissingToken(err))
24166                        }
24167                    }
24168                }
24169            };
24170            let auth_header = Authorization(Bearer { token: token.access_token });
24171            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
24172            let mut req_result = {
24173                let mut client = &mut *self.hub.client.borrow_mut();
24174                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
24175                    .header(UserAgent(self.hub._user_agent.clone()))
24176                    .header(auth_header.clone())
24177                    .header(ContentType(json_mime_type.clone()))
24178                    .header(ContentLength(request_size as u64))
24179                    .body(&mut request_value_reader);
24180
24181                dlg.pre_request();
24182                req.send()
24183            };
24184
24185            match req_result {
24186                Err(err) => {
24187                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
24188                        sleep(d);
24189                        continue;
24190                    }
24191                    dlg.finished(false);
24192                    return Err(Error::HttpError(err))
24193                }
24194                Ok(mut res) => {
24195                    if !res.status.is_success() {
24196                        let mut json_err = String::new();
24197                        res.read_to_string(&mut json_err).unwrap();
24198                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
24199                                                              json::from_str(&json_err).ok(),
24200                                                              json::from_str(&json_err).ok()) {
24201                            sleep(d);
24202                            continue;
24203                        }
24204                        dlg.finished(false);
24205                        return match json::from_str::<ErrorResponse>(&json_err){
24206                            Err(_) => Err(Error::Failure(res)),
24207                            Ok(serr) => Err(Error::BadRequest(serr))
24208                        }
24209                    }
24210                    let result_value = {
24211                        let mut json_response = String::new();
24212                        res.read_to_string(&mut json_response).unwrap();
24213                        match json::from_str(&json_response) {
24214                            Ok(decoded) => (res, decoded),
24215                            Err(err) => {
24216                                dlg.response_json_decode_error(&json_response, &err);
24217                                return Err(Error::JsonDecodeError(json_response, err));
24218                            }
24219                        }
24220                    };
24221
24222                    dlg.finished(true);
24223                    return Ok(result_value)
24224                }
24225            }
24226        }
24227    }
24228
24229
24230    ///
24231    /// Sets the *request* property to the given value.
24232    ///
24233    /// Even though the property as already been set when instantiating this call,
24234    /// we provide this method for API completeness.
24235    pub fn request(mut self, new_value: Schema) -> SchemaUpdateCall<'a, C, A> {
24236        self._request = new_value;
24237        self
24238    }
24239    /// Immutable ID of the G Suite account
24240    ///
24241    /// Sets the *customer id* path property to the given value.
24242    ///
24243    /// Even though the property as already been set when instantiating this call,
24244    /// we provide this method for API completeness.
24245    pub fn customer_id(mut self, new_value: &str) -> SchemaUpdateCall<'a, C, A> {
24246        self._customer_id = new_value.to_string();
24247        self
24248    }
24249    /// Name or immutable ID of the schema.
24250    ///
24251    /// Sets the *schema key* path property to the given value.
24252    ///
24253    /// Even though the property as already been set when instantiating this call,
24254    /// we provide this method for API completeness.
24255    pub fn schema_key(mut self, new_value: &str) -> SchemaUpdateCall<'a, C, A> {
24256        self._schema_key = new_value.to_string();
24257        self
24258    }
24259    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24260    /// while executing the actual API request.
24261    /// 
24262    /// It should be used to handle progress information, and to implement a certain level of resilience.
24263    ///
24264    /// Sets the *delegate* property to the given value.
24265    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SchemaUpdateCall<'a, C, A> {
24266        self._delegate = Some(new_value);
24267        self
24268    }
24269
24270    /// Set any additional parameter of the query string used in the request.
24271    /// It should be used to set parameters which are not yet available through their own
24272    /// setters.
24273    ///
24274    /// Please note that this method must not be used to set any of the known parameters
24275    /// which have their own setter method. If done anyway, the request will fail.
24276    ///
24277    /// # Additional Parameters
24278    ///
24279    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24280    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24281    /// * *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.
24282    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24283    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24284    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24285    /// * *alt* (query-string) - Data format for the response.
24286    pub fn param<T>(mut self, name: T, value: T) -> SchemaUpdateCall<'a, C, A>
24287                                                        where T: AsRef<str> {
24288        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
24289        self
24290    }
24291
24292    /// Identifies the authorization scope for the method you are building.
24293    ///
24294    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
24295    /// `Scope::DirectoryUserschema`.
24296    ///
24297    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24298    /// tokens for more than one scope.
24299    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
24300    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
24301    /// function for details).
24302    ///
24303    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24304    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24305    /// sufficient, a read-write scope will do as well.
24306    pub fn add_scope<T, S>(mut self, scope: T) -> SchemaUpdateCall<'a, C, A>
24307                                                        where T: Into<Option<S>>,
24308                                                              S: AsRef<str> {
24309        match scope.into() {
24310          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
24311          None => None,
24312        };
24313        self
24314    }
24315}
24316
24317
24318/// Retrieve all schemas for a customer
24319///
24320/// A builder for the *list* method supported by a *schema* resource.
24321/// It is not used directly, but through a `SchemaMethods` instance.
24322///
24323/// # Example
24324///
24325/// Instantiate a resource method builder
24326///
24327/// ```test_harness,no_run
24328/// # extern crate hyper;
24329/// # extern crate hyper_rustls;
24330/// # extern crate yup_oauth2 as oauth2;
24331/// # extern crate google_admin1_directory as admin1_directory;
24332/// # #[test] fn egal() {
24333/// # use std::default::Default;
24334/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
24335/// # use admin1_directory::Directory;
24336/// 
24337/// # let secret: ApplicationSecret = Default::default();
24338/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
24339/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
24340/// #                               <MemoryStorage as Default>::default(), None);
24341/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
24342/// // You can configure optional parameters by calling the respective setters at will, and
24343/// // execute the final call using `doit()`.
24344/// // Values shown here are possibly random and not representative !
24345/// let result = hub.schemas().list("customerId")
24346///              .doit();
24347/// # }
24348/// ```
24349pub struct SchemaListCall<'a, C, A>
24350    where C: 'a, A: 'a {
24351
24352    hub: &'a Directory<C, A>,
24353    _customer_id: String,
24354    _delegate: Option<&'a mut dyn Delegate>,
24355    _additional_params: HashMap<String, String>,
24356    _scopes: BTreeMap<String, ()>
24357}
24358
24359impl<'a, C, A> CallBuilder for SchemaListCall<'a, C, A> {}
24360
24361impl<'a, C, A> SchemaListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
24362
24363
24364    /// Perform the operation you have build so far.
24365    pub fn doit(mut self) -> Result<(hyper::client::Response, Schemas)> {
24366        use std::io::{Read, Seek};
24367        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
24368        let mut dd = DefaultDelegate;
24369        let mut dlg: &mut dyn Delegate = match self._delegate {
24370            Some(d) => d,
24371            None => &mut dd
24372        };
24373        dlg.begin(MethodInfo { id: "directory.schemas.list",
24374                               http_method: hyper::method::Method::Get });
24375        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
24376        params.push(("customerId", self._customer_id.to_string()));
24377        for &field in ["alt", "customerId"].iter() {
24378            if self._additional_params.contains_key(field) {
24379                dlg.finished(false);
24380                return Err(Error::FieldClash(field));
24381            }
24382        }
24383        for (name, value) in self._additional_params.iter() {
24384            params.push((&name, value.clone()));
24385        }
24386
24387        params.push(("alt", "json".to_string()));
24388
24389        let mut url = self.hub._base_url.clone() + "customer/{customerId}/schemas";
24390        if self._scopes.len() == 0 {
24391            self._scopes.insert(Scope::DirectoryUserschemaReadonly.as_ref().to_string(), ());
24392        }
24393
24394        for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
24395            let mut replace_with: Option<&str> = None;
24396            for &(name, ref value) in params.iter() {
24397                if name == param_name {
24398                    replace_with = Some(value);
24399                    break;
24400                }
24401            }
24402            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
24403        }
24404        {
24405            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
24406            for param_name in ["customerId"].iter() {
24407                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
24408                    indices_for_removal.push(index);
24409                }
24410            }
24411            for &index in indices_for_removal.iter() {
24412                params.remove(index);
24413            }
24414        }
24415
24416        let url = hyper::Url::parse_with_params(&url, params).unwrap();
24417
24418
24419
24420        loop {
24421            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
24422                Ok(token) => token,
24423                Err(err) => {
24424                    match  dlg.token(&*err) {
24425                        Some(token) => token,
24426                        None => {
24427                            dlg.finished(false);
24428                            return Err(Error::MissingToken(err))
24429                        }
24430                    }
24431                }
24432            };
24433            let auth_header = Authorization(Bearer { token: token.access_token });
24434            let mut req_result = {
24435                let mut client = &mut *self.hub.client.borrow_mut();
24436                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
24437                    .header(UserAgent(self.hub._user_agent.clone()))
24438                    .header(auth_header.clone());
24439
24440                dlg.pre_request();
24441                req.send()
24442            };
24443
24444            match req_result {
24445                Err(err) => {
24446                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
24447                        sleep(d);
24448                        continue;
24449                    }
24450                    dlg.finished(false);
24451                    return Err(Error::HttpError(err))
24452                }
24453                Ok(mut res) => {
24454                    if !res.status.is_success() {
24455                        let mut json_err = String::new();
24456                        res.read_to_string(&mut json_err).unwrap();
24457                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
24458                                                              json::from_str(&json_err).ok(),
24459                                                              json::from_str(&json_err).ok()) {
24460                            sleep(d);
24461                            continue;
24462                        }
24463                        dlg.finished(false);
24464                        return match json::from_str::<ErrorResponse>(&json_err){
24465                            Err(_) => Err(Error::Failure(res)),
24466                            Ok(serr) => Err(Error::BadRequest(serr))
24467                        }
24468                    }
24469                    let result_value = {
24470                        let mut json_response = String::new();
24471                        res.read_to_string(&mut json_response).unwrap();
24472                        match json::from_str(&json_response) {
24473                            Ok(decoded) => (res, decoded),
24474                            Err(err) => {
24475                                dlg.response_json_decode_error(&json_response, &err);
24476                                return Err(Error::JsonDecodeError(json_response, err));
24477                            }
24478                        }
24479                    };
24480
24481                    dlg.finished(true);
24482                    return Ok(result_value)
24483                }
24484            }
24485        }
24486    }
24487
24488
24489    /// Immutable ID of the G Suite account
24490    ///
24491    /// Sets the *customer id* path property to the given value.
24492    ///
24493    /// Even though the property as already been set when instantiating this call,
24494    /// we provide this method for API completeness.
24495    pub fn customer_id(mut self, new_value: &str) -> SchemaListCall<'a, C, A> {
24496        self._customer_id = new_value.to_string();
24497        self
24498    }
24499    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24500    /// while executing the actual API request.
24501    /// 
24502    /// It should be used to handle progress information, and to implement a certain level of resilience.
24503    ///
24504    /// Sets the *delegate* property to the given value.
24505    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SchemaListCall<'a, C, A> {
24506        self._delegate = Some(new_value);
24507        self
24508    }
24509
24510    /// Set any additional parameter of the query string used in the request.
24511    /// It should be used to set parameters which are not yet available through their own
24512    /// setters.
24513    ///
24514    /// Please note that this method must not be used to set any of the known parameters
24515    /// which have their own setter method. If done anyway, the request will fail.
24516    ///
24517    /// # Additional Parameters
24518    ///
24519    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24520    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24521    /// * *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.
24522    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24523    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24524    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24525    /// * *alt* (query-string) - Data format for the response.
24526    pub fn param<T>(mut self, name: T, value: T) -> SchemaListCall<'a, C, A>
24527                                                        where T: AsRef<str> {
24528        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
24529        self
24530    }
24531
24532    /// Identifies the authorization scope for the method you are building.
24533    ///
24534    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
24535    /// `Scope::DirectoryUserschemaReadonly`.
24536    ///
24537    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24538    /// tokens for more than one scope.
24539    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
24540    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
24541    /// function for details).
24542    ///
24543    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24544    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24545    /// sufficient, a read-write scope will do as well.
24546    pub fn add_scope<T, S>(mut self, scope: T) -> SchemaListCall<'a, C, A>
24547                                                        where T: Into<Option<S>>,
24548                                                              S: AsRef<str> {
24549        match scope.into() {
24550          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
24551          None => None,
24552        };
24553        self
24554    }
24555}
24556
24557
24558/// Update schema. This method supports patch semantics.
24559///
24560/// A builder for the *patch* method supported by a *schema* resource.
24561/// It is not used directly, but through a `SchemaMethods` instance.
24562///
24563/// # Example
24564///
24565/// Instantiate a resource method builder
24566///
24567/// ```test_harness,no_run
24568/// # extern crate hyper;
24569/// # extern crate hyper_rustls;
24570/// # extern crate yup_oauth2 as oauth2;
24571/// # extern crate google_admin1_directory as admin1_directory;
24572/// use admin1_directory::Schema;
24573/// # #[test] fn egal() {
24574/// # use std::default::Default;
24575/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
24576/// # use admin1_directory::Directory;
24577/// 
24578/// # let secret: ApplicationSecret = Default::default();
24579/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
24580/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
24581/// #                               <MemoryStorage as Default>::default(), None);
24582/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
24583/// // As the method needs a request, you would usually fill it with the desired information
24584/// // into the respective structure. Some of the parts shown here might not be applicable !
24585/// // Values shown here are possibly random and not representative !
24586/// let mut req = Schema::default();
24587/// 
24588/// // You can configure optional parameters by calling the respective setters at will, and
24589/// // execute the final call using `doit()`.
24590/// // Values shown here are possibly random and not representative !
24591/// let result = hub.schemas().patch(req, "customerId", "schemaKey")
24592///              .doit();
24593/// # }
24594/// ```
24595pub struct SchemaPatchCall<'a, C, A>
24596    where C: 'a, A: 'a {
24597
24598    hub: &'a Directory<C, A>,
24599    _request: Schema,
24600    _customer_id: String,
24601    _schema_key: String,
24602    _delegate: Option<&'a mut dyn Delegate>,
24603    _additional_params: HashMap<String, String>,
24604    _scopes: BTreeMap<String, ()>
24605}
24606
24607impl<'a, C, A> CallBuilder for SchemaPatchCall<'a, C, A> {}
24608
24609impl<'a, C, A> SchemaPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
24610
24611
24612    /// Perform the operation you have build so far.
24613    pub fn doit(mut self) -> Result<(hyper::client::Response, Schema)> {
24614        use std::io::{Read, Seek};
24615        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
24616        let mut dd = DefaultDelegate;
24617        let mut dlg: &mut dyn Delegate = match self._delegate {
24618            Some(d) => d,
24619            None => &mut dd
24620        };
24621        dlg.begin(MethodInfo { id: "directory.schemas.patch",
24622                               http_method: hyper::method::Method::Patch });
24623        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
24624        params.push(("customerId", self._customer_id.to_string()));
24625        params.push(("schemaKey", self._schema_key.to_string()));
24626        for &field in ["alt", "customerId", "schemaKey"].iter() {
24627            if self._additional_params.contains_key(field) {
24628                dlg.finished(false);
24629                return Err(Error::FieldClash(field));
24630            }
24631        }
24632        for (name, value) in self._additional_params.iter() {
24633            params.push((&name, value.clone()));
24634        }
24635
24636        params.push(("alt", "json".to_string()));
24637
24638        let mut url = self.hub._base_url.clone() + "customer/{customerId}/schemas/{schemaKey}";
24639        if self._scopes.len() == 0 {
24640            self._scopes.insert(Scope::DirectoryUserschema.as_ref().to_string(), ());
24641        }
24642
24643        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
24644            let mut replace_with: Option<&str> = None;
24645            for &(name, ref value) in params.iter() {
24646                if name == param_name {
24647                    replace_with = Some(value);
24648                    break;
24649                }
24650            }
24651            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
24652        }
24653        {
24654            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
24655            for param_name in ["schemaKey", "customerId"].iter() {
24656                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
24657                    indices_for_removal.push(index);
24658                }
24659            }
24660            for &index in indices_for_removal.iter() {
24661                params.remove(index);
24662            }
24663        }
24664
24665        let url = hyper::Url::parse_with_params(&url, params).unwrap();
24666
24667        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
24668        let mut request_value_reader =
24669            {
24670                let mut value = json::value::to_value(&self._request).expect("serde to work");
24671                remove_json_null_values(&mut value);
24672                let mut dst = io::Cursor::new(Vec::with_capacity(128));
24673                json::to_writer(&mut dst, &value).unwrap();
24674                dst
24675            };
24676        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
24677        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
24678
24679
24680        loop {
24681            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
24682                Ok(token) => token,
24683                Err(err) => {
24684                    match  dlg.token(&*err) {
24685                        Some(token) => token,
24686                        None => {
24687                            dlg.finished(false);
24688                            return Err(Error::MissingToken(err))
24689                        }
24690                    }
24691                }
24692            };
24693            let auth_header = Authorization(Bearer { token: token.access_token });
24694            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
24695            let mut req_result = {
24696                let mut client = &mut *self.hub.client.borrow_mut();
24697                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
24698                    .header(UserAgent(self.hub._user_agent.clone()))
24699                    .header(auth_header.clone())
24700                    .header(ContentType(json_mime_type.clone()))
24701                    .header(ContentLength(request_size as u64))
24702                    .body(&mut request_value_reader);
24703
24704                dlg.pre_request();
24705                req.send()
24706            };
24707
24708            match req_result {
24709                Err(err) => {
24710                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
24711                        sleep(d);
24712                        continue;
24713                    }
24714                    dlg.finished(false);
24715                    return Err(Error::HttpError(err))
24716                }
24717                Ok(mut res) => {
24718                    if !res.status.is_success() {
24719                        let mut json_err = String::new();
24720                        res.read_to_string(&mut json_err).unwrap();
24721                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
24722                                                              json::from_str(&json_err).ok(),
24723                                                              json::from_str(&json_err).ok()) {
24724                            sleep(d);
24725                            continue;
24726                        }
24727                        dlg.finished(false);
24728                        return match json::from_str::<ErrorResponse>(&json_err){
24729                            Err(_) => Err(Error::Failure(res)),
24730                            Ok(serr) => Err(Error::BadRequest(serr))
24731                        }
24732                    }
24733                    let result_value = {
24734                        let mut json_response = String::new();
24735                        res.read_to_string(&mut json_response).unwrap();
24736                        match json::from_str(&json_response) {
24737                            Ok(decoded) => (res, decoded),
24738                            Err(err) => {
24739                                dlg.response_json_decode_error(&json_response, &err);
24740                                return Err(Error::JsonDecodeError(json_response, err));
24741                            }
24742                        }
24743                    };
24744
24745                    dlg.finished(true);
24746                    return Ok(result_value)
24747                }
24748            }
24749        }
24750    }
24751
24752
24753    ///
24754    /// Sets the *request* property to the given value.
24755    ///
24756    /// Even though the property as already been set when instantiating this call,
24757    /// we provide this method for API completeness.
24758    pub fn request(mut self, new_value: Schema) -> SchemaPatchCall<'a, C, A> {
24759        self._request = new_value;
24760        self
24761    }
24762    /// Immutable ID of the G Suite account
24763    ///
24764    /// Sets the *customer id* path property to the given value.
24765    ///
24766    /// Even though the property as already been set when instantiating this call,
24767    /// we provide this method for API completeness.
24768    pub fn customer_id(mut self, new_value: &str) -> SchemaPatchCall<'a, C, A> {
24769        self._customer_id = new_value.to_string();
24770        self
24771    }
24772    /// Name or immutable ID of the schema.
24773    ///
24774    /// Sets the *schema key* path property to the given value.
24775    ///
24776    /// Even though the property as already been set when instantiating this call,
24777    /// we provide this method for API completeness.
24778    pub fn schema_key(mut self, new_value: &str) -> SchemaPatchCall<'a, C, A> {
24779        self._schema_key = new_value.to_string();
24780        self
24781    }
24782    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24783    /// while executing the actual API request.
24784    /// 
24785    /// It should be used to handle progress information, and to implement a certain level of resilience.
24786    ///
24787    /// Sets the *delegate* property to the given value.
24788    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SchemaPatchCall<'a, C, A> {
24789        self._delegate = Some(new_value);
24790        self
24791    }
24792
24793    /// Set any additional parameter of the query string used in the request.
24794    /// It should be used to set parameters which are not yet available through their own
24795    /// setters.
24796    ///
24797    /// Please note that this method must not be used to set any of the known parameters
24798    /// which have their own setter method. If done anyway, the request will fail.
24799    ///
24800    /// # Additional Parameters
24801    ///
24802    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24803    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24804    /// * *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.
24805    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24806    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24807    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24808    /// * *alt* (query-string) - Data format for the response.
24809    pub fn param<T>(mut self, name: T, value: T) -> SchemaPatchCall<'a, C, A>
24810                                                        where T: AsRef<str> {
24811        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
24812        self
24813    }
24814
24815    /// Identifies the authorization scope for the method you are building.
24816    ///
24817    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
24818    /// `Scope::DirectoryUserschema`.
24819    ///
24820    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24821    /// tokens for more than one scope.
24822    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
24823    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
24824    /// function for details).
24825    ///
24826    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24827    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24828    /// sufficient, a read-write scope will do as well.
24829    pub fn add_scope<T, S>(mut self, scope: T) -> SchemaPatchCall<'a, C, A>
24830                                                        where T: Into<Option<S>>,
24831                                                              S: AsRef<str> {
24832        match scope.into() {
24833          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
24834          None => None,
24835        };
24836        self
24837    }
24838}
24839
24840
24841/// Create schema.
24842///
24843/// A builder for the *insert* method supported by a *schema* resource.
24844/// It is not used directly, but through a `SchemaMethods` instance.
24845///
24846/// # Example
24847///
24848/// Instantiate a resource method builder
24849///
24850/// ```test_harness,no_run
24851/// # extern crate hyper;
24852/// # extern crate hyper_rustls;
24853/// # extern crate yup_oauth2 as oauth2;
24854/// # extern crate google_admin1_directory as admin1_directory;
24855/// use admin1_directory::Schema;
24856/// # #[test] fn egal() {
24857/// # use std::default::Default;
24858/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
24859/// # use admin1_directory::Directory;
24860/// 
24861/// # let secret: ApplicationSecret = Default::default();
24862/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
24863/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
24864/// #                               <MemoryStorage as Default>::default(), None);
24865/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
24866/// // As the method needs a request, you would usually fill it with the desired information
24867/// // into the respective structure. Some of the parts shown here might not be applicable !
24868/// // Values shown here are possibly random and not representative !
24869/// let mut req = Schema::default();
24870/// 
24871/// // You can configure optional parameters by calling the respective setters at will, and
24872/// // execute the final call using `doit()`.
24873/// // Values shown here are possibly random and not representative !
24874/// let result = hub.schemas().insert(req, "customerId")
24875///              .doit();
24876/// # }
24877/// ```
24878pub struct SchemaInsertCall<'a, C, A>
24879    where C: 'a, A: 'a {
24880
24881    hub: &'a Directory<C, A>,
24882    _request: Schema,
24883    _customer_id: String,
24884    _delegate: Option<&'a mut dyn Delegate>,
24885    _additional_params: HashMap<String, String>,
24886    _scopes: BTreeMap<String, ()>
24887}
24888
24889impl<'a, C, A> CallBuilder for SchemaInsertCall<'a, C, A> {}
24890
24891impl<'a, C, A> SchemaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
24892
24893
24894    /// Perform the operation you have build so far.
24895    pub fn doit(mut self) -> Result<(hyper::client::Response, Schema)> {
24896        use std::io::{Read, Seek};
24897        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
24898        let mut dd = DefaultDelegate;
24899        let mut dlg: &mut dyn Delegate = match self._delegate {
24900            Some(d) => d,
24901            None => &mut dd
24902        };
24903        dlg.begin(MethodInfo { id: "directory.schemas.insert",
24904                               http_method: hyper::method::Method::Post });
24905        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
24906        params.push(("customerId", self._customer_id.to_string()));
24907        for &field in ["alt", "customerId"].iter() {
24908            if self._additional_params.contains_key(field) {
24909                dlg.finished(false);
24910                return Err(Error::FieldClash(field));
24911            }
24912        }
24913        for (name, value) in self._additional_params.iter() {
24914            params.push((&name, value.clone()));
24915        }
24916
24917        params.push(("alt", "json".to_string()));
24918
24919        let mut url = self.hub._base_url.clone() + "customer/{customerId}/schemas";
24920        if self._scopes.len() == 0 {
24921            self._scopes.insert(Scope::DirectoryUserschema.as_ref().to_string(), ());
24922        }
24923
24924        for &(find_this, param_name) in [("{customerId}", "customerId")].iter() {
24925            let mut replace_with: Option<&str> = None;
24926            for &(name, ref value) in params.iter() {
24927                if name == param_name {
24928                    replace_with = Some(value);
24929                    break;
24930                }
24931            }
24932            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
24933        }
24934        {
24935            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
24936            for param_name in ["customerId"].iter() {
24937                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
24938                    indices_for_removal.push(index);
24939                }
24940            }
24941            for &index in indices_for_removal.iter() {
24942                params.remove(index);
24943            }
24944        }
24945
24946        let url = hyper::Url::parse_with_params(&url, params).unwrap();
24947
24948        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
24949        let mut request_value_reader =
24950            {
24951                let mut value = json::value::to_value(&self._request).expect("serde to work");
24952                remove_json_null_values(&mut value);
24953                let mut dst = io::Cursor::new(Vec::with_capacity(128));
24954                json::to_writer(&mut dst, &value).unwrap();
24955                dst
24956            };
24957        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
24958        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
24959
24960
24961        loop {
24962            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
24963                Ok(token) => token,
24964                Err(err) => {
24965                    match  dlg.token(&*err) {
24966                        Some(token) => token,
24967                        None => {
24968                            dlg.finished(false);
24969                            return Err(Error::MissingToken(err))
24970                        }
24971                    }
24972                }
24973            };
24974            let auth_header = Authorization(Bearer { token: token.access_token });
24975            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
24976            let mut req_result = {
24977                let mut client = &mut *self.hub.client.borrow_mut();
24978                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
24979                    .header(UserAgent(self.hub._user_agent.clone()))
24980                    .header(auth_header.clone())
24981                    .header(ContentType(json_mime_type.clone()))
24982                    .header(ContentLength(request_size as u64))
24983                    .body(&mut request_value_reader);
24984
24985                dlg.pre_request();
24986                req.send()
24987            };
24988
24989            match req_result {
24990                Err(err) => {
24991                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
24992                        sleep(d);
24993                        continue;
24994                    }
24995                    dlg.finished(false);
24996                    return Err(Error::HttpError(err))
24997                }
24998                Ok(mut res) => {
24999                    if !res.status.is_success() {
25000                        let mut json_err = String::new();
25001                        res.read_to_string(&mut json_err).unwrap();
25002                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
25003                                                              json::from_str(&json_err).ok(),
25004                                                              json::from_str(&json_err).ok()) {
25005                            sleep(d);
25006                            continue;
25007                        }
25008                        dlg.finished(false);
25009                        return match json::from_str::<ErrorResponse>(&json_err){
25010                            Err(_) => Err(Error::Failure(res)),
25011                            Ok(serr) => Err(Error::BadRequest(serr))
25012                        }
25013                    }
25014                    let result_value = {
25015                        let mut json_response = String::new();
25016                        res.read_to_string(&mut json_response).unwrap();
25017                        match json::from_str(&json_response) {
25018                            Ok(decoded) => (res, decoded),
25019                            Err(err) => {
25020                                dlg.response_json_decode_error(&json_response, &err);
25021                                return Err(Error::JsonDecodeError(json_response, err));
25022                            }
25023                        }
25024                    };
25025
25026                    dlg.finished(true);
25027                    return Ok(result_value)
25028                }
25029            }
25030        }
25031    }
25032
25033
25034    ///
25035    /// Sets the *request* property to the given value.
25036    ///
25037    /// Even though the property as already been set when instantiating this call,
25038    /// we provide this method for API completeness.
25039    pub fn request(mut self, new_value: Schema) -> SchemaInsertCall<'a, C, A> {
25040        self._request = new_value;
25041        self
25042    }
25043    /// Immutable ID of the G Suite account
25044    ///
25045    /// Sets the *customer id* path property to the given value.
25046    ///
25047    /// Even though the property as already been set when instantiating this call,
25048    /// we provide this method for API completeness.
25049    pub fn customer_id(mut self, new_value: &str) -> SchemaInsertCall<'a, C, A> {
25050        self._customer_id = new_value.to_string();
25051        self
25052    }
25053    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25054    /// while executing the actual API request.
25055    /// 
25056    /// It should be used to handle progress information, and to implement a certain level of resilience.
25057    ///
25058    /// Sets the *delegate* property to the given value.
25059    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SchemaInsertCall<'a, C, A> {
25060        self._delegate = Some(new_value);
25061        self
25062    }
25063
25064    /// Set any additional parameter of the query string used in the request.
25065    /// It should be used to set parameters which are not yet available through their own
25066    /// setters.
25067    ///
25068    /// Please note that this method must not be used to set any of the known parameters
25069    /// which have their own setter method. If done anyway, the request will fail.
25070    ///
25071    /// # Additional Parameters
25072    ///
25073    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25074    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25075    /// * *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.
25076    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25077    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25078    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25079    /// * *alt* (query-string) - Data format for the response.
25080    pub fn param<T>(mut self, name: T, value: T) -> SchemaInsertCall<'a, C, A>
25081                                                        where T: AsRef<str> {
25082        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
25083        self
25084    }
25085
25086    /// Identifies the authorization scope for the method you are building.
25087    ///
25088    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
25089    /// `Scope::DirectoryUserschema`.
25090    ///
25091    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25092    /// tokens for more than one scope.
25093    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
25094    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
25095    /// function for details).
25096    ///
25097    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25098    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25099    /// sufficient, a read-write scope will do as well.
25100    pub fn add_scope<T, S>(mut self, scope: T) -> SchemaInsertCall<'a, C, A>
25101                                                        where T: Into<Option<S>>,
25102                                                              S: AsRef<str> {
25103        match scope.into() {
25104          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
25105          None => None,
25106        };
25107        self
25108    }
25109}
25110
25111
25112/// Delete schema
25113///
25114/// A builder for the *delete* method supported by a *schema* resource.
25115/// It is not used directly, but through a `SchemaMethods` instance.
25116///
25117/// # Example
25118///
25119/// Instantiate a resource method builder
25120///
25121/// ```test_harness,no_run
25122/// # extern crate hyper;
25123/// # extern crate hyper_rustls;
25124/// # extern crate yup_oauth2 as oauth2;
25125/// # extern crate google_admin1_directory as admin1_directory;
25126/// # #[test] fn egal() {
25127/// # use std::default::Default;
25128/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
25129/// # use admin1_directory::Directory;
25130/// 
25131/// # let secret: ApplicationSecret = Default::default();
25132/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
25133/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
25134/// #                               <MemoryStorage as Default>::default(), None);
25135/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
25136/// // You can configure optional parameters by calling the respective setters at will, and
25137/// // execute the final call using `doit()`.
25138/// // Values shown here are possibly random and not representative !
25139/// let result = hub.schemas().delete("customerId", "schemaKey")
25140///              .doit();
25141/// # }
25142/// ```
25143pub struct SchemaDeleteCall<'a, C, A>
25144    where C: 'a, A: 'a {
25145
25146    hub: &'a Directory<C, A>,
25147    _customer_id: String,
25148    _schema_key: String,
25149    _delegate: Option<&'a mut dyn Delegate>,
25150    _additional_params: HashMap<String, String>,
25151    _scopes: BTreeMap<String, ()>
25152}
25153
25154impl<'a, C, A> CallBuilder for SchemaDeleteCall<'a, C, A> {}
25155
25156impl<'a, C, A> SchemaDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
25157
25158
25159    /// Perform the operation you have build so far.
25160    pub fn doit(mut self) -> Result<hyper::client::Response> {
25161        use std::io::{Read, Seek};
25162        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
25163        let mut dd = DefaultDelegate;
25164        let mut dlg: &mut dyn Delegate = match self._delegate {
25165            Some(d) => d,
25166            None => &mut dd
25167        };
25168        dlg.begin(MethodInfo { id: "directory.schemas.delete",
25169                               http_method: hyper::method::Method::Delete });
25170        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
25171        params.push(("customerId", self._customer_id.to_string()));
25172        params.push(("schemaKey", self._schema_key.to_string()));
25173        for &field in ["customerId", "schemaKey"].iter() {
25174            if self._additional_params.contains_key(field) {
25175                dlg.finished(false);
25176                return Err(Error::FieldClash(field));
25177            }
25178        }
25179        for (name, value) in self._additional_params.iter() {
25180            params.push((&name, value.clone()));
25181        }
25182
25183
25184        let mut url = self.hub._base_url.clone() + "customer/{customerId}/schemas/{schemaKey}";
25185        if self._scopes.len() == 0 {
25186            self._scopes.insert(Scope::DirectoryUserschema.as_ref().to_string(), ());
25187        }
25188
25189        for &(find_this, param_name) in [("{customerId}", "customerId"), ("{schemaKey}", "schemaKey")].iter() {
25190            let mut replace_with: Option<&str> = None;
25191            for &(name, ref value) in params.iter() {
25192                if name == param_name {
25193                    replace_with = Some(value);
25194                    break;
25195                }
25196            }
25197            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
25198        }
25199        {
25200            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
25201            for param_name in ["schemaKey", "customerId"].iter() {
25202                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
25203                    indices_for_removal.push(index);
25204                }
25205            }
25206            for &index in indices_for_removal.iter() {
25207                params.remove(index);
25208            }
25209        }
25210
25211        let url = hyper::Url::parse_with_params(&url, params).unwrap();
25212
25213
25214
25215        loop {
25216            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
25217                Ok(token) => token,
25218                Err(err) => {
25219                    match  dlg.token(&*err) {
25220                        Some(token) => token,
25221                        None => {
25222                            dlg.finished(false);
25223                            return Err(Error::MissingToken(err))
25224                        }
25225                    }
25226                }
25227            };
25228            let auth_header = Authorization(Bearer { token: token.access_token });
25229            let mut req_result = {
25230                let mut client = &mut *self.hub.client.borrow_mut();
25231                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
25232                    .header(UserAgent(self.hub._user_agent.clone()))
25233                    .header(auth_header.clone());
25234
25235                dlg.pre_request();
25236                req.send()
25237            };
25238
25239            match req_result {
25240                Err(err) => {
25241                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
25242                        sleep(d);
25243                        continue;
25244                    }
25245                    dlg.finished(false);
25246                    return Err(Error::HttpError(err))
25247                }
25248                Ok(mut res) => {
25249                    if !res.status.is_success() {
25250                        let mut json_err = String::new();
25251                        res.read_to_string(&mut json_err).unwrap();
25252                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
25253                                                              json::from_str(&json_err).ok(),
25254                                                              json::from_str(&json_err).ok()) {
25255                            sleep(d);
25256                            continue;
25257                        }
25258                        dlg.finished(false);
25259                        return match json::from_str::<ErrorResponse>(&json_err){
25260                            Err(_) => Err(Error::Failure(res)),
25261                            Ok(serr) => Err(Error::BadRequest(serr))
25262                        }
25263                    }
25264                    let result_value = res;
25265
25266                    dlg.finished(true);
25267                    return Ok(result_value)
25268                }
25269            }
25270        }
25271    }
25272
25273
25274    /// Immutable ID of the G Suite account
25275    ///
25276    /// Sets the *customer id* path property to the given value.
25277    ///
25278    /// Even though the property as already been set when instantiating this call,
25279    /// we provide this method for API completeness.
25280    pub fn customer_id(mut self, new_value: &str) -> SchemaDeleteCall<'a, C, A> {
25281        self._customer_id = new_value.to_string();
25282        self
25283    }
25284    /// Name or immutable ID of the schema
25285    ///
25286    /// Sets the *schema key* path property to the given value.
25287    ///
25288    /// Even though the property as already been set when instantiating this call,
25289    /// we provide this method for API completeness.
25290    pub fn schema_key(mut self, new_value: &str) -> SchemaDeleteCall<'a, C, A> {
25291        self._schema_key = new_value.to_string();
25292        self
25293    }
25294    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25295    /// while executing the actual API request.
25296    /// 
25297    /// It should be used to handle progress information, and to implement a certain level of resilience.
25298    ///
25299    /// Sets the *delegate* property to the given value.
25300    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SchemaDeleteCall<'a, C, A> {
25301        self._delegate = Some(new_value);
25302        self
25303    }
25304
25305    /// Set any additional parameter of the query string used in the request.
25306    /// It should be used to set parameters which are not yet available through their own
25307    /// setters.
25308    ///
25309    /// Please note that this method must not be used to set any of the known parameters
25310    /// which have their own setter method. If done anyway, the request will fail.
25311    ///
25312    /// # Additional Parameters
25313    ///
25314    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25315    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25316    /// * *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.
25317    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25318    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25319    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25320    /// * *alt* (query-string) - Data format for the response.
25321    pub fn param<T>(mut self, name: T, value: T) -> SchemaDeleteCall<'a, C, A>
25322                                                        where T: AsRef<str> {
25323        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
25324        self
25325    }
25326
25327    /// Identifies the authorization scope for the method you are building.
25328    ///
25329    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
25330    /// `Scope::DirectoryUserschema`.
25331    ///
25332    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25333    /// tokens for more than one scope.
25334    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
25335    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
25336    /// function for details).
25337    ///
25338    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25339    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25340    /// sufficient, a read-write scope will do as well.
25341    pub fn add_scope<T, S>(mut self, scope: T) -> SchemaDeleteCall<'a, C, A>
25342                                                        where T: Into<Option<S>>,
25343                                                              S: AsRef<str> {
25344        match scope.into() {
25345          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
25346          None => None,
25347        };
25348        self
25349    }
25350}
25351
25352
25353/// Retrieves a list of calendar resources for an account.
25354///
25355/// A builder for the *calendars.list* method supported by a *resource* resource.
25356/// It is not used directly, but through a `ResourceMethods` instance.
25357///
25358/// # Example
25359///
25360/// Instantiate a resource method builder
25361///
25362/// ```test_harness,no_run
25363/// # extern crate hyper;
25364/// # extern crate hyper_rustls;
25365/// # extern crate yup_oauth2 as oauth2;
25366/// # extern crate google_admin1_directory as admin1_directory;
25367/// # #[test] fn egal() {
25368/// # use std::default::Default;
25369/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
25370/// # use admin1_directory::Directory;
25371/// 
25372/// # let secret: ApplicationSecret = Default::default();
25373/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
25374/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
25375/// #                               <MemoryStorage as Default>::default(), None);
25376/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
25377/// // You can configure optional parameters by calling the respective setters at will, and
25378/// // execute the final call using `doit()`.
25379/// // Values shown here are possibly random and not representative !
25380/// let result = hub.resources().calendars_list("customer")
25381///              .query("no")
25382///              .page_token("invidunt")
25383///              .order_by("rebum.")
25384///              .max_results(-86)
25385///              .doit();
25386/// # }
25387/// ```
25388pub struct ResourceCalendarListCall<'a, C, A>
25389    where C: 'a, A: 'a {
25390
25391    hub: &'a Directory<C, A>,
25392    _customer: String,
25393    _query: Option<String>,
25394    _page_token: Option<String>,
25395    _order_by: Option<String>,
25396    _max_results: Option<i32>,
25397    _delegate: Option<&'a mut dyn Delegate>,
25398    _additional_params: HashMap<String, String>,
25399    _scopes: BTreeMap<String, ()>
25400}
25401
25402impl<'a, C, A> CallBuilder for ResourceCalendarListCall<'a, C, A> {}
25403
25404impl<'a, C, A> ResourceCalendarListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
25405
25406
25407    /// Perform the operation you have build so far.
25408    pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarResources)> {
25409        use std::io::{Read, Seek};
25410        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
25411        let mut dd = DefaultDelegate;
25412        let mut dlg: &mut dyn Delegate = match self._delegate {
25413            Some(d) => d,
25414            None => &mut dd
25415        };
25416        dlg.begin(MethodInfo { id: "directory.resources.calendars.list",
25417                               http_method: hyper::method::Method::Get });
25418        let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len());
25419        params.push(("customer", self._customer.to_string()));
25420        if let Some(value) = self._query {
25421            params.push(("query", value.to_string()));
25422        }
25423        if let Some(value) = self._page_token {
25424            params.push(("pageToken", value.to_string()));
25425        }
25426        if let Some(value) = self._order_by {
25427            params.push(("orderBy", value.to_string()));
25428        }
25429        if let Some(value) = self._max_results {
25430            params.push(("maxResults", value.to_string()));
25431        }
25432        for &field in ["alt", "customer", "query", "pageToken", "orderBy", "maxResults"].iter() {
25433            if self._additional_params.contains_key(field) {
25434                dlg.finished(false);
25435                return Err(Error::FieldClash(field));
25436            }
25437        }
25438        for (name, value) in self._additional_params.iter() {
25439            params.push((&name, value.clone()));
25440        }
25441
25442        params.push(("alt", "json".to_string()));
25443
25444        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/calendars";
25445        if self._scopes.len() == 0 {
25446            self._scopes.insert(Scope::DirectoryResourceCalendarReadonly.as_ref().to_string(), ());
25447        }
25448
25449        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
25450            let mut replace_with: Option<&str> = None;
25451            for &(name, ref value) in params.iter() {
25452                if name == param_name {
25453                    replace_with = Some(value);
25454                    break;
25455                }
25456            }
25457            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
25458        }
25459        {
25460            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
25461            for param_name in ["customer"].iter() {
25462                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
25463                    indices_for_removal.push(index);
25464                }
25465            }
25466            for &index in indices_for_removal.iter() {
25467                params.remove(index);
25468            }
25469        }
25470
25471        let url = hyper::Url::parse_with_params(&url, params).unwrap();
25472
25473
25474
25475        loop {
25476            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
25477                Ok(token) => token,
25478                Err(err) => {
25479                    match  dlg.token(&*err) {
25480                        Some(token) => token,
25481                        None => {
25482                            dlg.finished(false);
25483                            return Err(Error::MissingToken(err))
25484                        }
25485                    }
25486                }
25487            };
25488            let auth_header = Authorization(Bearer { token: token.access_token });
25489            let mut req_result = {
25490                let mut client = &mut *self.hub.client.borrow_mut();
25491                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
25492                    .header(UserAgent(self.hub._user_agent.clone()))
25493                    .header(auth_header.clone());
25494
25495                dlg.pre_request();
25496                req.send()
25497            };
25498
25499            match req_result {
25500                Err(err) => {
25501                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
25502                        sleep(d);
25503                        continue;
25504                    }
25505                    dlg.finished(false);
25506                    return Err(Error::HttpError(err))
25507                }
25508                Ok(mut res) => {
25509                    if !res.status.is_success() {
25510                        let mut json_err = String::new();
25511                        res.read_to_string(&mut json_err).unwrap();
25512                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
25513                                                              json::from_str(&json_err).ok(),
25514                                                              json::from_str(&json_err).ok()) {
25515                            sleep(d);
25516                            continue;
25517                        }
25518                        dlg.finished(false);
25519                        return match json::from_str::<ErrorResponse>(&json_err){
25520                            Err(_) => Err(Error::Failure(res)),
25521                            Ok(serr) => Err(Error::BadRequest(serr))
25522                        }
25523                    }
25524                    let result_value = {
25525                        let mut json_response = String::new();
25526                        res.read_to_string(&mut json_response).unwrap();
25527                        match json::from_str(&json_response) {
25528                            Ok(decoded) => (res, decoded),
25529                            Err(err) => {
25530                                dlg.response_json_decode_error(&json_response, &err);
25531                                return Err(Error::JsonDecodeError(json_response, err));
25532                            }
25533                        }
25534                    };
25535
25536                    dlg.finished(true);
25537                    return Ok(result_value)
25538                }
25539            }
25540        }
25541    }
25542
25543
25544    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
25545    ///
25546    /// Sets the *customer* path property to the given value.
25547    ///
25548    /// Even though the property as already been set when instantiating this call,
25549    /// we provide this method for API completeness.
25550    pub fn customer(mut self, new_value: &str) -> ResourceCalendarListCall<'a, C, A> {
25551        self._customer = new_value.to_string();
25552        self
25553    }
25554    /// String query used to filter results. Should be of the form "field operator value" where field can be any of supported fields and operators can be any of supported operations. Operators include '=' for exact match and ':' for prefix match or HAS match where applicable. For prefix match, the value should always be followed by a *. Supported fields include generatedResourceName, name, buildingId, featureInstances.feature.name. For example buildingId=US-NYC-9TH AND featureInstances.feature.name:Phone.
25555    ///
25556    /// Sets the *query* query property to the given value.
25557    pub fn query(mut self, new_value: &str) -> ResourceCalendarListCall<'a, C, A> {
25558        self._query = Some(new_value.to_string());
25559        self
25560    }
25561    /// Token to specify the next page in the list.
25562    ///
25563    /// Sets the *page token* query property to the given value.
25564    pub fn page_token(mut self, new_value: &str) -> ResourceCalendarListCall<'a, C, A> {
25565        self._page_token = Some(new_value.to_string());
25566        self
25567    }
25568    /// Field(s) to sort results by in either ascending or descending order. Supported fields include resourceId, resourceName, capacity, buildingId, and floorName. If no order is specified, defaults to ascending. Should be of the form "field [asc|desc], field [asc|desc], ...". For example buildingId, capacity desc would return results sorted first by buildingId in ascending order then by capacity in descending order.
25569    ///
25570    /// Sets the *order by* query property to the given value.
25571    pub fn order_by(mut self, new_value: &str) -> ResourceCalendarListCall<'a, C, A> {
25572        self._order_by = Some(new_value.to_string());
25573        self
25574    }
25575    /// Maximum number of results to return.
25576    ///
25577    /// Sets the *max results* query property to the given value.
25578    pub fn max_results(mut self, new_value: i32) -> ResourceCalendarListCall<'a, C, A> {
25579        self._max_results = Some(new_value);
25580        self
25581    }
25582    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25583    /// while executing the actual API request.
25584    /// 
25585    /// It should be used to handle progress information, and to implement a certain level of resilience.
25586    ///
25587    /// Sets the *delegate* property to the given value.
25588    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceCalendarListCall<'a, C, A> {
25589        self._delegate = Some(new_value);
25590        self
25591    }
25592
25593    /// Set any additional parameter of the query string used in the request.
25594    /// It should be used to set parameters which are not yet available through their own
25595    /// setters.
25596    ///
25597    /// Please note that this method must not be used to set any of the known parameters
25598    /// which have their own setter method. If done anyway, the request will fail.
25599    ///
25600    /// # Additional Parameters
25601    ///
25602    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25603    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25604    /// * *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.
25605    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25606    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25607    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25608    /// * *alt* (query-string) - Data format for the response.
25609    pub fn param<T>(mut self, name: T, value: T) -> ResourceCalendarListCall<'a, C, A>
25610                                                        where T: AsRef<str> {
25611        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
25612        self
25613    }
25614
25615    /// Identifies the authorization scope for the method you are building.
25616    ///
25617    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
25618    /// `Scope::DirectoryResourceCalendarReadonly`.
25619    ///
25620    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25621    /// tokens for more than one scope.
25622    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
25623    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
25624    /// function for details).
25625    ///
25626    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25627    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25628    /// sufficient, a read-write scope will do as well.
25629    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceCalendarListCall<'a, C, A>
25630                                                        where T: Into<Option<S>>,
25631                                                              S: AsRef<str> {
25632        match scope.into() {
25633          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
25634          None => None,
25635        };
25636        self
25637    }
25638}
25639
25640
25641/// Renames a feature.
25642///
25643/// A builder for the *features.rename* method supported by a *resource* resource.
25644/// It is not used directly, but through a `ResourceMethods` instance.
25645///
25646/// # Example
25647///
25648/// Instantiate a resource method builder
25649///
25650/// ```test_harness,no_run
25651/// # extern crate hyper;
25652/// # extern crate hyper_rustls;
25653/// # extern crate yup_oauth2 as oauth2;
25654/// # extern crate google_admin1_directory as admin1_directory;
25655/// use admin1_directory::FeatureRename;
25656/// # #[test] fn egal() {
25657/// # use std::default::Default;
25658/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
25659/// # use admin1_directory::Directory;
25660/// 
25661/// # let secret: ApplicationSecret = Default::default();
25662/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
25663/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
25664/// #                               <MemoryStorage as Default>::default(), None);
25665/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
25666/// // As the method needs a request, you would usually fill it with the desired information
25667/// // into the respective structure. Some of the parts shown here might not be applicable !
25668/// // Values shown here are possibly random and not representative !
25669/// let mut req = FeatureRename::default();
25670/// 
25671/// // You can configure optional parameters by calling the respective setters at will, and
25672/// // execute the final call using `doit()`.
25673/// // Values shown here are possibly random and not representative !
25674/// let result = hub.resources().features_rename(req, "customer", "oldName")
25675///              .doit();
25676/// # }
25677/// ```
25678pub struct ResourceFeatureRenameCall<'a, C, A>
25679    where C: 'a, A: 'a {
25680
25681    hub: &'a Directory<C, A>,
25682    _request: FeatureRename,
25683    _customer: String,
25684    _old_name: String,
25685    _delegate: Option<&'a mut dyn Delegate>,
25686    _additional_params: HashMap<String, String>,
25687    _scopes: BTreeMap<String, ()>
25688}
25689
25690impl<'a, C, A> CallBuilder for ResourceFeatureRenameCall<'a, C, A> {}
25691
25692impl<'a, C, A> ResourceFeatureRenameCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
25693
25694
25695    /// Perform the operation you have build so far.
25696    pub fn doit(mut self) -> Result<hyper::client::Response> {
25697        use std::io::{Read, Seek};
25698        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
25699        let mut dd = DefaultDelegate;
25700        let mut dlg: &mut dyn Delegate = match self._delegate {
25701            Some(d) => d,
25702            None => &mut dd
25703        };
25704        dlg.begin(MethodInfo { id: "directory.resources.features.rename",
25705                               http_method: hyper::method::Method::Post });
25706        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
25707        params.push(("customer", self._customer.to_string()));
25708        params.push(("oldName", self._old_name.to_string()));
25709        for &field in ["customer", "oldName"].iter() {
25710            if self._additional_params.contains_key(field) {
25711                dlg.finished(false);
25712                return Err(Error::FieldClash(field));
25713            }
25714        }
25715        for (name, value) in self._additional_params.iter() {
25716            params.push((&name, value.clone()));
25717        }
25718
25719
25720        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/features/{oldName}/rename";
25721        if self._scopes.len() == 0 {
25722            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
25723        }
25724
25725        for &(find_this, param_name) in [("{customer}", "customer"), ("{oldName}", "oldName")].iter() {
25726            let mut replace_with: Option<&str> = None;
25727            for &(name, ref value) in params.iter() {
25728                if name == param_name {
25729                    replace_with = Some(value);
25730                    break;
25731                }
25732            }
25733            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
25734        }
25735        {
25736            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
25737            for param_name in ["oldName", "customer"].iter() {
25738                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
25739                    indices_for_removal.push(index);
25740                }
25741            }
25742            for &index in indices_for_removal.iter() {
25743                params.remove(index);
25744            }
25745        }
25746
25747        let url = hyper::Url::parse_with_params(&url, params).unwrap();
25748
25749        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
25750        let mut request_value_reader =
25751            {
25752                let mut value = json::value::to_value(&self._request).expect("serde to work");
25753                remove_json_null_values(&mut value);
25754                let mut dst = io::Cursor::new(Vec::with_capacity(128));
25755                json::to_writer(&mut dst, &value).unwrap();
25756                dst
25757            };
25758        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
25759        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
25760
25761
25762        loop {
25763            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
25764                Ok(token) => token,
25765                Err(err) => {
25766                    match  dlg.token(&*err) {
25767                        Some(token) => token,
25768                        None => {
25769                            dlg.finished(false);
25770                            return Err(Error::MissingToken(err))
25771                        }
25772                    }
25773                }
25774            };
25775            let auth_header = Authorization(Bearer { token: token.access_token });
25776            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
25777            let mut req_result = {
25778                let mut client = &mut *self.hub.client.borrow_mut();
25779                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
25780                    .header(UserAgent(self.hub._user_agent.clone()))
25781                    .header(auth_header.clone())
25782                    .header(ContentType(json_mime_type.clone()))
25783                    .header(ContentLength(request_size as u64))
25784                    .body(&mut request_value_reader);
25785
25786                dlg.pre_request();
25787                req.send()
25788            };
25789
25790            match req_result {
25791                Err(err) => {
25792                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
25793                        sleep(d);
25794                        continue;
25795                    }
25796                    dlg.finished(false);
25797                    return Err(Error::HttpError(err))
25798                }
25799                Ok(mut res) => {
25800                    if !res.status.is_success() {
25801                        let mut json_err = String::new();
25802                        res.read_to_string(&mut json_err).unwrap();
25803                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
25804                                                              json::from_str(&json_err).ok(),
25805                                                              json::from_str(&json_err).ok()) {
25806                            sleep(d);
25807                            continue;
25808                        }
25809                        dlg.finished(false);
25810                        return match json::from_str::<ErrorResponse>(&json_err){
25811                            Err(_) => Err(Error::Failure(res)),
25812                            Ok(serr) => Err(Error::BadRequest(serr))
25813                        }
25814                    }
25815                    let result_value = res;
25816
25817                    dlg.finished(true);
25818                    return Ok(result_value)
25819                }
25820            }
25821        }
25822    }
25823
25824
25825    ///
25826    /// Sets the *request* property to the given value.
25827    ///
25828    /// Even though the property as already been set when instantiating this call,
25829    /// we provide this method for API completeness.
25830    pub fn request(mut self, new_value: FeatureRename) -> ResourceFeatureRenameCall<'a, C, A> {
25831        self._request = new_value;
25832        self
25833    }
25834    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
25835    ///
25836    /// Sets the *customer* path property to the given value.
25837    ///
25838    /// Even though the property as already been set when instantiating this call,
25839    /// we provide this method for API completeness.
25840    pub fn customer(mut self, new_value: &str) -> ResourceFeatureRenameCall<'a, C, A> {
25841        self._customer = new_value.to_string();
25842        self
25843    }
25844    /// The unique ID of the feature to rename.
25845    ///
25846    /// Sets the *old name* path property to the given value.
25847    ///
25848    /// Even though the property as already been set when instantiating this call,
25849    /// we provide this method for API completeness.
25850    pub fn old_name(mut self, new_value: &str) -> ResourceFeatureRenameCall<'a, C, A> {
25851        self._old_name = new_value.to_string();
25852        self
25853    }
25854    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25855    /// while executing the actual API request.
25856    /// 
25857    /// It should be used to handle progress information, and to implement a certain level of resilience.
25858    ///
25859    /// Sets the *delegate* property to the given value.
25860    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceFeatureRenameCall<'a, C, A> {
25861        self._delegate = Some(new_value);
25862        self
25863    }
25864
25865    /// Set any additional parameter of the query string used in the request.
25866    /// It should be used to set parameters which are not yet available through their own
25867    /// setters.
25868    ///
25869    /// Please note that this method must not be used to set any of the known parameters
25870    /// which have their own setter method. If done anyway, the request will fail.
25871    ///
25872    /// # Additional Parameters
25873    ///
25874    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25875    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25876    /// * *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.
25877    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25878    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25879    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25880    /// * *alt* (query-string) - Data format for the response.
25881    pub fn param<T>(mut self, name: T, value: T) -> ResourceFeatureRenameCall<'a, C, A>
25882                                                        where T: AsRef<str> {
25883        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
25884        self
25885    }
25886
25887    /// Identifies the authorization scope for the method you are building.
25888    ///
25889    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
25890    /// `Scope::DirectoryResourceCalendar`.
25891    ///
25892    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25893    /// tokens for more than one scope.
25894    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
25895    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
25896    /// function for details).
25897    ///
25898    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25899    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25900    /// sufficient, a read-write scope will do as well.
25901    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceFeatureRenameCall<'a, C, A>
25902                                                        where T: Into<Option<S>>,
25903                                                              S: AsRef<str> {
25904        match scope.into() {
25905          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
25906          None => None,
25907        };
25908        self
25909    }
25910}
25911
25912
25913/// Inserts a feature.
25914///
25915/// A builder for the *features.insert* method supported by a *resource* resource.
25916/// It is not used directly, but through a `ResourceMethods` instance.
25917///
25918/// # Example
25919///
25920/// Instantiate a resource method builder
25921///
25922/// ```test_harness,no_run
25923/// # extern crate hyper;
25924/// # extern crate hyper_rustls;
25925/// # extern crate yup_oauth2 as oauth2;
25926/// # extern crate google_admin1_directory as admin1_directory;
25927/// use admin1_directory::Feature;
25928/// # #[test] fn egal() {
25929/// # use std::default::Default;
25930/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
25931/// # use admin1_directory::Directory;
25932/// 
25933/// # let secret: ApplicationSecret = Default::default();
25934/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
25935/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
25936/// #                               <MemoryStorage as Default>::default(), None);
25937/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
25938/// // As the method needs a request, you would usually fill it with the desired information
25939/// // into the respective structure. Some of the parts shown here might not be applicable !
25940/// // Values shown here are possibly random and not representative !
25941/// let mut req = Feature::default();
25942/// 
25943/// // You can configure optional parameters by calling the respective setters at will, and
25944/// // execute the final call using `doit()`.
25945/// // Values shown here are possibly random and not representative !
25946/// let result = hub.resources().features_insert(req, "customer")
25947///              .doit();
25948/// # }
25949/// ```
25950pub struct ResourceFeatureInsertCall<'a, C, A>
25951    where C: 'a, A: 'a {
25952
25953    hub: &'a Directory<C, A>,
25954    _request: Feature,
25955    _customer: String,
25956    _delegate: Option<&'a mut dyn Delegate>,
25957    _additional_params: HashMap<String, String>,
25958    _scopes: BTreeMap<String, ()>
25959}
25960
25961impl<'a, C, A> CallBuilder for ResourceFeatureInsertCall<'a, C, A> {}
25962
25963impl<'a, C, A> ResourceFeatureInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
25964
25965
25966    /// Perform the operation you have build so far.
25967    pub fn doit(mut self) -> Result<(hyper::client::Response, Feature)> {
25968        use std::io::{Read, Seek};
25969        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
25970        let mut dd = DefaultDelegate;
25971        let mut dlg: &mut dyn Delegate = match self._delegate {
25972            Some(d) => d,
25973            None => &mut dd
25974        };
25975        dlg.begin(MethodInfo { id: "directory.resources.features.insert",
25976                               http_method: hyper::method::Method::Post });
25977        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
25978        params.push(("customer", self._customer.to_string()));
25979        for &field in ["alt", "customer"].iter() {
25980            if self._additional_params.contains_key(field) {
25981                dlg.finished(false);
25982                return Err(Error::FieldClash(field));
25983            }
25984        }
25985        for (name, value) in self._additional_params.iter() {
25986            params.push((&name, value.clone()));
25987        }
25988
25989        params.push(("alt", "json".to_string()));
25990
25991        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/features";
25992        if self._scopes.len() == 0 {
25993            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
25994        }
25995
25996        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
25997            let mut replace_with: Option<&str> = None;
25998            for &(name, ref value) in params.iter() {
25999                if name == param_name {
26000                    replace_with = Some(value);
26001                    break;
26002                }
26003            }
26004            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
26005        }
26006        {
26007            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
26008            for param_name in ["customer"].iter() {
26009                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
26010                    indices_for_removal.push(index);
26011                }
26012            }
26013            for &index in indices_for_removal.iter() {
26014                params.remove(index);
26015            }
26016        }
26017
26018        let url = hyper::Url::parse_with_params(&url, params).unwrap();
26019
26020        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
26021        let mut request_value_reader =
26022            {
26023                let mut value = json::value::to_value(&self._request).expect("serde to work");
26024                remove_json_null_values(&mut value);
26025                let mut dst = io::Cursor::new(Vec::with_capacity(128));
26026                json::to_writer(&mut dst, &value).unwrap();
26027                dst
26028            };
26029        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
26030        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
26031
26032
26033        loop {
26034            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
26035                Ok(token) => token,
26036                Err(err) => {
26037                    match  dlg.token(&*err) {
26038                        Some(token) => token,
26039                        None => {
26040                            dlg.finished(false);
26041                            return Err(Error::MissingToken(err))
26042                        }
26043                    }
26044                }
26045            };
26046            let auth_header = Authorization(Bearer { token: token.access_token });
26047            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
26048            let mut req_result = {
26049                let mut client = &mut *self.hub.client.borrow_mut();
26050                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
26051                    .header(UserAgent(self.hub._user_agent.clone()))
26052                    .header(auth_header.clone())
26053                    .header(ContentType(json_mime_type.clone()))
26054                    .header(ContentLength(request_size as u64))
26055                    .body(&mut request_value_reader);
26056
26057                dlg.pre_request();
26058                req.send()
26059            };
26060
26061            match req_result {
26062                Err(err) => {
26063                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
26064                        sleep(d);
26065                        continue;
26066                    }
26067                    dlg.finished(false);
26068                    return Err(Error::HttpError(err))
26069                }
26070                Ok(mut res) => {
26071                    if !res.status.is_success() {
26072                        let mut json_err = String::new();
26073                        res.read_to_string(&mut json_err).unwrap();
26074                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
26075                                                              json::from_str(&json_err).ok(),
26076                                                              json::from_str(&json_err).ok()) {
26077                            sleep(d);
26078                            continue;
26079                        }
26080                        dlg.finished(false);
26081                        return match json::from_str::<ErrorResponse>(&json_err){
26082                            Err(_) => Err(Error::Failure(res)),
26083                            Ok(serr) => Err(Error::BadRequest(serr))
26084                        }
26085                    }
26086                    let result_value = {
26087                        let mut json_response = String::new();
26088                        res.read_to_string(&mut json_response).unwrap();
26089                        match json::from_str(&json_response) {
26090                            Ok(decoded) => (res, decoded),
26091                            Err(err) => {
26092                                dlg.response_json_decode_error(&json_response, &err);
26093                                return Err(Error::JsonDecodeError(json_response, err));
26094                            }
26095                        }
26096                    };
26097
26098                    dlg.finished(true);
26099                    return Ok(result_value)
26100                }
26101            }
26102        }
26103    }
26104
26105
26106    ///
26107    /// Sets the *request* property to the given value.
26108    ///
26109    /// Even though the property as already been set when instantiating this call,
26110    /// we provide this method for API completeness.
26111    pub fn request(mut self, new_value: Feature) -> ResourceFeatureInsertCall<'a, C, A> {
26112        self._request = new_value;
26113        self
26114    }
26115    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
26116    ///
26117    /// Sets the *customer* path property to the given value.
26118    ///
26119    /// Even though the property as already been set when instantiating this call,
26120    /// we provide this method for API completeness.
26121    pub fn customer(mut self, new_value: &str) -> ResourceFeatureInsertCall<'a, C, A> {
26122        self._customer = new_value.to_string();
26123        self
26124    }
26125    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26126    /// while executing the actual API request.
26127    /// 
26128    /// It should be used to handle progress information, and to implement a certain level of resilience.
26129    ///
26130    /// Sets the *delegate* property to the given value.
26131    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceFeatureInsertCall<'a, C, A> {
26132        self._delegate = Some(new_value);
26133        self
26134    }
26135
26136    /// Set any additional parameter of the query string used in the request.
26137    /// It should be used to set parameters which are not yet available through their own
26138    /// setters.
26139    ///
26140    /// Please note that this method must not be used to set any of the known parameters
26141    /// which have their own setter method. If done anyway, the request will fail.
26142    ///
26143    /// # Additional Parameters
26144    ///
26145    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26146    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26147    /// * *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.
26148    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26149    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26150    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26151    /// * *alt* (query-string) - Data format for the response.
26152    pub fn param<T>(mut self, name: T, value: T) -> ResourceFeatureInsertCall<'a, C, A>
26153                                                        where T: AsRef<str> {
26154        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
26155        self
26156    }
26157
26158    /// Identifies the authorization scope for the method you are building.
26159    ///
26160    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
26161    /// `Scope::DirectoryResourceCalendar`.
26162    ///
26163    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26164    /// tokens for more than one scope.
26165    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
26166    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
26167    /// function for details).
26168    ///
26169    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26170    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26171    /// sufficient, a read-write scope will do as well.
26172    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceFeatureInsertCall<'a, C, A>
26173                                                        where T: Into<Option<S>>,
26174                                                              S: AsRef<str> {
26175        match scope.into() {
26176          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
26177          None => None,
26178        };
26179        self
26180    }
26181}
26182
26183
26184/// Updates a building.
26185///
26186/// A builder for the *buildings.update* method supported by a *resource* resource.
26187/// It is not used directly, but through a `ResourceMethods` instance.
26188///
26189/// # Example
26190///
26191/// Instantiate a resource method builder
26192///
26193/// ```test_harness,no_run
26194/// # extern crate hyper;
26195/// # extern crate hyper_rustls;
26196/// # extern crate yup_oauth2 as oauth2;
26197/// # extern crate google_admin1_directory as admin1_directory;
26198/// use admin1_directory::Building;
26199/// # #[test] fn egal() {
26200/// # use std::default::Default;
26201/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
26202/// # use admin1_directory::Directory;
26203/// 
26204/// # let secret: ApplicationSecret = Default::default();
26205/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
26206/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
26207/// #                               <MemoryStorage as Default>::default(), None);
26208/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
26209/// // As the method needs a request, you would usually fill it with the desired information
26210/// // into the respective structure. Some of the parts shown here might not be applicable !
26211/// // Values shown here are possibly random and not representative !
26212/// let mut req = Building::default();
26213/// 
26214/// // You can configure optional parameters by calling the respective setters at will, and
26215/// // execute the final call using `doit()`.
26216/// // Values shown here are possibly random and not representative !
26217/// let result = hub.resources().buildings_update(req, "customer", "buildingId")
26218///              .coordinates_source("At")
26219///              .doit();
26220/// # }
26221/// ```
26222pub struct ResourceBuildingUpdateCall<'a, C, A>
26223    where C: 'a, A: 'a {
26224
26225    hub: &'a Directory<C, A>,
26226    _request: Building,
26227    _customer: String,
26228    _building_id: String,
26229    _coordinates_source: Option<String>,
26230    _delegate: Option<&'a mut dyn Delegate>,
26231    _additional_params: HashMap<String, String>,
26232    _scopes: BTreeMap<String, ()>
26233}
26234
26235impl<'a, C, A> CallBuilder for ResourceBuildingUpdateCall<'a, C, A> {}
26236
26237impl<'a, C, A> ResourceBuildingUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
26238
26239
26240    /// Perform the operation you have build so far.
26241    pub fn doit(mut self) -> Result<(hyper::client::Response, Building)> {
26242        use std::io::{Read, Seek};
26243        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
26244        let mut dd = DefaultDelegate;
26245        let mut dlg: &mut dyn Delegate = match self._delegate {
26246            Some(d) => d,
26247            None => &mut dd
26248        };
26249        dlg.begin(MethodInfo { id: "directory.resources.buildings.update",
26250                               http_method: hyper::method::Method::Put });
26251        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
26252        params.push(("customer", self._customer.to_string()));
26253        params.push(("buildingId", self._building_id.to_string()));
26254        if let Some(value) = self._coordinates_source {
26255            params.push(("coordinatesSource", value.to_string()));
26256        }
26257        for &field in ["alt", "customer", "buildingId", "coordinatesSource"].iter() {
26258            if self._additional_params.contains_key(field) {
26259                dlg.finished(false);
26260                return Err(Error::FieldClash(field));
26261            }
26262        }
26263        for (name, value) in self._additional_params.iter() {
26264            params.push((&name, value.clone()));
26265        }
26266
26267        params.push(("alt", "json".to_string()));
26268
26269        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/buildings/{buildingId}";
26270        if self._scopes.len() == 0 {
26271            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
26272        }
26273
26274        for &(find_this, param_name) in [("{customer}", "customer"), ("{buildingId}", "buildingId")].iter() {
26275            let mut replace_with: Option<&str> = None;
26276            for &(name, ref value) in params.iter() {
26277                if name == param_name {
26278                    replace_with = Some(value);
26279                    break;
26280                }
26281            }
26282            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
26283        }
26284        {
26285            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
26286            for param_name in ["buildingId", "customer"].iter() {
26287                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
26288                    indices_for_removal.push(index);
26289                }
26290            }
26291            for &index in indices_for_removal.iter() {
26292                params.remove(index);
26293            }
26294        }
26295
26296        let url = hyper::Url::parse_with_params(&url, params).unwrap();
26297
26298        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
26299        let mut request_value_reader =
26300            {
26301                let mut value = json::value::to_value(&self._request).expect("serde to work");
26302                remove_json_null_values(&mut value);
26303                let mut dst = io::Cursor::new(Vec::with_capacity(128));
26304                json::to_writer(&mut dst, &value).unwrap();
26305                dst
26306            };
26307        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
26308        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
26309
26310
26311        loop {
26312            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
26313                Ok(token) => token,
26314                Err(err) => {
26315                    match  dlg.token(&*err) {
26316                        Some(token) => token,
26317                        None => {
26318                            dlg.finished(false);
26319                            return Err(Error::MissingToken(err))
26320                        }
26321                    }
26322                }
26323            };
26324            let auth_header = Authorization(Bearer { token: token.access_token });
26325            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
26326            let mut req_result = {
26327                let mut client = &mut *self.hub.client.borrow_mut();
26328                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
26329                    .header(UserAgent(self.hub._user_agent.clone()))
26330                    .header(auth_header.clone())
26331                    .header(ContentType(json_mime_type.clone()))
26332                    .header(ContentLength(request_size as u64))
26333                    .body(&mut request_value_reader);
26334
26335                dlg.pre_request();
26336                req.send()
26337            };
26338
26339            match req_result {
26340                Err(err) => {
26341                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
26342                        sleep(d);
26343                        continue;
26344                    }
26345                    dlg.finished(false);
26346                    return Err(Error::HttpError(err))
26347                }
26348                Ok(mut res) => {
26349                    if !res.status.is_success() {
26350                        let mut json_err = String::new();
26351                        res.read_to_string(&mut json_err).unwrap();
26352                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
26353                                                              json::from_str(&json_err).ok(),
26354                                                              json::from_str(&json_err).ok()) {
26355                            sleep(d);
26356                            continue;
26357                        }
26358                        dlg.finished(false);
26359                        return match json::from_str::<ErrorResponse>(&json_err){
26360                            Err(_) => Err(Error::Failure(res)),
26361                            Ok(serr) => Err(Error::BadRequest(serr))
26362                        }
26363                    }
26364                    let result_value = {
26365                        let mut json_response = String::new();
26366                        res.read_to_string(&mut json_response).unwrap();
26367                        match json::from_str(&json_response) {
26368                            Ok(decoded) => (res, decoded),
26369                            Err(err) => {
26370                                dlg.response_json_decode_error(&json_response, &err);
26371                                return Err(Error::JsonDecodeError(json_response, err));
26372                            }
26373                        }
26374                    };
26375
26376                    dlg.finished(true);
26377                    return Ok(result_value)
26378                }
26379            }
26380        }
26381    }
26382
26383
26384    ///
26385    /// Sets the *request* property to the given value.
26386    ///
26387    /// Even though the property as already been set when instantiating this call,
26388    /// we provide this method for API completeness.
26389    pub fn request(mut self, new_value: Building) -> ResourceBuildingUpdateCall<'a, C, A> {
26390        self._request = new_value;
26391        self
26392    }
26393    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
26394    ///
26395    /// Sets the *customer* path property to the given value.
26396    ///
26397    /// Even though the property as already been set when instantiating this call,
26398    /// we provide this method for API completeness.
26399    pub fn customer(mut self, new_value: &str) -> ResourceBuildingUpdateCall<'a, C, A> {
26400        self._customer = new_value.to_string();
26401        self
26402    }
26403    /// The ID of the building to update.
26404    ///
26405    /// Sets the *building id* path property to the given value.
26406    ///
26407    /// Even though the property as already been set when instantiating this call,
26408    /// we provide this method for API completeness.
26409    pub fn building_id(mut self, new_value: &str) -> ResourceBuildingUpdateCall<'a, C, A> {
26410        self._building_id = new_value.to_string();
26411        self
26412    }
26413    /// Source from which Building.coordinates are derived.
26414    ///
26415    /// Sets the *coordinates source* query property to the given value.
26416    pub fn coordinates_source(mut self, new_value: &str) -> ResourceBuildingUpdateCall<'a, C, A> {
26417        self._coordinates_source = Some(new_value.to_string());
26418        self
26419    }
26420    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26421    /// while executing the actual API request.
26422    /// 
26423    /// It should be used to handle progress information, and to implement a certain level of resilience.
26424    ///
26425    /// Sets the *delegate* property to the given value.
26426    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceBuildingUpdateCall<'a, C, A> {
26427        self._delegate = Some(new_value);
26428        self
26429    }
26430
26431    /// Set any additional parameter of the query string used in the request.
26432    /// It should be used to set parameters which are not yet available through their own
26433    /// setters.
26434    ///
26435    /// Please note that this method must not be used to set any of the known parameters
26436    /// which have their own setter method. If done anyway, the request will fail.
26437    ///
26438    /// # Additional Parameters
26439    ///
26440    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26441    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26442    /// * *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.
26443    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26444    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26445    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26446    /// * *alt* (query-string) - Data format for the response.
26447    pub fn param<T>(mut self, name: T, value: T) -> ResourceBuildingUpdateCall<'a, C, A>
26448                                                        where T: AsRef<str> {
26449        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
26450        self
26451    }
26452
26453    /// Identifies the authorization scope for the method you are building.
26454    ///
26455    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
26456    /// `Scope::DirectoryResourceCalendar`.
26457    ///
26458    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26459    /// tokens for more than one scope.
26460    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
26461    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
26462    /// function for details).
26463    ///
26464    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26465    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26466    /// sufficient, a read-write scope will do as well.
26467    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceBuildingUpdateCall<'a, C, A>
26468                                                        where T: Into<Option<S>>,
26469                                                              S: AsRef<str> {
26470        match scope.into() {
26471          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
26472          None => None,
26473        };
26474        self
26475    }
26476}
26477
26478
26479/// Deletes a building.
26480///
26481/// A builder for the *buildings.delete* method supported by a *resource* resource.
26482/// It is not used directly, but through a `ResourceMethods` instance.
26483///
26484/// # Example
26485///
26486/// Instantiate a resource method builder
26487///
26488/// ```test_harness,no_run
26489/// # extern crate hyper;
26490/// # extern crate hyper_rustls;
26491/// # extern crate yup_oauth2 as oauth2;
26492/// # extern crate google_admin1_directory as admin1_directory;
26493/// # #[test] fn egal() {
26494/// # use std::default::Default;
26495/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
26496/// # use admin1_directory::Directory;
26497/// 
26498/// # let secret: ApplicationSecret = Default::default();
26499/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
26500/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
26501/// #                               <MemoryStorage as Default>::default(), None);
26502/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
26503/// // You can configure optional parameters by calling the respective setters at will, and
26504/// // execute the final call using `doit()`.
26505/// // Values shown here are possibly random and not representative !
26506/// let result = hub.resources().buildings_delete("customer", "buildingId")
26507///              .doit();
26508/// # }
26509/// ```
26510pub struct ResourceBuildingDeleteCall<'a, C, A>
26511    where C: 'a, A: 'a {
26512
26513    hub: &'a Directory<C, A>,
26514    _customer: String,
26515    _building_id: String,
26516    _delegate: Option<&'a mut dyn Delegate>,
26517    _additional_params: HashMap<String, String>,
26518    _scopes: BTreeMap<String, ()>
26519}
26520
26521impl<'a, C, A> CallBuilder for ResourceBuildingDeleteCall<'a, C, A> {}
26522
26523impl<'a, C, A> ResourceBuildingDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
26524
26525
26526    /// Perform the operation you have build so far.
26527    pub fn doit(mut self) -> Result<hyper::client::Response> {
26528        use std::io::{Read, Seek};
26529        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
26530        let mut dd = DefaultDelegate;
26531        let mut dlg: &mut dyn Delegate = match self._delegate {
26532            Some(d) => d,
26533            None => &mut dd
26534        };
26535        dlg.begin(MethodInfo { id: "directory.resources.buildings.delete",
26536                               http_method: hyper::method::Method::Delete });
26537        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
26538        params.push(("customer", self._customer.to_string()));
26539        params.push(("buildingId", self._building_id.to_string()));
26540        for &field in ["customer", "buildingId"].iter() {
26541            if self._additional_params.contains_key(field) {
26542                dlg.finished(false);
26543                return Err(Error::FieldClash(field));
26544            }
26545        }
26546        for (name, value) in self._additional_params.iter() {
26547            params.push((&name, value.clone()));
26548        }
26549
26550
26551        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/buildings/{buildingId}";
26552        if self._scopes.len() == 0 {
26553            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
26554        }
26555
26556        for &(find_this, param_name) in [("{customer}", "customer"), ("{buildingId}", "buildingId")].iter() {
26557            let mut replace_with: Option<&str> = None;
26558            for &(name, ref value) in params.iter() {
26559                if name == param_name {
26560                    replace_with = Some(value);
26561                    break;
26562                }
26563            }
26564            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
26565        }
26566        {
26567            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
26568            for param_name in ["buildingId", "customer"].iter() {
26569                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
26570                    indices_for_removal.push(index);
26571                }
26572            }
26573            for &index in indices_for_removal.iter() {
26574                params.remove(index);
26575            }
26576        }
26577
26578        let url = hyper::Url::parse_with_params(&url, params).unwrap();
26579
26580
26581
26582        loop {
26583            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
26584                Ok(token) => token,
26585                Err(err) => {
26586                    match  dlg.token(&*err) {
26587                        Some(token) => token,
26588                        None => {
26589                            dlg.finished(false);
26590                            return Err(Error::MissingToken(err))
26591                        }
26592                    }
26593                }
26594            };
26595            let auth_header = Authorization(Bearer { token: token.access_token });
26596            let mut req_result = {
26597                let mut client = &mut *self.hub.client.borrow_mut();
26598                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
26599                    .header(UserAgent(self.hub._user_agent.clone()))
26600                    .header(auth_header.clone());
26601
26602                dlg.pre_request();
26603                req.send()
26604            };
26605
26606            match req_result {
26607                Err(err) => {
26608                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
26609                        sleep(d);
26610                        continue;
26611                    }
26612                    dlg.finished(false);
26613                    return Err(Error::HttpError(err))
26614                }
26615                Ok(mut res) => {
26616                    if !res.status.is_success() {
26617                        let mut json_err = String::new();
26618                        res.read_to_string(&mut json_err).unwrap();
26619                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
26620                                                              json::from_str(&json_err).ok(),
26621                                                              json::from_str(&json_err).ok()) {
26622                            sleep(d);
26623                            continue;
26624                        }
26625                        dlg.finished(false);
26626                        return match json::from_str::<ErrorResponse>(&json_err){
26627                            Err(_) => Err(Error::Failure(res)),
26628                            Ok(serr) => Err(Error::BadRequest(serr))
26629                        }
26630                    }
26631                    let result_value = res;
26632
26633                    dlg.finished(true);
26634                    return Ok(result_value)
26635                }
26636            }
26637        }
26638    }
26639
26640
26641    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
26642    ///
26643    /// Sets the *customer* path property to the given value.
26644    ///
26645    /// Even though the property as already been set when instantiating this call,
26646    /// we provide this method for API completeness.
26647    pub fn customer(mut self, new_value: &str) -> ResourceBuildingDeleteCall<'a, C, A> {
26648        self._customer = new_value.to_string();
26649        self
26650    }
26651    /// The ID of the building to delete.
26652    ///
26653    /// Sets the *building id* path property to the given value.
26654    ///
26655    /// Even though the property as already been set when instantiating this call,
26656    /// we provide this method for API completeness.
26657    pub fn building_id(mut self, new_value: &str) -> ResourceBuildingDeleteCall<'a, C, A> {
26658        self._building_id = new_value.to_string();
26659        self
26660    }
26661    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26662    /// while executing the actual API request.
26663    /// 
26664    /// It should be used to handle progress information, and to implement a certain level of resilience.
26665    ///
26666    /// Sets the *delegate* property to the given value.
26667    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceBuildingDeleteCall<'a, C, A> {
26668        self._delegate = Some(new_value);
26669        self
26670    }
26671
26672    /// Set any additional parameter of the query string used in the request.
26673    /// It should be used to set parameters which are not yet available through their own
26674    /// setters.
26675    ///
26676    /// Please note that this method must not be used to set any of the known parameters
26677    /// which have their own setter method. If done anyway, the request will fail.
26678    ///
26679    /// # Additional Parameters
26680    ///
26681    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26682    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26683    /// * *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.
26684    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26685    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26686    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26687    /// * *alt* (query-string) - Data format for the response.
26688    pub fn param<T>(mut self, name: T, value: T) -> ResourceBuildingDeleteCall<'a, C, A>
26689                                                        where T: AsRef<str> {
26690        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
26691        self
26692    }
26693
26694    /// Identifies the authorization scope for the method you are building.
26695    ///
26696    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
26697    /// `Scope::DirectoryResourceCalendar`.
26698    ///
26699    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26700    /// tokens for more than one scope.
26701    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
26702    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
26703    /// function for details).
26704    ///
26705    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26706    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26707    /// sufficient, a read-write scope will do as well.
26708    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceBuildingDeleteCall<'a, C, A>
26709                                                        where T: Into<Option<S>>,
26710                                                              S: AsRef<str> {
26711        match scope.into() {
26712          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
26713          None => None,
26714        };
26715        self
26716    }
26717}
26718
26719
26720/// Retrieves a list of features for an account.
26721///
26722/// A builder for the *features.list* method supported by a *resource* resource.
26723/// It is not used directly, but through a `ResourceMethods` instance.
26724///
26725/// # Example
26726///
26727/// Instantiate a resource method builder
26728///
26729/// ```test_harness,no_run
26730/// # extern crate hyper;
26731/// # extern crate hyper_rustls;
26732/// # extern crate yup_oauth2 as oauth2;
26733/// # extern crate google_admin1_directory as admin1_directory;
26734/// # #[test] fn egal() {
26735/// # use std::default::Default;
26736/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
26737/// # use admin1_directory::Directory;
26738/// 
26739/// # let secret: ApplicationSecret = Default::default();
26740/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
26741/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
26742/// #                               <MemoryStorage as Default>::default(), None);
26743/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
26744/// // You can configure optional parameters by calling the respective setters at will, and
26745/// // execute the final call using `doit()`.
26746/// // Values shown here are possibly random and not representative !
26747/// let result = hub.resources().features_list("customer")
26748///              .page_token("accusam")
26749///              .max_results(-68)
26750///              .doit();
26751/// # }
26752/// ```
26753pub struct ResourceFeatureListCall<'a, C, A>
26754    where C: 'a, A: 'a {
26755
26756    hub: &'a Directory<C, A>,
26757    _customer: String,
26758    _page_token: Option<String>,
26759    _max_results: Option<i32>,
26760    _delegate: Option<&'a mut dyn Delegate>,
26761    _additional_params: HashMap<String, String>,
26762    _scopes: BTreeMap<String, ()>
26763}
26764
26765impl<'a, C, A> CallBuilder for ResourceFeatureListCall<'a, C, A> {}
26766
26767impl<'a, C, A> ResourceFeatureListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
26768
26769
26770    /// Perform the operation you have build so far.
26771    pub fn doit(mut self) -> Result<(hyper::client::Response, Features)> {
26772        use std::io::{Read, Seek};
26773        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
26774        let mut dd = DefaultDelegate;
26775        let mut dlg: &mut dyn Delegate = match self._delegate {
26776            Some(d) => d,
26777            None => &mut dd
26778        };
26779        dlg.begin(MethodInfo { id: "directory.resources.features.list",
26780                               http_method: hyper::method::Method::Get });
26781        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
26782        params.push(("customer", self._customer.to_string()));
26783        if let Some(value) = self._page_token {
26784            params.push(("pageToken", value.to_string()));
26785        }
26786        if let Some(value) = self._max_results {
26787            params.push(("maxResults", value.to_string()));
26788        }
26789        for &field in ["alt", "customer", "pageToken", "maxResults"].iter() {
26790            if self._additional_params.contains_key(field) {
26791                dlg.finished(false);
26792                return Err(Error::FieldClash(field));
26793            }
26794        }
26795        for (name, value) in self._additional_params.iter() {
26796            params.push((&name, value.clone()));
26797        }
26798
26799        params.push(("alt", "json".to_string()));
26800
26801        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/features";
26802        if self._scopes.len() == 0 {
26803            self._scopes.insert(Scope::DirectoryResourceCalendarReadonly.as_ref().to_string(), ());
26804        }
26805
26806        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
26807            let mut replace_with: Option<&str> = None;
26808            for &(name, ref value) in params.iter() {
26809                if name == param_name {
26810                    replace_with = Some(value);
26811                    break;
26812                }
26813            }
26814            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
26815        }
26816        {
26817            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
26818            for param_name in ["customer"].iter() {
26819                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
26820                    indices_for_removal.push(index);
26821                }
26822            }
26823            for &index in indices_for_removal.iter() {
26824                params.remove(index);
26825            }
26826        }
26827
26828        let url = hyper::Url::parse_with_params(&url, params).unwrap();
26829
26830
26831
26832        loop {
26833            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
26834                Ok(token) => token,
26835                Err(err) => {
26836                    match  dlg.token(&*err) {
26837                        Some(token) => token,
26838                        None => {
26839                            dlg.finished(false);
26840                            return Err(Error::MissingToken(err))
26841                        }
26842                    }
26843                }
26844            };
26845            let auth_header = Authorization(Bearer { token: token.access_token });
26846            let mut req_result = {
26847                let mut client = &mut *self.hub.client.borrow_mut();
26848                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
26849                    .header(UserAgent(self.hub._user_agent.clone()))
26850                    .header(auth_header.clone());
26851
26852                dlg.pre_request();
26853                req.send()
26854            };
26855
26856            match req_result {
26857                Err(err) => {
26858                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
26859                        sleep(d);
26860                        continue;
26861                    }
26862                    dlg.finished(false);
26863                    return Err(Error::HttpError(err))
26864                }
26865                Ok(mut res) => {
26866                    if !res.status.is_success() {
26867                        let mut json_err = String::new();
26868                        res.read_to_string(&mut json_err).unwrap();
26869                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
26870                                                              json::from_str(&json_err).ok(),
26871                                                              json::from_str(&json_err).ok()) {
26872                            sleep(d);
26873                            continue;
26874                        }
26875                        dlg.finished(false);
26876                        return match json::from_str::<ErrorResponse>(&json_err){
26877                            Err(_) => Err(Error::Failure(res)),
26878                            Ok(serr) => Err(Error::BadRequest(serr))
26879                        }
26880                    }
26881                    let result_value = {
26882                        let mut json_response = String::new();
26883                        res.read_to_string(&mut json_response).unwrap();
26884                        match json::from_str(&json_response) {
26885                            Ok(decoded) => (res, decoded),
26886                            Err(err) => {
26887                                dlg.response_json_decode_error(&json_response, &err);
26888                                return Err(Error::JsonDecodeError(json_response, err));
26889                            }
26890                        }
26891                    };
26892
26893                    dlg.finished(true);
26894                    return Ok(result_value)
26895                }
26896            }
26897        }
26898    }
26899
26900
26901    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
26902    ///
26903    /// Sets the *customer* path property to the given value.
26904    ///
26905    /// Even though the property as already been set when instantiating this call,
26906    /// we provide this method for API completeness.
26907    pub fn customer(mut self, new_value: &str) -> ResourceFeatureListCall<'a, C, A> {
26908        self._customer = new_value.to_string();
26909        self
26910    }
26911    /// Token to specify the next page in the list.
26912    ///
26913    /// Sets the *page token* query property to the given value.
26914    pub fn page_token(mut self, new_value: &str) -> ResourceFeatureListCall<'a, C, A> {
26915        self._page_token = Some(new_value.to_string());
26916        self
26917    }
26918    /// Maximum number of results to return.
26919    ///
26920    /// Sets the *max results* query property to the given value.
26921    pub fn max_results(mut self, new_value: i32) -> ResourceFeatureListCall<'a, C, A> {
26922        self._max_results = Some(new_value);
26923        self
26924    }
26925    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26926    /// while executing the actual API request.
26927    /// 
26928    /// It should be used to handle progress information, and to implement a certain level of resilience.
26929    ///
26930    /// Sets the *delegate* property to the given value.
26931    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceFeatureListCall<'a, C, A> {
26932        self._delegate = Some(new_value);
26933        self
26934    }
26935
26936    /// Set any additional parameter of the query string used in the request.
26937    /// It should be used to set parameters which are not yet available through their own
26938    /// setters.
26939    ///
26940    /// Please note that this method must not be used to set any of the known parameters
26941    /// which have their own setter method. If done anyway, the request will fail.
26942    ///
26943    /// # Additional Parameters
26944    ///
26945    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26946    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26947    /// * *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.
26948    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26949    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26950    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26951    /// * *alt* (query-string) - Data format for the response.
26952    pub fn param<T>(mut self, name: T, value: T) -> ResourceFeatureListCall<'a, C, A>
26953                                                        where T: AsRef<str> {
26954        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
26955        self
26956    }
26957
26958    /// Identifies the authorization scope for the method you are building.
26959    ///
26960    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
26961    /// `Scope::DirectoryResourceCalendarReadonly`.
26962    ///
26963    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26964    /// tokens for more than one scope.
26965    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
26966    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
26967    /// function for details).
26968    ///
26969    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26970    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26971    /// sufficient, a read-write scope will do as well.
26972    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceFeatureListCall<'a, C, A>
26973                                                        where T: Into<Option<S>>,
26974                                                              S: AsRef<str> {
26975        match scope.into() {
26976          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
26977          None => None,
26978        };
26979        self
26980    }
26981}
26982
26983
26984/// Retrieves a calendar resource.
26985///
26986/// A builder for the *calendars.get* method supported by a *resource* resource.
26987/// It is not used directly, but through a `ResourceMethods` instance.
26988///
26989/// # Example
26990///
26991/// Instantiate a resource method builder
26992///
26993/// ```test_harness,no_run
26994/// # extern crate hyper;
26995/// # extern crate hyper_rustls;
26996/// # extern crate yup_oauth2 as oauth2;
26997/// # extern crate google_admin1_directory as admin1_directory;
26998/// # #[test] fn egal() {
26999/// # use std::default::Default;
27000/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
27001/// # use admin1_directory::Directory;
27002/// 
27003/// # let secret: ApplicationSecret = Default::default();
27004/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
27005/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
27006/// #                               <MemoryStorage as Default>::default(), None);
27007/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
27008/// // You can configure optional parameters by calling the respective setters at will, and
27009/// // execute the final call using `doit()`.
27010/// // Values shown here are possibly random and not representative !
27011/// let result = hub.resources().calendars_get("customer", "calendarResourceId")
27012///              .doit();
27013/// # }
27014/// ```
27015pub struct ResourceCalendarGetCall<'a, C, A>
27016    where C: 'a, A: 'a {
27017
27018    hub: &'a Directory<C, A>,
27019    _customer: String,
27020    _calendar_resource_id: String,
27021    _delegate: Option<&'a mut dyn Delegate>,
27022    _additional_params: HashMap<String, String>,
27023    _scopes: BTreeMap<String, ()>
27024}
27025
27026impl<'a, C, A> CallBuilder for ResourceCalendarGetCall<'a, C, A> {}
27027
27028impl<'a, C, A> ResourceCalendarGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
27029
27030
27031    /// Perform the operation you have build so far.
27032    pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarResource)> {
27033        use std::io::{Read, Seek};
27034        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
27035        let mut dd = DefaultDelegate;
27036        let mut dlg: &mut dyn Delegate = match self._delegate {
27037            Some(d) => d,
27038            None => &mut dd
27039        };
27040        dlg.begin(MethodInfo { id: "directory.resources.calendars.get",
27041                               http_method: hyper::method::Method::Get });
27042        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
27043        params.push(("customer", self._customer.to_string()));
27044        params.push(("calendarResourceId", self._calendar_resource_id.to_string()));
27045        for &field in ["alt", "customer", "calendarResourceId"].iter() {
27046            if self._additional_params.contains_key(field) {
27047                dlg.finished(false);
27048                return Err(Error::FieldClash(field));
27049            }
27050        }
27051        for (name, value) in self._additional_params.iter() {
27052            params.push((&name, value.clone()));
27053        }
27054
27055        params.push(("alt", "json".to_string()));
27056
27057        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/calendars/{calendarResourceId}";
27058        if self._scopes.len() == 0 {
27059            self._scopes.insert(Scope::DirectoryResourceCalendarReadonly.as_ref().to_string(), ());
27060        }
27061
27062        for &(find_this, param_name) in [("{customer}", "customer"), ("{calendarResourceId}", "calendarResourceId")].iter() {
27063            let mut replace_with: Option<&str> = None;
27064            for &(name, ref value) in params.iter() {
27065                if name == param_name {
27066                    replace_with = Some(value);
27067                    break;
27068                }
27069            }
27070            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
27071        }
27072        {
27073            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
27074            for param_name in ["calendarResourceId", "customer"].iter() {
27075                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
27076                    indices_for_removal.push(index);
27077                }
27078            }
27079            for &index in indices_for_removal.iter() {
27080                params.remove(index);
27081            }
27082        }
27083
27084        let url = hyper::Url::parse_with_params(&url, params).unwrap();
27085
27086
27087
27088        loop {
27089            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
27090                Ok(token) => token,
27091                Err(err) => {
27092                    match  dlg.token(&*err) {
27093                        Some(token) => token,
27094                        None => {
27095                            dlg.finished(false);
27096                            return Err(Error::MissingToken(err))
27097                        }
27098                    }
27099                }
27100            };
27101            let auth_header = Authorization(Bearer { token: token.access_token });
27102            let mut req_result = {
27103                let mut client = &mut *self.hub.client.borrow_mut();
27104                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
27105                    .header(UserAgent(self.hub._user_agent.clone()))
27106                    .header(auth_header.clone());
27107
27108                dlg.pre_request();
27109                req.send()
27110            };
27111
27112            match req_result {
27113                Err(err) => {
27114                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
27115                        sleep(d);
27116                        continue;
27117                    }
27118                    dlg.finished(false);
27119                    return Err(Error::HttpError(err))
27120                }
27121                Ok(mut res) => {
27122                    if !res.status.is_success() {
27123                        let mut json_err = String::new();
27124                        res.read_to_string(&mut json_err).unwrap();
27125                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
27126                                                              json::from_str(&json_err).ok(),
27127                                                              json::from_str(&json_err).ok()) {
27128                            sleep(d);
27129                            continue;
27130                        }
27131                        dlg.finished(false);
27132                        return match json::from_str::<ErrorResponse>(&json_err){
27133                            Err(_) => Err(Error::Failure(res)),
27134                            Ok(serr) => Err(Error::BadRequest(serr))
27135                        }
27136                    }
27137                    let result_value = {
27138                        let mut json_response = String::new();
27139                        res.read_to_string(&mut json_response).unwrap();
27140                        match json::from_str(&json_response) {
27141                            Ok(decoded) => (res, decoded),
27142                            Err(err) => {
27143                                dlg.response_json_decode_error(&json_response, &err);
27144                                return Err(Error::JsonDecodeError(json_response, err));
27145                            }
27146                        }
27147                    };
27148
27149                    dlg.finished(true);
27150                    return Ok(result_value)
27151                }
27152            }
27153        }
27154    }
27155
27156
27157    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
27158    ///
27159    /// Sets the *customer* path property to the given value.
27160    ///
27161    /// Even though the property as already been set when instantiating this call,
27162    /// we provide this method for API completeness.
27163    pub fn customer(mut self, new_value: &str) -> ResourceCalendarGetCall<'a, C, A> {
27164        self._customer = new_value.to_string();
27165        self
27166    }
27167    /// The unique ID of the calendar resource to retrieve.
27168    ///
27169    /// Sets the *calendar resource id* path property to the given value.
27170    ///
27171    /// Even though the property as already been set when instantiating this call,
27172    /// we provide this method for API completeness.
27173    pub fn calendar_resource_id(mut self, new_value: &str) -> ResourceCalendarGetCall<'a, C, A> {
27174        self._calendar_resource_id = new_value.to_string();
27175        self
27176    }
27177    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27178    /// while executing the actual API request.
27179    /// 
27180    /// It should be used to handle progress information, and to implement a certain level of resilience.
27181    ///
27182    /// Sets the *delegate* property to the given value.
27183    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceCalendarGetCall<'a, C, A> {
27184        self._delegate = Some(new_value);
27185        self
27186    }
27187
27188    /// Set any additional parameter of the query string used in the request.
27189    /// It should be used to set parameters which are not yet available through their own
27190    /// setters.
27191    ///
27192    /// Please note that this method must not be used to set any of the known parameters
27193    /// which have their own setter method. If done anyway, the request will fail.
27194    ///
27195    /// # Additional Parameters
27196    ///
27197    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27198    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27199    /// * *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.
27200    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27201    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27202    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27203    /// * *alt* (query-string) - Data format for the response.
27204    pub fn param<T>(mut self, name: T, value: T) -> ResourceCalendarGetCall<'a, C, A>
27205                                                        where T: AsRef<str> {
27206        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
27207        self
27208    }
27209
27210    /// Identifies the authorization scope for the method you are building.
27211    ///
27212    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
27213    /// `Scope::DirectoryResourceCalendarReadonly`.
27214    ///
27215    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27216    /// tokens for more than one scope.
27217    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
27218    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
27219    /// function for details).
27220    ///
27221    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27222    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27223    /// sufficient, a read-write scope will do as well.
27224    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceCalendarGetCall<'a, C, A>
27225                                                        where T: Into<Option<S>>,
27226                                                              S: AsRef<str> {
27227        match scope.into() {
27228          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
27229          None => None,
27230        };
27231        self
27232    }
27233}
27234
27235
27236/// Updates a building. This method supports patch semantics.
27237///
27238/// A builder for the *buildings.patch* method supported by a *resource* resource.
27239/// It is not used directly, but through a `ResourceMethods` instance.
27240///
27241/// # Example
27242///
27243/// Instantiate a resource method builder
27244///
27245/// ```test_harness,no_run
27246/// # extern crate hyper;
27247/// # extern crate hyper_rustls;
27248/// # extern crate yup_oauth2 as oauth2;
27249/// # extern crate google_admin1_directory as admin1_directory;
27250/// use admin1_directory::Building;
27251/// # #[test] fn egal() {
27252/// # use std::default::Default;
27253/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
27254/// # use admin1_directory::Directory;
27255/// 
27256/// # let secret: ApplicationSecret = Default::default();
27257/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
27258/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
27259/// #                               <MemoryStorage as Default>::default(), None);
27260/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
27261/// // As the method needs a request, you would usually fill it with the desired information
27262/// // into the respective structure. Some of the parts shown here might not be applicable !
27263/// // Values shown here are possibly random and not representative !
27264/// let mut req = Building::default();
27265/// 
27266/// // You can configure optional parameters by calling the respective setters at will, and
27267/// // execute the final call using `doit()`.
27268/// // Values shown here are possibly random and not representative !
27269/// let result = hub.resources().buildings_patch(req, "customer", "buildingId")
27270///              .coordinates_source("ea")
27271///              .doit();
27272/// # }
27273/// ```
27274pub struct ResourceBuildingPatchCall<'a, C, A>
27275    where C: 'a, A: 'a {
27276
27277    hub: &'a Directory<C, A>,
27278    _request: Building,
27279    _customer: String,
27280    _building_id: String,
27281    _coordinates_source: Option<String>,
27282    _delegate: Option<&'a mut dyn Delegate>,
27283    _additional_params: HashMap<String, String>,
27284    _scopes: BTreeMap<String, ()>
27285}
27286
27287impl<'a, C, A> CallBuilder for ResourceBuildingPatchCall<'a, C, A> {}
27288
27289impl<'a, C, A> ResourceBuildingPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
27290
27291
27292    /// Perform the operation you have build so far.
27293    pub fn doit(mut self) -> Result<(hyper::client::Response, Building)> {
27294        use std::io::{Read, Seek};
27295        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
27296        let mut dd = DefaultDelegate;
27297        let mut dlg: &mut dyn Delegate = match self._delegate {
27298            Some(d) => d,
27299            None => &mut dd
27300        };
27301        dlg.begin(MethodInfo { id: "directory.resources.buildings.patch",
27302                               http_method: hyper::method::Method::Patch });
27303        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
27304        params.push(("customer", self._customer.to_string()));
27305        params.push(("buildingId", self._building_id.to_string()));
27306        if let Some(value) = self._coordinates_source {
27307            params.push(("coordinatesSource", value.to_string()));
27308        }
27309        for &field in ["alt", "customer", "buildingId", "coordinatesSource"].iter() {
27310            if self._additional_params.contains_key(field) {
27311                dlg.finished(false);
27312                return Err(Error::FieldClash(field));
27313            }
27314        }
27315        for (name, value) in self._additional_params.iter() {
27316            params.push((&name, value.clone()));
27317        }
27318
27319        params.push(("alt", "json".to_string()));
27320
27321        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/buildings/{buildingId}";
27322        if self._scopes.len() == 0 {
27323            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
27324        }
27325
27326        for &(find_this, param_name) in [("{customer}", "customer"), ("{buildingId}", "buildingId")].iter() {
27327            let mut replace_with: Option<&str> = None;
27328            for &(name, ref value) in params.iter() {
27329                if name == param_name {
27330                    replace_with = Some(value);
27331                    break;
27332                }
27333            }
27334            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
27335        }
27336        {
27337            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
27338            for param_name in ["buildingId", "customer"].iter() {
27339                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
27340                    indices_for_removal.push(index);
27341                }
27342            }
27343            for &index in indices_for_removal.iter() {
27344                params.remove(index);
27345            }
27346        }
27347
27348        let url = hyper::Url::parse_with_params(&url, params).unwrap();
27349
27350        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
27351        let mut request_value_reader =
27352            {
27353                let mut value = json::value::to_value(&self._request).expect("serde to work");
27354                remove_json_null_values(&mut value);
27355                let mut dst = io::Cursor::new(Vec::with_capacity(128));
27356                json::to_writer(&mut dst, &value).unwrap();
27357                dst
27358            };
27359        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
27360        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
27361
27362
27363        loop {
27364            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
27365                Ok(token) => token,
27366                Err(err) => {
27367                    match  dlg.token(&*err) {
27368                        Some(token) => token,
27369                        None => {
27370                            dlg.finished(false);
27371                            return Err(Error::MissingToken(err))
27372                        }
27373                    }
27374                }
27375            };
27376            let auth_header = Authorization(Bearer { token: token.access_token });
27377            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
27378            let mut req_result = {
27379                let mut client = &mut *self.hub.client.borrow_mut();
27380                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
27381                    .header(UserAgent(self.hub._user_agent.clone()))
27382                    .header(auth_header.clone())
27383                    .header(ContentType(json_mime_type.clone()))
27384                    .header(ContentLength(request_size as u64))
27385                    .body(&mut request_value_reader);
27386
27387                dlg.pre_request();
27388                req.send()
27389            };
27390
27391            match req_result {
27392                Err(err) => {
27393                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
27394                        sleep(d);
27395                        continue;
27396                    }
27397                    dlg.finished(false);
27398                    return Err(Error::HttpError(err))
27399                }
27400                Ok(mut res) => {
27401                    if !res.status.is_success() {
27402                        let mut json_err = String::new();
27403                        res.read_to_string(&mut json_err).unwrap();
27404                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
27405                                                              json::from_str(&json_err).ok(),
27406                                                              json::from_str(&json_err).ok()) {
27407                            sleep(d);
27408                            continue;
27409                        }
27410                        dlg.finished(false);
27411                        return match json::from_str::<ErrorResponse>(&json_err){
27412                            Err(_) => Err(Error::Failure(res)),
27413                            Ok(serr) => Err(Error::BadRequest(serr))
27414                        }
27415                    }
27416                    let result_value = {
27417                        let mut json_response = String::new();
27418                        res.read_to_string(&mut json_response).unwrap();
27419                        match json::from_str(&json_response) {
27420                            Ok(decoded) => (res, decoded),
27421                            Err(err) => {
27422                                dlg.response_json_decode_error(&json_response, &err);
27423                                return Err(Error::JsonDecodeError(json_response, err));
27424                            }
27425                        }
27426                    };
27427
27428                    dlg.finished(true);
27429                    return Ok(result_value)
27430                }
27431            }
27432        }
27433    }
27434
27435
27436    ///
27437    /// Sets the *request* property to the given value.
27438    ///
27439    /// Even though the property as already been set when instantiating this call,
27440    /// we provide this method for API completeness.
27441    pub fn request(mut self, new_value: Building) -> ResourceBuildingPatchCall<'a, C, A> {
27442        self._request = new_value;
27443        self
27444    }
27445    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
27446    ///
27447    /// Sets the *customer* path property to the given value.
27448    ///
27449    /// Even though the property as already been set when instantiating this call,
27450    /// we provide this method for API completeness.
27451    pub fn customer(mut self, new_value: &str) -> ResourceBuildingPatchCall<'a, C, A> {
27452        self._customer = new_value.to_string();
27453        self
27454    }
27455    /// The ID of the building to update.
27456    ///
27457    /// Sets the *building id* path property to the given value.
27458    ///
27459    /// Even though the property as already been set when instantiating this call,
27460    /// we provide this method for API completeness.
27461    pub fn building_id(mut self, new_value: &str) -> ResourceBuildingPatchCall<'a, C, A> {
27462        self._building_id = new_value.to_string();
27463        self
27464    }
27465    /// Source from which Building.coordinates are derived.
27466    ///
27467    /// Sets the *coordinates source* query property to the given value.
27468    pub fn coordinates_source(mut self, new_value: &str) -> ResourceBuildingPatchCall<'a, C, A> {
27469        self._coordinates_source = Some(new_value.to_string());
27470        self
27471    }
27472    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27473    /// while executing the actual API request.
27474    /// 
27475    /// It should be used to handle progress information, and to implement a certain level of resilience.
27476    ///
27477    /// Sets the *delegate* property to the given value.
27478    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceBuildingPatchCall<'a, C, A> {
27479        self._delegate = Some(new_value);
27480        self
27481    }
27482
27483    /// Set any additional parameter of the query string used in the request.
27484    /// It should be used to set parameters which are not yet available through their own
27485    /// setters.
27486    ///
27487    /// Please note that this method must not be used to set any of the known parameters
27488    /// which have their own setter method. If done anyway, the request will fail.
27489    ///
27490    /// # Additional Parameters
27491    ///
27492    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27493    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27494    /// * *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.
27495    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27496    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27497    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27498    /// * *alt* (query-string) - Data format for the response.
27499    pub fn param<T>(mut self, name: T, value: T) -> ResourceBuildingPatchCall<'a, C, A>
27500                                                        where T: AsRef<str> {
27501        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
27502        self
27503    }
27504
27505    /// Identifies the authorization scope for the method you are building.
27506    ///
27507    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
27508    /// `Scope::DirectoryResourceCalendar`.
27509    ///
27510    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27511    /// tokens for more than one scope.
27512    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
27513    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
27514    /// function for details).
27515    ///
27516    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27517    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27518    /// sufficient, a read-write scope will do as well.
27519    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceBuildingPatchCall<'a, C, A>
27520                                                        where T: Into<Option<S>>,
27521                                                              S: AsRef<str> {
27522        match scope.into() {
27523          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
27524          None => None,
27525        };
27526        self
27527    }
27528}
27529
27530
27531/// Retrieves a list of buildings for an account.
27532///
27533/// A builder for the *buildings.list* method supported by a *resource* resource.
27534/// It is not used directly, but through a `ResourceMethods` instance.
27535///
27536/// # Example
27537///
27538/// Instantiate a resource method builder
27539///
27540/// ```test_harness,no_run
27541/// # extern crate hyper;
27542/// # extern crate hyper_rustls;
27543/// # extern crate yup_oauth2 as oauth2;
27544/// # extern crate google_admin1_directory as admin1_directory;
27545/// # #[test] fn egal() {
27546/// # use std::default::Default;
27547/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
27548/// # use admin1_directory::Directory;
27549/// 
27550/// # let secret: ApplicationSecret = Default::default();
27551/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
27552/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
27553/// #                               <MemoryStorage as Default>::default(), None);
27554/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
27555/// // You can configure optional parameters by calling the respective setters at will, and
27556/// // execute the final call using `doit()`.
27557/// // Values shown here are possibly random and not representative !
27558/// let result = hub.resources().buildings_list("customer")
27559///              .page_token("Stet")
27560///              .max_results(-43)
27561///              .doit();
27562/// # }
27563/// ```
27564pub struct ResourceBuildingListCall<'a, C, A>
27565    where C: 'a, A: 'a {
27566
27567    hub: &'a Directory<C, A>,
27568    _customer: String,
27569    _page_token: Option<String>,
27570    _max_results: Option<i32>,
27571    _delegate: Option<&'a mut dyn Delegate>,
27572    _additional_params: HashMap<String, String>,
27573    _scopes: BTreeMap<String, ()>
27574}
27575
27576impl<'a, C, A> CallBuilder for ResourceBuildingListCall<'a, C, A> {}
27577
27578impl<'a, C, A> ResourceBuildingListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
27579
27580
27581    /// Perform the operation you have build so far.
27582    pub fn doit(mut self) -> Result<(hyper::client::Response, Buildings)> {
27583        use std::io::{Read, Seek};
27584        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
27585        let mut dd = DefaultDelegate;
27586        let mut dlg: &mut dyn Delegate = match self._delegate {
27587            Some(d) => d,
27588            None => &mut dd
27589        };
27590        dlg.begin(MethodInfo { id: "directory.resources.buildings.list",
27591                               http_method: hyper::method::Method::Get });
27592        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
27593        params.push(("customer", self._customer.to_string()));
27594        if let Some(value) = self._page_token {
27595            params.push(("pageToken", value.to_string()));
27596        }
27597        if let Some(value) = self._max_results {
27598            params.push(("maxResults", value.to_string()));
27599        }
27600        for &field in ["alt", "customer", "pageToken", "maxResults"].iter() {
27601            if self._additional_params.contains_key(field) {
27602                dlg.finished(false);
27603                return Err(Error::FieldClash(field));
27604            }
27605        }
27606        for (name, value) in self._additional_params.iter() {
27607            params.push((&name, value.clone()));
27608        }
27609
27610        params.push(("alt", "json".to_string()));
27611
27612        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/buildings";
27613        if self._scopes.len() == 0 {
27614            self._scopes.insert(Scope::DirectoryResourceCalendarReadonly.as_ref().to_string(), ());
27615        }
27616
27617        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
27618            let mut replace_with: Option<&str> = None;
27619            for &(name, ref value) in params.iter() {
27620                if name == param_name {
27621                    replace_with = Some(value);
27622                    break;
27623                }
27624            }
27625            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
27626        }
27627        {
27628            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
27629            for param_name in ["customer"].iter() {
27630                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
27631                    indices_for_removal.push(index);
27632                }
27633            }
27634            for &index in indices_for_removal.iter() {
27635                params.remove(index);
27636            }
27637        }
27638
27639        let url = hyper::Url::parse_with_params(&url, params).unwrap();
27640
27641
27642
27643        loop {
27644            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
27645                Ok(token) => token,
27646                Err(err) => {
27647                    match  dlg.token(&*err) {
27648                        Some(token) => token,
27649                        None => {
27650                            dlg.finished(false);
27651                            return Err(Error::MissingToken(err))
27652                        }
27653                    }
27654                }
27655            };
27656            let auth_header = Authorization(Bearer { token: token.access_token });
27657            let mut req_result = {
27658                let mut client = &mut *self.hub.client.borrow_mut();
27659                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
27660                    .header(UserAgent(self.hub._user_agent.clone()))
27661                    .header(auth_header.clone());
27662
27663                dlg.pre_request();
27664                req.send()
27665            };
27666
27667            match req_result {
27668                Err(err) => {
27669                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
27670                        sleep(d);
27671                        continue;
27672                    }
27673                    dlg.finished(false);
27674                    return Err(Error::HttpError(err))
27675                }
27676                Ok(mut res) => {
27677                    if !res.status.is_success() {
27678                        let mut json_err = String::new();
27679                        res.read_to_string(&mut json_err).unwrap();
27680                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
27681                                                              json::from_str(&json_err).ok(),
27682                                                              json::from_str(&json_err).ok()) {
27683                            sleep(d);
27684                            continue;
27685                        }
27686                        dlg.finished(false);
27687                        return match json::from_str::<ErrorResponse>(&json_err){
27688                            Err(_) => Err(Error::Failure(res)),
27689                            Ok(serr) => Err(Error::BadRequest(serr))
27690                        }
27691                    }
27692                    let result_value = {
27693                        let mut json_response = String::new();
27694                        res.read_to_string(&mut json_response).unwrap();
27695                        match json::from_str(&json_response) {
27696                            Ok(decoded) => (res, decoded),
27697                            Err(err) => {
27698                                dlg.response_json_decode_error(&json_response, &err);
27699                                return Err(Error::JsonDecodeError(json_response, err));
27700                            }
27701                        }
27702                    };
27703
27704                    dlg.finished(true);
27705                    return Ok(result_value)
27706                }
27707            }
27708        }
27709    }
27710
27711
27712    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
27713    ///
27714    /// Sets the *customer* path property to the given value.
27715    ///
27716    /// Even though the property as already been set when instantiating this call,
27717    /// we provide this method for API completeness.
27718    pub fn customer(mut self, new_value: &str) -> ResourceBuildingListCall<'a, C, A> {
27719        self._customer = new_value.to_string();
27720        self
27721    }
27722    /// Token to specify the next page in the list.
27723    ///
27724    /// Sets the *page token* query property to the given value.
27725    pub fn page_token(mut self, new_value: &str) -> ResourceBuildingListCall<'a, C, A> {
27726        self._page_token = Some(new_value.to_string());
27727        self
27728    }
27729    /// Maximum number of results to return.
27730    ///
27731    /// Sets the *max results* query property to the given value.
27732    pub fn max_results(mut self, new_value: i32) -> ResourceBuildingListCall<'a, C, A> {
27733        self._max_results = Some(new_value);
27734        self
27735    }
27736    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27737    /// while executing the actual API request.
27738    /// 
27739    /// It should be used to handle progress information, and to implement a certain level of resilience.
27740    ///
27741    /// Sets the *delegate* property to the given value.
27742    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceBuildingListCall<'a, C, A> {
27743        self._delegate = Some(new_value);
27744        self
27745    }
27746
27747    /// Set any additional parameter of the query string used in the request.
27748    /// It should be used to set parameters which are not yet available through their own
27749    /// setters.
27750    ///
27751    /// Please note that this method must not be used to set any of the known parameters
27752    /// which have their own setter method. If done anyway, the request will fail.
27753    ///
27754    /// # Additional Parameters
27755    ///
27756    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27757    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27758    /// * *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.
27759    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27760    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27761    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27762    /// * *alt* (query-string) - Data format for the response.
27763    pub fn param<T>(mut self, name: T, value: T) -> ResourceBuildingListCall<'a, C, A>
27764                                                        where T: AsRef<str> {
27765        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
27766        self
27767    }
27768
27769    /// Identifies the authorization scope for the method you are building.
27770    ///
27771    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
27772    /// `Scope::DirectoryResourceCalendarReadonly`.
27773    ///
27774    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27775    /// tokens for more than one scope.
27776    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
27777    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
27778    /// function for details).
27779    ///
27780    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27781    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27782    /// sufficient, a read-write scope will do as well.
27783    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceBuildingListCall<'a, C, A>
27784                                                        where T: Into<Option<S>>,
27785                                                              S: AsRef<str> {
27786        match scope.into() {
27787          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
27788          None => None,
27789        };
27790        self
27791    }
27792}
27793
27794
27795/// Retrieves a feature.
27796///
27797/// A builder for the *features.get* method supported by a *resource* resource.
27798/// It is not used directly, but through a `ResourceMethods` instance.
27799///
27800/// # Example
27801///
27802/// Instantiate a resource method builder
27803///
27804/// ```test_harness,no_run
27805/// # extern crate hyper;
27806/// # extern crate hyper_rustls;
27807/// # extern crate yup_oauth2 as oauth2;
27808/// # extern crate google_admin1_directory as admin1_directory;
27809/// # #[test] fn egal() {
27810/// # use std::default::Default;
27811/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
27812/// # use admin1_directory::Directory;
27813/// 
27814/// # let secret: ApplicationSecret = Default::default();
27815/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
27816/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
27817/// #                               <MemoryStorage as Default>::default(), None);
27818/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
27819/// // You can configure optional parameters by calling the respective setters at will, and
27820/// // execute the final call using `doit()`.
27821/// // Values shown here are possibly random and not representative !
27822/// let result = hub.resources().features_get("customer", "featureKey")
27823///              .doit();
27824/// # }
27825/// ```
27826pub struct ResourceFeatureGetCall<'a, C, A>
27827    where C: 'a, A: 'a {
27828
27829    hub: &'a Directory<C, A>,
27830    _customer: String,
27831    _feature_key: String,
27832    _delegate: Option<&'a mut dyn Delegate>,
27833    _additional_params: HashMap<String, String>,
27834    _scopes: BTreeMap<String, ()>
27835}
27836
27837impl<'a, C, A> CallBuilder for ResourceFeatureGetCall<'a, C, A> {}
27838
27839impl<'a, C, A> ResourceFeatureGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
27840
27841
27842    /// Perform the operation you have build so far.
27843    pub fn doit(mut self) -> Result<(hyper::client::Response, Feature)> {
27844        use std::io::{Read, Seek};
27845        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
27846        let mut dd = DefaultDelegate;
27847        let mut dlg: &mut dyn Delegate = match self._delegate {
27848            Some(d) => d,
27849            None => &mut dd
27850        };
27851        dlg.begin(MethodInfo { id: "directory.resources.features.get",
27852                               http_method: hyper::method::Method::Get });
27853        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
27854        params.push(("customer", self._customer.to_string()));
27855        params.push(("featureKey", self._feature_key.to_string()));
27856        for &field in ["alt", "customer", "featureKey"].iter() {
27857            if self._additional_params.contains_key(field) {
27858                dlg.finished(false);
27859                return Err(Error::FieldClash(field));
27860            }
27861        }
27862        for (name, value) in self._additional_params.iter() {
27863            params.push((&name, value.clone()));
27864        }
27865
27866        params.push(("alt", "json".to_string()));
27867
27868        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/features/{featureKey}";
27869        if self._scopes.len() == 0 {
27870            self._scopes.insert(Scope::DirectoryResourceCalendarReadonly.as_ref().to_string(), ());
27871        }
27872
27873        for &(find_this, param_name) in [("{customer}", "customer"), ("{featureKey}", "featureKey")].iter() {
27874            let mut replace_with: Option<&str> = None;
27875            for &(name, ref value) in params.iter() {
27876                if name == param_name {
27877                    replace_with = Some(value);
27878                    break;
27879                }
27880            }
27881            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
27882        }
27883        {
27884            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
27885            for param_name in ["featureKey", "customer"].iter() {
27886                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
27887                    indices_for_removal.push(index);
27888                }
27889            }
27890            for &index in indices_for_removal.iter() {
27891                params.remove(index);
27892            }
27893        }
27894
27895        let url = hyper::Url::parse_with_params(&url, params).unwrap();
27896
27897
27898
27899        loop {
27900            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
27901                Ok(token) => token,
27902                Err(err) => {
27903                    match  dlg.token(&*err) {
27904                        Some(token) => token,
27905                        None => {
27906                            dlg.finished(false);
27907                            return Err(Error::MissingToken(err))
27908                        }
27909                    }
27910                }
27911            };
27912            let auth_header = Authorization(Bearer { token: token.access_token });
27913            let mut req_result = {
27914                let mut client = &mut *self.hub.client.borrow_mut();
27915                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
27916                    .header(UserAgent(self.hub._user_agent.clone()))
27917                    .header(auth_header.clone());
27918
27919                dlg.pre_request();
27920                req.send()
27921            };
27922
27923            match req_result {
27924                Err(err) => {
27925                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
27926                        sleep(d);
27927                        continue;
27928                    }
27929                    dlg.finished(false);
27930                    return Err(Error::HttpError(err))
27931                }
27932                Ok(mut res) => {
27933                    if !res.status.is_success() {
27934                        let mut json_err = String::new();
27935                        res.read_to_string(&mut json_err).unwrap();
27936                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
27937                                                              json::from_str(&json_err).ok(),
27938                                                              json::from_str(&json_err).ok()) {
27939                            sleep(d);
27940                            continue;
27941                        }
27942                        dlg.finished(false);
27943                        return match json::from_str::<ErrorResponse>(&json_err){
27944                            Err(_) => Err(Error::Failure(res)),
27945                            Ok(serr) => Err(Error::BadRequest(serr))
27946                        }
27947                    }
27948                    let result_value = {
27949                        let mut json_response = String::new();
27950                        res.read_to_string(&mut json_response).unwrap();
27951                        match json::from_str(&json_response) {
27952                            Ok(decoded) => (res, decoded),
27953                            Err(err) => {
27954                                dlg.response_json_decode_error(&json_response, &err);
27955                                return Err(Error::JsonDecodeError(json_response, err));
27956                            }
27957                        }
27958                    };
27959
27960                    dlg.finished(true);
27961                    return Ok(result_value)
27962                }
27963            }
27964        }
27965    }
27966
27967
27968    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
27969    ///
27970    /// Sets the *customer* path property to the given value.
27971    ///
27972    /// Even though the property as already been set when instantiating this call,
27973    /// we provide this method for API completeness.
27974    pub fn customer(mut self, new_value: &str) -> ResourceFeatureGetCall<'a, C, A> {
27975        self._customer = new_value.to_string();
27976        self
27977    }
27978    /// The unique ID of the feature to retrieve.
27979    ///
27980    /// Sets the *feature key* path property to the given value.
27981    ///
27982    /// Even though the property as already been set when instantiating this call,
27983    /// we provide this method for API completeness.
27984    pub fn feature_key(mut self, new_value: &str) -> ResourceFeatureGetCall<'a, C, A> {
27985        self._feature_key = new_value.to_string();
27986        self
27987    }
27988    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27989    /// while executing the actual API request.
27990    /// 
27991    /// It should be used to handle progress information, and to implement a certain level of resilience.
27992    ///
27993    /// Sets the *delegate* property to the given value.
27994    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceFeatureGetCall<'a, C, A> {
27995        self._delegate = Some(new_value);
27996        self
27997    }
27998
27999    /// Set any additional parameter of the query string used in the request.
28000    /// It should be used to set parameters which are not yet available through their own
28001    /// setters.
28002    ///
28003    /// Please note that this method must not be used to set any of the known parameters
28004    /// which have their own setter method. If done anyway, the request will fail.
28005    ///
28006    /// # Additional Parameters
28007    ///
28008    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28009    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28010    /// * *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.
28011    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28012    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28013    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28014    /// * *alt* (query-string) - Data format for the response.
28015    pub fn param<T>(mut self, name: T, value: T) -> ResourceFeatureGetCall<'a, C, A>
28016                                                        where T: AsRef<str> {
28017        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
28018        self
28019    }
28020
28021    /// Identifies the authorization scope for the method you are building.
28022    ///
28023    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
28024    /// `Scope::DirectoryResourceCalendarReadonly`.
28025    ///
28026    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28027    /// tokens for more than one scope.
28028    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
28029    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
28030    /// function for details).
28031    ///
28032    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28033    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28034    /// sufficient, a read-write scope will do as well.
28035    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceFeatureGetCall<'a, C, A>
28036                                                        where T: Into<Option<S>>,
28037                                                              S: AsRef<str> {
28038        match scope.into() {
28039          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
28040          None => None,
28041        };
28042        self
28043    }
28044}
28045
28046
28047/// Inserts a calendar resource.
28048///
28049/// A builder for the *calendars.insert* method supported by a *resource* resource.
28050/// It is not used directly, but through a `ResourceMethods` instance.
28051///
28052/// # Example
28053///
28054/// Instantiate a resource method builder
28055///
28056/// ```test_harness,no_run
28057/// # extern crate hyper;
28058/// # extern crate hyper_rustls;
28059/// # extern crate yup_oauth2 as oauth2;
28060/// # extern crate google_admin1_directory as admin1_directory;
28061/// use admin1_directory::CalendarResource;
28062/// # #[test] fn egal() {
28063/// # use std::default::Default;
28064/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
28065/// # use admin1_directory::Directory;
28066/// 
28067/// # let secret: ApplicationSecret = Default::default();
28068/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
28069/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
28070/// #                               <MemoryStorage as Default>::default(), None);
28071/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
28072/// // As the method needs a request, you would usually fill it with the desired information
28073/// // into the respective structure. Some of the parts shown here might not be applicable !
28074/// // Values shown here are possibly random and not representative !
28075/// let mut req = CalendarResource::default();
28076/// 
28077/// // You can configure optional parameters by calling the respective setters at will, and
28078/// // execute the final call using `doit()`.
28079/// // Values shown here are possibly random and not representative !
28080/// let result = hub.resources().calendars_insert(req, "customer")
28081///              .doit();
28082/// # }
28083/// ```
28084pub struct ResourceCalendarInsertCall<'a, C, A>
28085    where C: 'a, A: 'a {
28086
28087    hub: &'a Directory<C, A>,
28088    _request: CalendarResource,
28089    _customer: String,
28090    _delegate: Option<&'a mut dyn Delegate>,
28091    _additional_params: HashMap<String, String>,
28092    _scopes: BTreeMap<String, ()>
28093}
28094
28095impl<'a, C, A> CallBuilder for ResourceCalendarInsertCall<'a, C, A> {}
28096
28097impl<'a, C, A> ResourceCalendarInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
28098
28099
28100    /// Perform the operation you have build so far.
28101    pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarResource)> {
28102        use std::io::{Read, Seek};
28103        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
28104        let mut dd = DefaultDelegate;
28105        let mut dlg: &mut dyn Delegate = match self._delegate {
28106            Some(d) => d,
28107            None => &mut dd
28108        };
28109        dlg.begin(MethodInfo { id: "directory.resources.calendars.insert",
28110                               http_method: hyper::method::Method::Post });
28111        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
28112        params.push(("customer", self._customer.to_string()));
28113        for &field in ["alt", "customer"].iter() {
28114            if self._additional_params.contains_key(field) {
28115                dlg.finished(false);
28116                return Err(Error::FieldClash(field));
28117            }
28118        }
28119        for (name, value) in self._additional_params.iter() {
28120            params.push((&name, value.clone()));
28121        }
28122
28123        params.push(("alt", "json".to_string()));
28124
28125        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/calendars";
28126        if self._scopes.len() == 0 {
28127            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
28128        }
28129
28130        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
28131            let mut replace_with: Option<&str> = None;
28132            for &(name, ref value) in params.iter() {
28133                if name == param_name {
28134                    replace_with = Some(value);
28135                    break;
28136                }
28137            }
28138            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
28139        }
28140        {
28141            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
28142            for param_name in ["customer"].iter() {
28143                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
28144                    indices_for_removal.push(index);
28145                }
28146            }
28147            for &index in indices_for_removal.iter() {
28148                params.remove(index);
28149            }
28150        }
28151
28152        let url = hyper::Url::parse_with_params(&url, params).unwrap();
28153
28154        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
28155        let mut request_value_reader =
28156            {
28157                let mut value = json::value::to_value(&self._request).expect("serde to work");
28158                remove_json_null_values(&mut value);
28159                let mut dst = io::Cursor::new(Vec::with_capacity(128));
28160                json::to_writer(&mut dst, &value).unwrap();
28161                dst
28162            };
28163        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
28164        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
28165
28166
28167        loop {
28168            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
28169                Ok(token) => token,
28170                Err(err) => {
28171                    match  dlg.token(&*err) {
28172                        Some(token) => token,
28173                        None => {
28174                            dlg.finished(false);
28175                            return Err(Error::MissingToken(err))
28176                        }
28177                    }
28178                }
28179            };
28180            let auth_header = Authorization(Bearer { token: token.access_token });
28181            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
28182            let mut req_result = {
28183                let mut client = &mut *self.hub.client.borrow_mut();
28184                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
28185                    .header(UserAgent(self.hub._user_agent.clone()))
28186                    .header(auth_header.clone())
28187                    .header(ContentType(json_mime_type.clone()))
28188                    .header(ContentLength(request_size as u64))
28189                    .body(&mut request_value_reader);
28190
28191                dlg.pre_request();
28192                req.send()
28193            };
28194
28195            match req_result {
28196                Err(err) => {
28197                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
28198                        sleep(d);
28199                        continue;
28200                    }
28201                    dlg.finished(false);
28202                    return Err(Error::HttpError(err))
28203                }
28204                Ok(mut res) => {
28205                    if !res.status.is_success() {
28206                        let mut json_err = String::new();
28207                        res.read_to_string(&mut json_err).unwrap();
28208                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
28209                                                              json::from_str(&json_err).ok(),
28210                                                              json::from_str(&json_err).ok()) {
28211                            sleep(d);
28212                            continue;
28213                        }
28214                        dlg.finished(false);
28215                        return match json::from_str::<ErrorResponse>(&json_err){
28216                            Err(_) => Err(Error::Failure(res)),
28217                            Ok(serr) => Err(Error::BadRequest(serr))
28218                        }
28219                    }
28220                    let result_value = {
28221                        let mut json_response = String::new();
28222                        res.read_to_string(&mut json_response).unwrap();
28223                        match json::from_str(&json_response) {
28224                            Ok(decoded) => (res, decoded),
28225                            Err(err) => {
28226                                dlg.response_json_decode_error(&json_response, &err);
28227                                return Err(Error::JsonDecodeError(json_response, err));
28228                            }
28229                        }
28230                    };
28231
28232                    dlg.finished(true);
28233                    return Ok(result_value)
28234                }
28235            }
28236        }
28237    }
28238
28239
28240    ///
28241    /// Sets the *request* property to the given value.
28242    ///
28243    /// Even though the property as already been set when instantiating this call,
28244    /// we provide this method for API completeness.
28245    pub fn request(mut self, new_value: CalendarResource) -> ResourceCalendarInsertCall<'a, C, A> {
28246        self._request = new_value;
28247        self
28248    }
28249    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
28250    ///
28251    /// Sets the *customer* path property to the given value.
28252    ///
28253    /// Even though the property as already been set when instantiating this call,
28254    /// we provide this method for API completeness.
28255    pub fn customer(mut self, new_value: &str) -> ResourceCalendarInsertCall<'a, C, A> {
28256        self._customer = new_value.to_string();
28257        self
28258    }
28259    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28260    /// while executing the actual API request.
28261    /// 
28262    /// It should be used to handle progress information, and to implement a certain level of resilience.
28263    ///
28264    /// Sets the *delegate* property to the given value.
28265    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceCalendarInsertCall<'a, C, A> {
28266        self._delegate = Some(new_value);
28267        self
28268    }
28269
28270    /// Set any additional parameter of the query string used in the request.
28271    /// It should be used to set parameters which are not yet available through their own
28272    /// setters.
28273    ///
28274    /// Please note that this method must not be used to set any of the known parameters
28275    /// which have their own setter method. If done anyway, the request will fail.
28276    ///
28277    /// # Additional Parameters
28278    ///
28279    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28280    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28281    /// * *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.
28282    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28283    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28284    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28285    /// * *alt* (query-string) - Data format for the response.
28286    pub fn param<T>(mut self, name: T, value: T) -> ResourceCalendarInsertCall<'a, C, A>
28287                                                        where T: AsRef<str> {
28288        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
28289        self
28290    }
28291
28292    /// Identifies the authorization scope for the method you are building.
28293    ///
28294    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
28295    /// `Scope::DirectoryResourceCalendar`.
28296    ///
28297    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28298    /// tokens for more than one scope.
28299    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
28300    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
28301    /// function for details).
28302    ///
28303    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28304    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28305    /// sufficient, a read-write scope will do as well.
28306    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceCalendarInsertCall<'a, C, A>
28307                                                        where T: Into<Option<S>>,
28308                                                              S: AsRef<str> {
28309        match scope.into() {
28310          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
28311          None => None,
28312        };
28313        self
28314    }
28315}
28316
28317
28318/// Updates a feature. This method supports patch semantics.
28319///
28320/// A builder for the *features.patch* method supported by a *resource* resource.
28321/// It is not used directly, but through a `ResourceMethods` instance.
28322///
28323/// # Example
28324///
28325/// Instantiate a resource method builder
28326///
28327/// ```test_harness,no_run
28328/// # extern crate hyper;
28329/// # extern crate hyper_rustls;
28330/// # extern crate yup_oauth2 as oauth2;
28331/// # extern crate google_admin1_directory as admin1_directory;
28332/// use admin1_directory::Feature;
28333/// # #[test] fn egal() {
28334/// # use std::default::Default;
28335/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
28336/// # use admin1_directory::Directory;
28337/// 
28338/// # let secret: ApplicationSecret = Default::default();
28339/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
28340/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
28341/// #                               <MemoryStorage as Default>::default(), None);
28342/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
28343/// // As the method needs a request, you would usually fill it with the desired information
28344/// // into the respective structure. Some of the parts shown here might not be applicable !
28345/// // Values shown here are possibly random and not representative !
28346/// let mut req = Feature::default();
28347/// 
28348/// // You can configure optional parameters by calling the respective setters at will, and
28349/// // execute the final call using `doit()`.
28350/// // Values shown here are possibly random and not representative !
28351/// let result = hub.resources().features_patch(req, "customer", "featureKey")
28352///              .doit();
28353/// # }
28354/// ```
28355pub struct ResourceFeaturePatchCall<'a, C, A>
28356    where C: 'a, A: 'a {
28357
28358    hub: &'a Directory<C, A>,
28359    _request: Feature,
28360    _customer: String,
28361    _feature_key: String,
28362    _delegate: Option<&'a mut dyn Delegate>,
28363    _additional_params: HashMap<String, String>,
28364    _scopes: BTreeMap<String, ()>
28365}
28366
28367impl<'a, C, A> CallBuilder for ResourceFeaturePatchCall<'a, C, A> {}
28368
28369impl<'a, C, A> ResourceFeaturePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
28370
28371
28372    /// Perform the operation you have build so far.
28373    pub fn doit(mut self) -> Result<(hyper::client::Response, Feature)> {
28374        use std::io::{Read, Seek};
28375        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
28376        let mut dd = DefaultDelegate;
28377        let mut dlg: &mut dyn Delegate = match self._delegate {
28378            Some(d) => d,
28379            None => &mut dd
28380        };
28381        dlg.begin(MethodInfo { id: "directory.resources.features.patch",
28382                               http_method: hyper::method::Method::Patch });
28383        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
28384        params.push(("customer", self._customer.to_string()));
28385        params.push(("featureKey", self._feature_key.to_string()));
28386        for &field in ["alt", "customer", "featureKey"].iter() {
28387            if self._additional_params.contains_key(field) {
28388                dlg.finished(false);
28389                return Err(Error::FieldClash(field));
28390            }
28391        }
28392        for (name, value) in self._additional_params.iter() {
28393            params.push((&name, value.clone()));
28394        }
28395
28396        params.push(("alt", "json".to_string()));
28397
28398        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/features/{featureKey}";
28399        if self._scopes.len() == 0 {
28400            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
28401        }
28402
28403        for &(find_this, param_name) in [("{customer}", "customer"), ("{featureKey}", "featureKey")].iter() {
28404            let mut replace_with: Option<&str> = None;
28405            for &(name, ref value) in params.iter() {
28406                if name == param_name {
28407                    replace_with = Some(value);
28408                    break;
28409                }
28410            }
28411            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
28412        }
28413        {
28414            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
28415            for param_name in ["featureKey", "customer"].iter() {
28416                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
28417                    indices_for_removal.push(index);
28418                }
28419            }
28420            for &index in indices_for_removal.iter() {
28421                params.remove(index);
28422            }
28423        }
28424
28425        let url = hyper::Url::parse_with_params(&url, params).unwrap();
28426
28427        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
28428        let mut request_value_reader =
28429            {
28430                let mut value = json::value::to_value(&self._request).expect("serde to work");
28431                remove_json_null_values(&mut value);
28432                let mut dst = io::Cursor::new(Vec::with_capacity(128));
28433                json::to_writer(&mut dst, &value).unwrap();
28434                dst
28435            };
28436        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
28437        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
28438
28439
28440        loop {
28441            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
28442                Ok(token) => token,
28443                Err(err) => {
28444                    match  dlg.token(&*err) {
28445                        Some(token) => token,
28446                        None => {
28447                            dlg.finished(false);
28448                            return Err(Error::MissingToken(err))
28449                        }
28450                    }
28451                }
28452            };
28453            let auth_header = Authorization(Bearer { token: token.access_token });
28454            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
28455            let mut req_result = {
28456                let mut client = &mut *self.hub.client.borrow_mut();
28457                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
28458                    .header(UserAgent(self.hub._user_agent.clone()))
28459                    .header(auth_header.clone())
28460                    .header(ContentType(json_mime_type.clone()))
28461                    .header(ContentLength(request_size as u64))
28462                    .body(&mut request_value_reader);
28463
28464                dlg.pre_request();
28465                req.send()
28466            };
28467
28468            match req_result {
28469                Err(err) => {
28470                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
28471                        sleep(d);
28472                        continue;
28473                    }
28474                    dlg.finished(false);
28475                    return Err(Error::HttpError(err))
28476                }
28477                Ok(mut res) => {
28478                    if !res.status.is_success() {
28479                        let mut json_err = String::new();
28480                        res.read_to_string(&mut json_err).unwrap();
28481                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
28482                                                              json::from_str(&json_err).ok(),
28483                                                              json::from_str(&json_err).ok()) {
28484                            sleep(d);
28485                            continue;
28486                        }
28487                        dlg.finished(false);
28488                        return match json::from_str::<ErrorResponse>(&json_err){
28489                            Err(_) => Err(Error::Failure(res)),
28490                            Ok(serr) => Err(Error::BadRequest(serr))
28491                        }
28492                    }
28493                    let result_value = {
28494                        let mut json_response = String::new();
28495                        res.read_to_string(&mut json_response).unwrap();
28496                        match json::from_str(&json_response) {
28497                            Ok(decoded) => (res, decoded),
28498                            Err(err) => {
28499                                dlg.response_json_decode_error(&json_response, &err);
28500                                return Err(Error::JsonDecodeError(json_response, err));
28501                            }
28502                        }
28503                    };
28504
28505                    dlg.finished(true);
28506                    return Ok(result_value)
28507                }
28508            }
28509        }
28510    }
28511
28512
28513    ///
28514    /// Sets the *request* property to the given value.
28515    ///
28516    /// Even though the property as already been set when instantiating this call,
28517    /// we provide this method for API completeness.
28518    pub fn request(mut self, new_value: Feature) -> ResourceFeaturePatchCall<'a, C, A> {
28519        self._request = new_value;
28520        self
28521    }
28522    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
28523    ///
28524    /// Sets the *customer* path property to the given value.
28525    ///
28526    /// Even though the property as already been set when instantiating this call,
28527    /// we provide this method for API completeness.
28528    pub fn customer(mut self, new_value: &str) -> ResourceFeaturePatchCall<'a, C, A> {
28529        self._customer = new_value.to_string();
28530        self
28531    }
28532    /// The unique ID of the feature to update.
28533    ///
28534    /// Sets the *feature key* path property to the given value.
28535    ///
28536    /// Even though the property as already been set when instantiating this call,
28537    /// we provide this method for API completeness.
28538    pub fn feature_key(mut self, new_value: &str) -> ResourceFeaturePatchCall<'a, C, A> {
28539        self._feature_key = new_value.to_string();
28540        self
28541    }
28542    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28543    /// while executing the actual API request.
28544    /// 
28545    /// It should be used to handle progress information, and to implement a certain level of resilience.
28546    ///
28547    /// Sets the *delegate* property to the given value.
28548    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceFeaturePatchCall<'a, C, A> {
28549        self._delegate = Some(new_value);
28550        self
28551    }
28552
28553    /// Set any additional parameter of the query string used in the request.
28554    /// It should be used to set parameters which are not yet available through their own
28555    /// setters.
28556    ///
28557    /// Please note that this method must not be used to set any of the known parameters
28558    /// which have their own setter method. If done anyway, the request will fail.
28559    ///
28560    /// # Additional Parameters
28561    ///
28562    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28563    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28564    /// * *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.
28565    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28566    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28567    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28568    /// * *alt* (query-string) - Data format for the response.
28569    pub fn param<T>(mut self, name: T, value: T) -> ResourceFeaturePatchCall<'a, C, A>
28570                                                        where T: AsRef<str> {
28571        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
28572        self
28573    }
28574
28575    /// Identifies the authorization scope for the method you are building.
28576    ///
28577    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
28578    /// `Scope::DirectoryResourceCalendar`.
28579    ///
28580    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28581    /// tokens for more than one scope.
28582    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
28583    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
28584    /// function for details).
28585    ///
28586    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28587    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28588    /// sufficient, a read-write scope will do as well.
28589    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceFeaturePatchCall<'a, C, A>
28590                                                        where T: Into<Option<S>>,
28591                                                              S: AsRef<str> {
28592        match scope.into() {
28593          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
28594          None => None,
28595        };
28596        self
28597    }
28598}
28599
28600
28601/// Retrieves a building.
28602///
28603/// A builder for the *buildings.get* method supported by a *resource* resource.
28604/// It is not used directly, but through a `ResourceMethods` instance.
28605///
28606/// # Example
28607///
28608/// Instantiate a resource method builder
28609///
28610/// ```test_harness,no_run
28611/// # extern crate hyper;
28612/// # extern crate hyper_rustls;
28613/// # extern crate yup_oauth2 as oauth2;
28614/// # extern crate google_admin1_directory as admin1_directory;
28615/// # #[test] fn egal() {
28616/// # use std::default::Default;
28617/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
28618/// # use admin1_directory::Directory;
28619/// 
28620/// # let secret: ApplicationSecret = Default::default();
28621/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
28622/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
28623/// #                               <MemoryStorage as Default>::default(), None);
28624/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
28625/// // You can configure optional parameters by calling the respective setters at will, and
28626/// // execute the final call using `doit()`.
28627/// // Values shown here are possibly random and not representative !
28628/// let result = hub.resources().buildings_get("customer", "buildingId")
28629///              .doit();
28630/// # }
28631/// ```
28632pub struct ResourceBuildingGetCall<'a, C, A>
28633    where C: 'a, A: 'a {
28634
28635    hub: &'a Directory<C, A>,
28636    _customer: String,
28637    _building_id: String,
28638    _delegate: Option<&'a mut dyn Delegate>,
28639    _additional_params: HashMap<String, String>,
28640    _scopes: BTreeMap<String, ()>
28641}
28642
28643impl<'a, C, A> CallBuilder for ResourceBuildingGetCall<'a, C, A> {}
28644
28645impl<'a, C, A> ResourceBuildingGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
28646
28647
28648    /// Perform the operation you have build so far.
28649    pub fn doit(mut self) -> Result<(hyper::client::Response, Building)> {
28650        use std::io::{Read, Seek};
28651        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
28652        let mut dd = DefaultDelegate;
28653        let mut dlg: &mut dyn Delegate = match self._delegate {
28654            Some(d) => d,
28655            None => &mut dd
28656        };
28657        dlg.begin(MethodInfo { id: "directory.resources.buildings.get",
28658                               http_method: hyper::method::Method::Get });
28659        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
28660        params.push(("customer", self._customer.to_string()));
28661        params.push(("buildingId", self._building_id.to_string()));
28662        for &field in ["alt", "customer", "buildingId"].iter() {
28663            if self._additional_params.contains_key(field) {
28664                dlg.finished(false);
28665                return Err(Error::FieldClash(field));
28666            }
28667        }
28668        for (name, value) in self._additional_params.iter() {
28669            params.push((&name, value.clone()));
28670        }
28671
28672        params.push(("alt", "json".to_string()));
28673
28674        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/buildings/{buildingId}";
28675        if self._scopes.len() == 0 {
28676            self._scopes.insert(Scope::DirectoryResourceCalendarReadonly.as_ref().to_string(), ());
28677        }
28678
28679        for &(find_this, param_name) in [("{customer}", "customer"), ("{buildingId}", "buildingId")].iter() {
28680            let mut replace_with: Option<&str> = None;
28681            for &(name, ref value) in params.iter() {
28682                if name == param_name {
28683                    replace_with = Some(value);
28684                    break;
28685                }
28686            }
28687            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
28688        }
28689        {
28690            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
28691            for param_name in ["buildingId", "customer"].iter() {
28692                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
28693                    indices_for_removal.push(index);
28694                }
28695            }
28696            for &index in indices_for_removal.iter() {
28697                params.remove(index);
28698            }
28699        }
28700
28701        let url = hyper::Url::parse_with_params(&url, params).unwrap();
28702
28703
28704
28705        loop {
28706            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
28707                Ok(token) => token,
28708                Err(err) => {
28709                    match  dlg.token(&*err) {
28710                        Some(token) => token,
28711                        None => {
28712                            dlg.finished(false);
28713                            return Err(Error::MissingToken(err))
28714                        }
28715                    }
28716                }
28717            };
28718            let auth_header = Authorization(Bearer { token: token.access_token });
28719            let mut req_result = {
28720                let mut client = &mut *self.hub.client.borrow_mut();
28721                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
28722                    .header(UserAgent(self.hub._user_agent.clone()))
28723                    .header(auth_header.clone());
28724
28725                dlg.pre_request();
28726                req.send()
28727            };
28728
28729            match req_result {
28730                Err(err) => {
28731                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
28732                        sleep(d);
28733                        continue;
28734                    }
28735                    dlg.finished(false);
28736                    return Err(Error::HttpError(err))
28737                }
28738                Ok(mut res) => {
28739                    if !res.status.is_success() {
28740                        let mut json_err = String::new();
28741                        res.read_to_string(&mut json_err).unwrap();
28742                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
28743                                                              json::from_str(&json_err).ok(),
28744                                                              json::from_str(&json_err).ok()) {
28745                            sleep(d);
28746                            continue;
28747                        }
28748                        dlg.finished(false);
28749                        return match json::from_str::<ErrorResponse>(&json_err){
28750                            Err(_) => Err(Error::Failure(res)),
28751                            Ok(serr) => Err(Error::BadRequest(serr))
28752                        }
28753                    }
28754                    let result_value = {
28755                        let mut json_response = String::new();
28756                        res.read_to_string(&mut json_response).unwrap();
28757                        match json::from_str(&json_response) {
28758                            Ok(decoded) => (res, decoded),
28759                            Err(err) => {
28760                                dlg.response_json_decode_error(&json_response, &err);
28761                                return Err(Error::JsonDecodeError(json_response, err));
28762                            }
28763                        }
28764                    };
28765
28766                    dlg.finished(true);
28767                    return Ok(result_value)
28768                }
28769            }
28770        }
28771    }
28772
28773
28774    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
28775    ///
28776    /// Sets the *customer* path property to the given value.
28777    ///
28778    /// Even though the property as already been set when instantiating this call,
28779    /// we provide this method for API completeness.
28780    pub fn customer(mut self, new_value: &str) -> ResourceBuildingGetCall<'a, C, A> {
28781        self._customer = new_value.to_string();
28782        self
28783    }
28784    /// The unique ID of the building to retrieve.
28785    ///
28786    /// Sets the *building id* path property to the given value.
28787    ///
28788    /// Even though the property as already been set when instantiating this call,
28789    /// we provide this method for API completeness.
28790    pub fn building_id(mut self, new_value: &str) -> ResourceBuildingGetCall<'a, C, A> {
28791        self._building_id = new_value.to_string();
28792        self
28793    }
28794    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28795    /// while executing the actual API request.
28796    /// 
28797    /// It should be used to handle progress information, and to implement a certain level of resilience.
28798    ///
28799    /// Sets the *delegate* property to the given value.
28800    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceBuildingGetCall<'a, C, A> {
28801        self._delegate = Some(new_value);
28802        self
28803    }
28804
28805    /// Set any additional parameter of the query string used in the request.
28806    /// It should be used to set parameters which are not yet available through their own
28807    /// setters.
28808    ///
28809    /// Please note that this method must not be used to set any of the known parameters
28810    /// which have their own setter method. If done anyway, the request will fail.
28811    ///
28812    /// # Additional Parameters
28813    ///
28814    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28815    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28816    /// * *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.
28817    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28818    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28819    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28820    /// * *alt* (query-string) - Data format for the response.
28821    pub fn param<T>(mut self, name: T, value: T) -> ResourceBuildingGetCall<'a, C, A>
28822                                                        where T: AsRef<str> {
28823        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
28824        self
28825    }
28826
28827    /// Identifies the authorization scope for the method you are building.
28828    ///
28829    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
28830    /// `Scope::DirectoryResourceCalendarReadonly`.
28831    ///
28832    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28833    /// tokens for more than one scope.
28834    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
28835    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
28836    /// function for details).
28837    ///
28838    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28839    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28840    /// sufficient, a read-write scope will do as well.
28841    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceBuildingGetCall<'a, C, A>
28842                                                        where T: Into<Option<S>>,
28843                                                              S: AsRef<str> {
28844        match scope.into() {
28845          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
28846          None => None,
28847        };
28848        self
28849    }
28850}
28851
28852
28853/// Deletes a feature.
28854///
28855/// A builder for the *features.delete* method supported by a *resource* resource.
28856/// It is not used directly, but through a `ResourceMethods` instance.
28857///
28858/// # Example
28859///
28860/// Instantiate a resource method builder
28861///
28862/// ```test_harness,no_run
28863/// # extern crate hyper;
28864/// # extern crate hyper_rustls;
28865/// # extern crate yup_oauth2 as oauth2;
28866/// # extern crate google_admin1_directory as admin1_directory;
28867/// # #[test] fn egal() {
28868/// # use std::default::Default;
28869/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
28870/// # use admin1_directory::Directory;
28871/// 
28872/// # let secret: ApplicationSecret = Default::default();
28873/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
28874/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
28875/// #                               <MemoryStorage as Default>::default(), None);
28876/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
28877/// // You can configure optional parameters by calling the respective setters at will, and
28878/// // execute the final call using `doit()`.
28879/// // Values shown here are possibly random and not representative !
28880/// let result = hub.resources().features_delete("customer", "featureKey")
28881///              .doit();
28882/// # }
28883/// ```
28884pub struct ResourceFeatureDeleteCall<'a, C, A>
28885    where C: 'a, A: 'a {
28886
28887    hub: &'a Directory<C, A>,
28888    _customer: String,
28889    _feature_key: String,
28890    _delegate: Option<&'a mut dyn Delegate>,
28891    _additional_params: HashMap<String, String>,
28892    _scopes: BTreeMap<String, ()>
28893}
28894
28895impl<'a, C, A> CallBuilder for ResourceFeatureDeleteCall<'a, C, A> {}
28896
28897impl<'a, C, A> ResourceFeatureDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
28898
28899
28900    /// Perform the operation you have build so far.
28901    pub fn doit(mut self) -> Result<hyper::client::Response> {
28902        use std::io::{Read, Seek};
28903        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
28904        let mut dd = DefaultDelegate;
28905        let mut dlg: &mut dyn Delegate = match self._delegate {
28906            Some(d) => d,
28907            None => &mut dd
28908        };
28909        dlg.begin(MethodInfo { id: "directory.resources.features.delete",
28910                               http_method: hyper::method::Method::Delete });
28911        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
28912        params.push(("customer", self._customer.to_string()));
28913        params.push(("featureKey", self._feature_key.to_string()));
28914        for &field in ["customer", "featureKey"].iter() {
28915            if self._additional_params.contains_key(field) {
28916                dlg.finished(false);
28917                return Err(Error::FieldClash(field));
28918            }
28919        }
28920        for (name, value) in self._additional_params.iter() {
28921            params.push((&name, value.clone()));
28922        }
28923
28924
28925        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/features/{featureKey}";
28926        if self._scopes.len() == 0 {
28927            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
28928        }
28929
28930        for &(find_this, param_name) in [("{customer}", "customer"), ("{featureKey}", "featureKey")].iter() {
28931            let mut replace_with: Option<&str> = None;
28932            for &(name, ref value) in params.iter() {
28933                if name == param_name {
28934                    replace_with = Some(value);
28935                    break;
28936                }
28937            }
28938            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
28939        }
28940        {
28941            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
28942            for param_name in ["featureKey", "customer"].iter() {
28943                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
28944                    indices_for_removal.push(index);
28945                }
28946            }
28947            for &index in indices_for_removal.iter() {
28948                params.remove(index);
28949            }
28950        }
28951
28952        let url = hyper::Url::parse_with_params(&url, params).unwrap();
28953
28954
28955
28956        loop {
28957            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
28958                Ok(token) => token,
28959                Err(err) => {
28960                    match  dlg.token(&*err) {
28961                        Some(token) => token,
28962                        None => {
28963                            dlg.finished(false);
28964                            return Err(Error::MissingToken(err))
28965                        }
28966                    }
28967                }
28968            };
28969            let auth_header = Authorization(Bearer { token: token.access_token });
28970            let mut req_result = {
28971                let mut client = &mut *self.hub.client.borrow_mut();
28972                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
28973                    .header(UserAgent(self.hub._user_agent.clone()))
28974                    .header(auth_header.clone());
28975
28976                dlg.pre_request();
28977                req.send()
28978            };
28979
28980            match req_result {
28981                Err(err) => {
28982                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
28983                        sleep(d);
28984                        continue;
28985                    }
28986                    dlg.finished(false);
28987                    return Err(Error::HttpError(err))
28988                }
28989                Ok(mut res) => {
28990                    if !res.status.is_success() {
28991                        let mut json_err = String::new();
28992                        res.read_to_string(&mut json_err).unwrap();
28993                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
28994                                                              json::from_str(&json_err).ok(),
28995                                                              json::from_str(&json_err).ok()) {
28996                            sleep(d);
28997                            continue;
28998                        }
28999                        dlg.finished(false);
29000                        return match json::from_str::<ErrorResponse>(&json_err){
29001                            Err(_) => Err(Error::Failure(res)),
29002                            Ok(serr) => Err(Error::BadRequest(serr))
29003                        }
29004                    }
29005                    let result_value = res;
29006
29007                    dlg.finished(true);
29008                    return Ok(result_value)
29009                }
29010            }
29011        }
29012    }
29013
29014
29015    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
29016    ///
29017    /// Sets the *customer* path property to the given value.
29018    ///
29019    /// Even though the property as already been set when instantiating this call,
29020    /// we provide this method for API completeness.
29021    pub fn customer(mut self, new_value: &str) -> ResourceFeatureDeleteCall<'a, C, A> {
29022        self._customer = new_value.to_string();
29023        self
29024    }
29025    /// The unique ID of the feature to delete.
29026    ///
29027    /// Sets the *feature key* path property to the given value.
29028    ///
29029    /// Even though the property as already been set when instantiating this call,
29030    /// we provide this method for API completeness.
29031    pub fn feature_key(mut self, new_value: &str) -> ResourceFeatureDeleteCall<'a, C, A> {
29032        self._feature_key = new_value.to_string();
29033        self
29034    }
29035    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29036    /// while executing the actual API request.
29037    /// 
29038    /// It should be used to handle progress information, and to implement a certain level of resilience.
29039    ///
29040    /// Sets the *delegate* property to the given value.
29041    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceFeatureDeleteCall<'a, C, A> {
29042        self._delegate = Some(new_value);
29043        self
29044    }
29045
29046    /// Set any additional parameter of the query string used in the request.
29047    /// It should be used to set parameters which are not yet available through their own
29048    /// setters.
29049    ///
29050    /// Please note that this method must not be used to set any of the known parameters
29051    /// which have their own setter method. If done anyway, the request will fail.
29052    ///
29053    /// # Additional Parameters
29054    ///
29055    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29056    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29057    /// * *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.
29058    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29059    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29060    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29061    /// * *alt* (query-string) - Data format for the response.
29062    pub fn param<T>(mut self, name: T, value: T) -> ResourceFeatureDeleteCall<'a, C, A>
29063                                                        where T: AsRef<str> {
29064        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
29065        self
29066    }
29067
29068    /// Identifies the authorization scope for the method you are building.
29069    ///
29070    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
29071    /// `Scope::DirectoryResourceCalendar`.
29072    ///
29073    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29074    /// tokens for more than one scope.
29075    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
29076    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
29077    /// function for details).
29078    ///
29079    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29080    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29081    /// sufficient, a read-write scope will do as well.
29082    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceFeatureDeleteCall<'a, C, A>
29083                                                        where T: Into<Option<S>>,
29084                                                              S: AsRef<str> {
29085        match scope.into() {
29086          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
29087          None => None,
29088        };
29089        self
29090    }
29091}
29092
29093
29094/// Updates a feature.
29095///
29096/// A builder for the *features.update* method supported by a *resource* resource.
29097/// It is not used directly, but through a `ResourceMethods` instance.
29098///
29099/// # Example
29100///
29101/// Instantiate a resource method builder
29102///
29103/// ```test_harness,no_run
29104/// # extern crate hyper;
29105/// # extern crate hyper_rustls;
29106/// # extern crate yup_oauth2 as oauth2;
29107/// # extern crate google_admin1_directory as admin1_directory;
29108/// use admin1_directory::Feature;
29109/// # #[test] fn egal() {
29110/// # use std::default::Default;
29111/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
29112/// # use admin1_directory::Directory;
29113/// 
29114/// # let secret: ApplicationSecret = Default::default();
29115/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
29116/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
29117/// #                               <MemoryStorage as Default>::default(), None);
29118/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
29119/// // As the method needs a request, you would usually fill it with the desired information
29120/// // into the respective structure. Some of the parts shown here might not be applicable !
29121/// // Values shown here are possibly random and not representative !
29122/// let mut req = Feature::default();
29123/// 
29124/// // You can configure optional parameters by calling the respective setters at will, and
29125/// // execute the final call using `doit()`.
29126/// // Values shown here are possibly random and not representative !
29127/// let result = hub.resources().features_update(req, "customer", "featureKey")
29128///              .doit();
29129/// # }
29130/// ```
29131pub struct ResourceFeatureUpdateCall<'a, C, A>
29132    where C: 'a, A: 'a {
29133
29134    hub: &'a Directory<C, A>,
29135    _request: Feature,
29136    _customer: String,
29137    _feature_key: String,
29138    _delegate: Option<&'a mut dyn Delegate>,
29139    _additional_params: HashMap<String, String>,
29140    _scopes: BTreeMap<String, ()>
29141}
29142
29143impl<'a, C, A> CallBuilder for ResourceFeatureUpdateCall<'a, C, A> {}
29144
29145impl<'a, C, A> ResourceFeatureUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
29146
29147
29148    /// Perform the operation you have build so far.
29149    pub fn doit(mut self) -> Result<(hyper::client::Response, Feature)> {
29150        use std::io::{Read, Seek};
29151        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
29152        let mut dd = DefaultDelegate;
29153        let mut dlg: &mut dyn Delegate = match self._delegate {
29154            Some(d) => d,
29155            None => &mut dd
29156        };
29157        dlg.begin(MethodInfo { id: "directory.resources.features.update",
29158                               http_method: hyper::method::Method::Put });
29159        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
29160        params.push(("customer", self._customer.to_string()));
29161        params.push(("featureKey", self._feature_key.to_string()));
29162        for &field in ["alt", "customer", "featureKey"].iter() {
29163            if self._additional_params.contains_key(field) {
29164                dlg.finished(false);
29165                return Err(Error::FieldClash(field));
29166            }
29167        }
29168        for (name, value) in self._additional_params.iter() {
29169            params.push((&name, value.clone()));
29170        }
29171
29172        params.push(("alt", "json".to_string()));
29173
29174        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/features/{featureKey}";
29175        if self._scopes.len() == 0 {
29176            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
29177        }
29178
29179        for &(find_this, param_name) in [("{customer}", "customer"), ("{featureKey}", "featureKey")].iter() {
29180            let mut replace_with: Option<&str> = None;
29181            for &(name, ref value) in params.iter() {
29182                if name == param_name {
29183                    replace_with = Some(value);
29184                    break;
29185                }
29186            }
29187            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
29188        }
29189        {
29190            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
29191            for param_name in ["featureKey", "customer"].iter() {
29192                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
29193                    indices_for_removal.push(index);
29194                }
29195            }
29196            for &index in indices_for_removal.iter() {
29197                params.remove(index);
29198            }
29199        }
29200
29201        let url = hyper::Url::parse_with_params(&url, params).unwrap();
29202
29203        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
29204        let mut request_value_reader =
29205            {
29206                let mut value = json::value::to_value(&self._request).expect("serde to work");
29207                remove_json_null_values(&mut value);
29208                let mut dst = io::Cursor::new(Vec::with_capacity(128));
29209                json::to_writer(&mut dst, &value).unwrap();
29210                dst
29211            };
29212        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
29213        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
29214
29215
29216        loop {
29217            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
29218                Ok(token) => token,
29219                Err(err) => {
29220                    match  dlg.token(&*err) {
29221                        Some(token) => token,
29222                        None => {
29223                            dlg.finished(false);
29224                            return Err(Error::MissingToken(err))
29225                        }
29226                    }
29227                }
29228            };
29229            let auth_header = Authorization(Bearer { token: token.access_token });
29230            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
29231            let mut req_result = {
29232                let mut client = &mut *self.hub.client.borrow_mut();
29233                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
29234                    .header(UserAgent(self.hub._user_agent.clone()))
29235                    .header(auth_header.clone())
29236                    .header(ContentType(json_mime_type.clone()))
29237                    .header(ContentLength(request_size as u64))
29238                    .body(&mut request_value_reader);
29239
29240                dlg.pre_request();
29241                req.send()
29242            };
29243
29244            match req_result {
29245                Err(err) => {
29246                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
29247                        sleep(d);
29248                        continue;
29249                    }
29250                    dlg.finished(false);
29251                    return Err(Error::HttpError(err))
29252                }
29253                Ok(mut res) => {
29254                    if !res.status.is_success() {
29255                        let mut json_err = String::new();
29256                        res.read_to_string(&mut json_err).unwrap();
29257                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
29258                                                              json::from_str(&json_err).ok(),
29259                                                              json::from_str(&json_err).ok()) {
29260                            sleep(d);
29261                            continue;
29262                        }
29263                        dlg.finished(false);
29264                        return match json::from_str::<ErrorResponse>(&json_err){
29265                            Err(_) => Err(Error::Failure(res)),
29266                            Ok(serr) => Err(Error::BadRequest(serr))
29267                        }
29268                    }
29269                    let result_value = {
29270                        let mut json_response = String::new();
29271                        res.read_to_string(&mut json_response).unwrap();
29272                        match json::from_str(&json_response) {
29273                            Ok(decoded) => (res, decoded),
29274                            Err(err) => {
29275                                dlg.response_json_decode_error(&json_response, &err);
29276                                return Err(Error::JsonDecodeError(json_response, err));
29277                            }
29278                        }
29279                    };
29280
29281                    dlg.finished(true);
29282                    return Ok(result_value)
29283                }
29284            }
29285        }
29286    }
29287
29288
29289    ///
29290    /// Sets the *request* property to the given value.
29291    ///
29292    /// Even though the property as already been set when instantiating this call,
29293    /// we provide this method for API completeness.
29294    pub fn request(mut self, new_value: Feature) -> ResourceFeatureUpdateCall<'a, C, A> {
29295        self._request = new_value;
29296        self
29297    }
29298    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
29299    ///
29300    /// Sets the *customer* path property to the given value.
29301    ///
29302    /// Even though the property as already been set when instantiating this call,
29303    /// we provide this method for API completeness.
29304    pub fn customer(mut self, new_value: &str) -> ResourceFeatureUpdateCall<'a, C, A> {
29305        self._customer = new_value.to_string();
29306        self
29307    }
29308    /// The unique ID of the feature to update.
29309    ///
29310    /// Sets the *feature key* path property to the given value.
29311    ///
29312    /// Even though the property as already been set when instantiating this call,
29313    /// we provide this method for API completeness.
29314    pub fn feature_key(mut self, new_value: &str) -> ResourceFeatureUpdateCall<'a, C, A> {
29315        self._feature_key = new_value.to_string();
29316        self
29317    }
29318    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29319    /// while executing the actual API request.
29320    /// 
29321    /// It should be used to handle progress information, and to implement a certain level of resilience.
29322    ///
29323    /// Sets the *delegate* property to the given value.
29324    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceFeatureUpdateCall<'a, C, A> {
29325        self._delegate = Some(new_value);
29326        self
29327    }
29328
29329    /// Set any additional parameter of the query string used in the request.
29330    /// It should be used to set parameters which are not yet available through their own
29331    /// setters.
29332    ///
29333    /// Please note that this method must not be used to set any of the known parameters
29334    /// which have their own setter method. If done anyway, the request will fail.
29335    ///
29336    /// # Additional Parameters
29337    ///
29338    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29339    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29340    /// * *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.
29341    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29342    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29343    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29344    /// * *alt* (query-string) - Data format for the response.
29345    pub fn param<T>(mut self, name: T, value: T) -> ResourceFeatureUpdateCall<'a, C, A>
29346                                                        where T: AsRef<str> {
29347        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
29348        self
29349    }
29350
29351    /// Identifies the authorization scope for the method you are building.
29352    ///
29353    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
29354    /// `Scope::DirectoryResourceCalendar`.
29355    ///
29356    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29357    /// tokens for more than one scope.
29358    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
29359    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
29360    /// function for details).
29361    ///
29362    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29363    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29364    /// sufficient, a read-write scope will do as well.
29365    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceFeatureUpdateCall<'a, C, A>
29366                                                        where T: Into<Option<S>>,
29367                                                              S: AsRef<str> {
29368        match scope.into() {
29369          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
29370          None => None,
29371        };
29372        self
29373    }
29374}
29375
29376
29377/// Inserts a building.
29378///
29379/// A builder for the *buildings.insert* method supported by a *resource* resource.
29380/// It is not used directly, but through a `ResourceMethods` instance.
29381///
29382/// # Example
29383///
29384/// Instantiate a resource method builder
29385///
29386/// ```test_harness,no_run
29387/// # extern crate hyper;
29388/// # extern crate hyper_rustls;
29389/// # extern crate yup_oauth2 as oauth2;
29390/// # extern crate google_admin1_directory as admin1_directory;
29391/// use admin1_directory::Building;
29392/// # #[test] fn egal() {
29393/// # use std::default::Default;
29394/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
29395/// # use admin1_directory::Directory;
29396/// 
29397/// # let secret: ApplicationSecret = Default::default();
29398/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
29399/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
29400/// #                               <MemoryStorage as Default>::default(), None);
29401/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
29402/// // As the method needs a request, you would usually fill it with the desired information
29403/// // into the respective structure. Some of the parts shown here might not be applicable !
29404/// // Values shown here are possibly random and not representative !
29405/// let mut req = Building::default();
29406/// 
29407/// // You can configure optional parameters by calling the respective setters at will, and
29408/// // execute the final call using `doit()`.
29409/// // Values shown here are possibly random and not representative !
29410/// let result = hub.resources().buildings_insert(req, "customer")
29411///              .coordinates_source("magna")
29412///              .doit();
29413/// # }
29414/// ```
29415pub struct ResourceBuildingInsertCall<'a, C, A>
29416    where C: 'a, A: 'a {
29417
29418    hub: &'a Directory<C, A>,
29419    _request: Building,
29420    _customer: String,
29421    _coordinates_source: Option<String>,
29422    _delegate: Option<&'a mut dyn Delegate>,
29423    _additional_params: HashMap<String, String>,
29424    _scopes: BTreeMap<String, ()>
29425}
29426
29427impl<'a, C, A> CallBuilder for ResourceBuildingInsertCall<'a, C, A> {}
29428
29429impl<'a, C, A> ResourceBuildingInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
29430
29431
29432    /// Perform the operation you have build so far.
29433    pub fn doit(mut self) -> Result<(hyper::client::Response, Building)> {
29434        use std::io::{Read, Seek};
29435        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
29436        let mut dd = DefaultDelegate;
29437        let mut dlg: &mut dyn Delegate = match self._delegate {
29438            Some(d) => d,
29439            None => &mut dd
29440        };
29441        dlg.begin(MethodInfo { id: "directory.resources.buildings.insert",
29442                               http_method: hyper::method::Method::Post });
29443        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
29444        params.push(("customer", self._customer.to_string()));
29445        if let Some(value) = self._coordinates_source {
29446            params.push(("coordinatesSource", value.to_string()));
29447        }
29448        for &field in ["alt", "customer", "coordinatesSource"].iter() {
29449            if self._additional_params.contains_key(field) {
29450                dlg.finished(false);
29451                return Err(Error::FieldClash(field));
29452            }
29453        }
29454        for (name, value) in self._additional_params.iter() {
29455            params.push((&name, value.clone()));
29456        }
29457
29458        params.push(("alt", "json".to_string()));
29459
29460        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/buildings";
29461        if self._scopes.len() == 0 {
29462            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
29463        }
29464
29465        for &(find_this, param_name) in [("{customer}", "customer")].iter() {
29466            let mut replace_with: Option<&str> = None;
29467            for &(name, ref value) in params.iter() {
29468                if name == param_name {
29469                    replace_with = Some(value);
29470                    break;
29471                }
29472            }
29473            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
29474        }
29475        {
29476            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
29477            for param_name in ["customer"].iter() {
29478                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
29479                    indices_for_removal.push(index);
29480                }
29481            }
29482            for &index in indices_for_removal.iter() {
29483                params.remove(index);
29484            }
29485        }
29486
29487        let url = hyper::Url::parse_with_params(&url, params).unwrap();
29488
29489        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
29490        let mut request_value_reader =
29491            {
29492                let mut value = json::value::to_value(&self._request).expect("serde to work");
29493                remove_json_null_values(&mut value);
29494                let mut dst = io::Cursor::new(Vec::with_capacity(128));
29495                json::to_writer(&mut dst, &value).unwrap();
29496                dst
29497            };
29498        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
29499        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
29500
29501
29502        loop {
29503            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
29504                Ok(token) => token,
29505                Err(err) => {
29506                    match  dlg.token(&*err) {
29507                        Some(token) => token,
29508                        None => {
29509                            dlg.finished(false);
29510                            return Err(Error::MissingToken(err))
29511                        }
29512                    }
29513                }
29514            };
29515            let auth_header = Authorization(Bearer { token: token.access_token });
29516            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
29517            let mut req_result = {
29518                let mut client = &mut *self.hub.client.borrow_mut();
29519                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
29520                    .header(UserAgent(self.hub._user_agent.clone()))
29521                    .header(auth_header.clone())
29522                    .header(ContentType(json_mime_type.clone()))
29523                    .header(ContentLength(request_size as u64))
29524                    .body(&mut request_value_reader);
29525
29526                dlg.pre_request();
29527                req.send()
29528            };
29529
29530            match req_result {
29531                Err(err) => {
29532                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
29533                        sleep(d);
29534                        continue;
29535                    }
29536                    dlg.finished(false);
29537                    return Err(Error::HttpError(err))
29538                }
29539                Ok(mut res) => {
29540                    if !res.status.is_success() {
29541                        let mut json_err = String::new();
29542                        res.read_to_string(&mut json_err).unwrap();
29543                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
29544                                                              json::from_str(&json_err).ok(),
29545                                                              json::from_str(&json_err).ok()) {
29546                            sleep(d);
29547                            continue;
29548                        }
29549                        dlg.finished(false);
29550                        return match json::from_str::<ErrorResponse>(&json_err){
29551                            Err(_) => Err(Error::Failure(res)),
29552                            Ok(serr) => Err(Error::BadRequest(serr))
29553                        }
29554                    }
29555                    let result_value = {
29556                        let mut json_response = String::new();
29557                        res.read_to_string(&mut json_response).unwrap();
29558                        match json::from_str(&json_response) {
29559                            Ok(decoded) => (res, decoded),
29560                            Err(err) => {
29561                                dlg.response_json_decode_error(&json_response, &err);
29562                                return Err(Error::JsonDecodeError(json_response, err));
29563                            }
29564                        }
29565                    };
29566
29567                    dlg.finished(true);
29568                    return Ok(result_value)
29569                }
29570            }
29571        }
29572    }
29573
29574
29575    ///
29576    /// Sets the *request* property to the given value.
29577    ///
29578    /// Even though the property as already been set when instantiating this call,
29579    /// we provide this method for API completeness.
29580    pub fn request(mut self, new_value: Building) -> ResourceBuildingInsertCall<'a, C, A> {
29581        self._request = new_value;
29582        self
29583    }
29584    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
29585    ///
29586    /// Sets the *customer* path property to the given value.
29587    ///
29588    /// Even though the property as already been set when instantiating this call,
29589    /// we provide this method for API completeness.
29590    pub fn customer(mut self, new_value: &str) -> ResourceBuildingInsertCall<'a, C, A> {
29591        self._customer = new_value.to_string();
29592        self
29593    }
29594    /// Source from which Building.coordinates are derived.
29595    ///
29596    /// Sets the *coordinates source* query property to the given value.
29597    pub fn coordinates_source(mut self, new_value: &str) -> ResourceBuildingInsertCall<'a, C, A> {
29598        self._coordinates_source = Some(new_value.to_string());
29599        self
29600    }
29601    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29602    /// while executing the actual API request.
29603    /// 
29604    /// It should be used to handle progress information, and to implement a certain level of resilience.
29605    ///
29606    /// Sets the *delegate* property to the given value.
29607    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceBuildingInsertCall<'a, C, A> {
29608        self._delegate = Some(new_value);
29609        self
29610    }
29611
29612    /// Set any additional parameter of the query string used in the request.
29613    /// It should be used to set parameters which are not yet available through their own
29614    /// setters.
29615    ///
29616    /// Please note that this method must not be used to set any of the known parameters
29617    /// which have their own setter method. If done anyway, the request will fail.
29618    ///
29619    /// # Additional Parameters
29620    ///
29621    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29622    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29623    /// * *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.
29624    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29625    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29626    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29627    /// * *alt* (query-string) - Data format for the response.
29628    pub fn param<T>(mut self, name: T, value: T) -> ResourceBuildingInsertCall<'a, C, A>
29629                                                        where T: AsRef<str> {
29630        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
29631        self
29632    }
29633
29634    /// Identifies the authorization scope for the method you are building.
29635    ///
29636    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
29637    /// `Scope::DirectoryResourceCalendar`.
29638    ///
29639    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29640    /// tokens for more than one scope.
29641    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
29642    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
29643    /// function for details).
29644    ///
29645    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29646    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29647    /// sufficient, a read-write scope will do as well.
29648    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceBuildingInsertCall<'a, C, A>
29649                                                        where T: Into<Option<S>>,
29650                                                              S: AsRef<str> {
29651        match scope.into() {
29652          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
29653          None => None,
29654        };
29655        self
29656    }
29657}
29658
29659
29660/// Updates a calendar resource.
29661/// 
29662/// This method supports patch semantics, meaning you only need to include the fields you wish to update. Fields that are not present in the request will be preserved. This method supports patch semantics.
29663///
29664/// A builder for the *calendars.patch* method supported by a *resource* resource.
29665/// It is not used directly, but through a `ResourceMethods` instance.
29666///
29667/// # Example
29668///
29669/// Instantiate a resource method builder
29670///
29671/// ```test_harness,no_run
29672/// # extern crate hyper;
29673/// # extern crate hyper_rustls;
29674/// # extern crate yup_oauth2 as oauth2;
29675/// # extern crate google_admin1_directory as admin1_directory;
29676/// use admin1_directory::CalendarResource;
29677/// # #[test] fn egal() {
29678/// # use std::default::Default;
29679/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
29680/// # use admin1_directory::Directory;
29681/// 
29682/// # let secret: ApplicationSecret = Default::default();
29683/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
29684/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
29685/// #                               <MemoryStorage as Default>::default(), None);
29686/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
29687/// // As the method needs a request, you would usually fill it with the desired information
29688/// // into the respective structure. Some of the parts shown here might not be applicable !
29689/// // Values shown here are possibly random and not representative !
29690/// let mut req = CalendarResource::default();
29691/// 
29692/// // You can configure optional parameters by calling the respective setters at will, and
29693/// // execute the final call using `doit()`.
29694/// // Values shown here are possibly random and not representative !
29695/// let result = hub.resources().calendars_patch(req, "customer", "calendarResourceId")
29696///              .doit();
29697/// # }
29698/// ```
29699pub struct ResourceCalendarPatchCall<'a, C, A>
29700    where C: 'a, A: 'a {
29701
29702    hub: &'a Directory<C, A>,
29703    _request: CalendarResource,
29704    _customer: String,
29705    _calendar_resource_id: String,
29706    _delegate: Option<&'a mut dyn Delegate>,
29707    _additional_params: HashMap<String, String>,
29708    _scopes: BTreeMap<String, ()>
29709}
29710
29711impl<'a, C, A> CallBuilder for ResourceCalendarPatchCall<'a, C, A> {}
29712
29713impl<'a, C, A> ResourceCalendarPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
29714
29715
29716    /// Perform the operation you have build so far.
29717    pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarResource)> {
29718        use std::io::{Read, Seek};
29719        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
29720        let mut dd = DefaultDelegate;
29721        let mut dlg: &mut dyn Delegate = match self._delegate {
29722            Some(d) => d,
29723            None => &mut dd
29724        };
29725        dlg.begin(MethodInfo { id: "directory.resources.calendars.patch",
29726                               http_method: hyper::method::Method::Patch });
29727        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
29728        params.push(("customer", self._customer.to_string()));
29729        params.push(("calendarResourceId", self._calendar_resource_id.to_string()));
29730        for &field in ["alt", "customer", "calendarResourceId"].iter() {
29731            if self._additional_params.contains_key(field) {
29732                dlg.finished(false);
29733                return Err(Error::FieldClash(field));
29734            }
29735        }
29736        for (name, value) in self._additional_params.iter() {
29737            params.push((&name, value.clone()));
29738        }
29739
29740        params.push(("alt", "json".to_string()));
29741
29742        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/calendars/{calendarResourceId}";
29743        if self._scopes.len() == 0 {
29744            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
29745        }
29746
29747        for &(find_this, param_name) in [("{customer}", "customer"), ("{calendarResourceId}", "calendarResourceId")].iter() {
29748            let mut replace_with: Option<&str> = None;
29749            for &(name, ref value) in params.iter() {
29750                if name == param_name {
29751                    replace_with = Some(value);
29752                    break;
29753                }
29754            }
29755            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
29756        }
29757        {
29758            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
29759            for param_name in ["calendarResourceId", "customer"].iter() {
29760                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
29761                    indices_for_removal.push(index);
29762                }
29763            }
29764            for &index in indices_for_removal.iter() {
29765                params.remove(index);
29766            }
29767        }
29768
29769        let url = hyper::Url::parse_with_params(&url, params).unwrap();
29770
29771        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
29772        let mut request_value_reader =
29773            {
29774                let mut value = json::value::to_value(&self._request).expect("serde to work");
29775                remove_json_null_values(&mut value);
29776                let mut dst = io::Cursor::new(Vec::with_capacity(128));
29777                json::to_writer(&mut dst, &value).unwrap();
29778                dst
29779            };
29780        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
29781        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
29782
29783
29784        loop {
29785            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
29786                Ok(token) => token,
29787                Err(err) => {
29788                    match  dlg.token(&*err) {
29789                        Some(token) => token,
29790                        None => {
29791                            dlg.finished(false);
29792                            return Err(Error::MissingToken(err))
29793                        }
29794                    }
29795                }
29796            };
29797            let auth_header = Authorization(Bearer { token: token.access_token });
29798            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
29799            let mut req_result = {
29800                let mut client = &mut *self.hub.client.borrow_mut();
29801                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
29802                    .header(UserAgent(self.hub._user_agent.clone()))
29803                    .header(auth_header.clone())
29804                    .header(ContentType(json_mime_type.clone()))
29805                    .header(ContentLength(request_size as u64))
29806                    .body(&mut request_value_reader);
29807
29808                dlg.pre_request();
29809                req.send()
29810            };
29811
29812            match req_result {
29813                Err(err) => {
29814                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
29815                        sleep(d);
29816                        continue;
29817                    }
29818                    dlg.finished(false);
29819                    return Err(Error::HttpError(err))
29820                }
29821                Ok(mut res) => {
29822                    if !res.status.is_success() {
29823                        let mut json_err = String::new();
29824                        res.read_to_string(&mut json_err).unwrap();
29825                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
29826                                                              json::from_str(&json_err).ok(),
29827                                                              json::from_str(&json_err).ok()) {
29828                            sleep(d);
29829                            continue;
29830                        }
29831                        dlg.finished(false);
29832                        return match json::from_str::<ErrorResponse>(&json_err){
29833                            Err(_) => Err(Error::Failure(res)),
29834                            Ok(serr) => Err(Error::BadRequest(serr))
29835                        }
29836                    }
29837                    let result_value = {
29838                        let mut json_response = String::new();
29839                        res.read_to_string(&mut json_response).unwrap();
29840                        match json::from_str(&json_response) {
29841                            Ok(decoded) => (res, decoded),
29842                            Err(err) => {
29843                                dlg.response_json_decode_error(&json_response, &err);
29844                                return Err(Error::JsonDecodeError(json_response, err));
29845                            }
29846                        }
29847                    };
29848
29849                    dlg.finished(true);
29850                    return Ok(result_value)
29851                }
29852            }
29853        }
29854    }
29855
29856
29857    ///
29858    /// Sets the *request* property to the given value.
29859    ///
29860    /// Even though the property as already been set when instantiating this call,
29861    /// we provide this method for API completeness.
29862    pub fn request(mut self, new_value: CalendarResource) -> ResourceCalendarPatchCall<'a, C, A> {
29863        self._request = new_value;
29864        self
29865    }
29866    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
29867    ///
29868    /// Sets the *customer* path property to the given value.
29869    ///
29870    /// Even though the property as already been set when instantiating this call,
29871    /// we provide this method for API completeness.
29872    pub fn customer(mut self, new_value: &str) -> ResourceCalendarPatchCall<'a, C, A> {
29873        self._customer = new_value.to_string();
29874        self
29875    }
29876    /// The unique ID of the calendar resource to update.
29877    ///
29878    /// Sets the *calendar resource id* path property to the given value.
29879    ///
29880    /// Even though the property as already been set when instantiating this call,
29881    /// we provide this method for API completeness.
29882    pub fn calendar_resource_id(mut self, new_value: &str) -> ResourceCalendarPatchCall<'a, C, A> {
29883        self._calendar_resource_id = new_value.to_string();
29884        self
29885    }
29886    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29887    /// while executing the actual API request.
29888    /// 
29889    /// It should be used to handle progress information, and to implement a certain level of resilience.
29890    ///
29891    /// Sets the *delegate* property to the given value.
29892    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceCalendarPatchCall<'a, C, A> {
29893        self._delegate = Some(new_value);
29894        self
29895    }
29896
29897    /// Set any additional parameter of the query string used in the request.
29898    /// It should be used to set parameters which are not yet available through their own
29899    /// setters.
29900    ///
29901    /// Please note that this method must not be used to set any of the known parameters
29902    /// which have their own setter method. If done anyway, the request will fail.
29903    ///
29904    /// # Additional Parameters
29905    ///
29906    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29907    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29908    /// * *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.
29909    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29910    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29911    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29912    /// * *alt* (query-string) - Data format for the response.
29913    pub fn param<T>(mut self, name: T, value: T) -> ResourceCalendarPatchCall<'a, C, A>
29914                                                        where T: AsRef<str> {
29915        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
29916        self
29917    }
29918
29919    /// Identifies the authorization scope for the method you are building.
29920    ///
29921    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
29922    /// `Scope::DirectoryResourceCalendar`.
29923    ///
29924    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29925    /// tokens for more than one scope.
29926    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
29927    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
29928    /// function for details).
29929    ///
29930    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29931    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29932    /// sufficient, a read-write scope will do as well.
29933    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceCalendarPatchCall<'a, C, A>
29934                                                        where T: Into<Option<S>>,
29935                                                              S: AsRef<str> {
29936        match scope.into() {
29937          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
29938          None => None,
29939        };
29940        self
29941    }
29942}
29943
29944
29945/// Updates a calendar resource.
29946/// 
29947/// This method supports patch semantics, meaning you only need to include the fields you wish to update. Fields that are not present in the request will be preserved.
29948///
29949/// A builder for the *calendars.update* method supported by a *resource* resource.
29950/// It is not used directly, but through a `ResourceMethods` instance.
29951///
29952/// # Example
29953///
29954/// Instantiate a resource method builder
29955///
29956/// ```test_harness,no_run
29957/// # extern crate hyper;
29958/// # extern crate hyper_rustls;
29959/// # extern crate yup_oauth2 as oauth2;
29960/// # extern crate google_admin1_directory as admin1_directory;
29961/// use admin1_directory::CalendarResource;
29962/// # #[test] fn egal() {
29963/// # use std::default::Default;
29964/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
29965/// # use admin1_directory::Directory;
29966/// 
29967/// # let secret: ApplicationSecret = Default::default();
29968/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
29969/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
29970/// #                               <MemoryStorage as Default>::default(), None);
29971/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
29972/// // As the method needs a request, you would usually fill it with the desired information
29973/// // into the respective structure. Some of the parts shown here might not be applicable !
29974/// // Values shown here are possibly random and not representative !
29975/// let mut req = CalendarResource::default();
29976/// 
29977/// // You can configure optional parameters by calling the respective setters at will, and
29978/// // execute the final call using `doit()`.
29979/// // Values shown here are possibly random and not representative !
29980/// let result = hub.resources().calendars_update(req, "customer", "calendarResourceId")
29981///              .doit();
29982/// # }
29983/// ```
29984pub struct ResourceCalendarUpdateCall<'a, C, A>
29985    where C: 'a, A: 'a {
29986
29987    hub: &'a Directory<C, A>,
29988    _request: CalendarResource,
29989    _customer: String,
29990    _calendar_resource_id: String,
29991    _delegate: Option<&'a mut dyn Delegate>,
29992    _additional_params: HashMap<String, String>,
29993    _scopes: BTreeMap<String, ()>
29994}
29995
29996impl<'a, C, A> CallBuilder for ResourceCalendarUpdateCall<'a, C, A> {}
29997
29998impl<'a, C, A> ResourceCalendarUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
29999
30000
30001    /// Perform the operation you have build so far.
30002    pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarResource)> {
30003        use std::io::{Read, Seek};
30004        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
30005        let mut dd = DefaultDelegate;
30006        let mut dlg: &mut dyn Delegate = match self._delegate {
30007            Some(d) => d,
30008            None => &mut dd
30009        };
30010        dlg.begin(MethodInfo { id: "directory.resources.calendars.update",
30011                               http_method: hyper::method::Method::Put });
30012        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
30013        params.push(("customer", self._customer.to_string()));
30014        params.push(("calendarResourceId", self._calendar_resource_id.to_string()));
30015        for &field in ["alt", "customer", "calendarResourceId"].iter() {
30016            if self._additional_params.contains_key(field) {
30017                dlg.finished(false);
30018                return Err(Error::FieldClash(field));
30019            }
30020        }
30021        for (name, value) in self._additional_params.iter() {
30022            params.push((&name, value.clone()));
30023        }
30024
30025        params.push(("alt", "json".to_string()));
30026
30027        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/calendars/{calendarResourceId}";
30028        if self._scopes.len() == 0 {
30029            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
30030        }
30031
30032        for &(find_this, param_name) in [("{customer}", "customer"), ("{calendarResourceId}", "calendarResourceId")].iter() {
30033            let mut replace_with: Option<&str> = None;
30034            for &(name, ref value) in params.iter() {
30035                if name == param_name {
30036                    replace_with = Some(value);
30037                    break;
30038                }
30039            }
30040            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
30041        }
30042        {
30043            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
30044            for param_name in ["calendarResourceId", "customer"].iter() {
30045                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
30046                    indices_for_removal.push(index);
30047                }
30048            }
30049            for &index in indices_for_removal.iter() {
30050                params.remove(index);
30051            }
30052        }
30053
30054        let url = hyper::Url::parse_with_params(&url, params).unwrap();
30055
30056        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
30057        let mut request_value_reader =
30058            {
30059                let mut value = json::value::to_value(&self._request).expect("serde to work");
30060                remove_json_null_values(&mut value);
30061                let mut dst = io::Cursor::new(Vec::with_capacity(128));
30062                json::to_writer(&mut dst, &value).unwrap();
30063                dst
30064            };
30065        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
30066        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
30067
30068
30069        loop {
30070            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
30071                Ok(token) => token,
30072                Err(err) => {
30073                    match  dlg.token(&*err) {
30074                        Some(token) => token,
30075                        None => {
30076                            dlg.finished(false);
30077                            return Err(Error::MissingToken(err))
30078                        }
30079                    }
30080                }
30081            };
30082            let auth_header = Authorization(Bearer { token: token.access_token });
30083            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
30084            let mut req_result = {
30085                let mut client = &mut *self.hub.client.borrow_mut();
30086                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
30087                    .header(UserAgent(self.hub._user_agent.clone()))
30088                    .header(auth_header.clone())
30089                    .header(ContentType(json_mime_type.clone()))
30090                    .header(ContentLength(request_size as u64))
30091                    .body(&mut request_value_reader);
30092
30093                dlg.pre_request();
30094                req.send()
30095            };
30096
30097            match req_result {
30098                Err(err) => {
30099                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
30100                        sleep(d);
30101                        continue;
30102                    }
30103                    dlg.finished(false);
30104                    return Err(Error::HttpError(err))
30105                }
30106                Ok(mut res) => {
30107                    if !res.status.is_success() {
30108                        let mut json_err = String::new();
30109                        res.read_to_string(&mut json_err).unwrap();
30110                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
30111                                                              json::from_str(&json_err).ok(),
30112                                                              json::from_str(&json_err).ok()) {
30113                            sleep(d);
30114                            continue;
30115                        }
30116                        dlg.finished(false);
30117                        return match json::from_str::<ErrorResponse>(&json_err){
30118                            Err(_) => Err(Error::Failure(res)),
30119                            Ok(serr) => Err(Error::BadRequest(serr))
30120                        }
30121                    }
30122                    let result_value = {
30123                        let mut json_response = String::new();
30124                        res.read_to_string(&mut json_response).unwrap();
30125                        match json::from_str(&json_response) {
30126                            Ok(decoded) => (res, decoded),
30127                            Err(err) => {
30128                                dlg.response_json_decode_error(&json_response, &err);
30129                                return Err(Error::JsonDecodeError(json_response, err));
30130                            }
30131                        }
30132                    };
30133
30134                    dlg.finished(true);
30135                    return Ok(result_value)
30136                }
30137            }
30138        }
30139    }
30140
30141
30142    ///
30143    /// Sets the *request* property to the given value.
30144    ///
30145    /// Even though the property as already been set when instantiating this call,
30146    /// we provide this method for API completeness.
30147    pub fn request(mut self, new_value: CalendarResource) -> ResourceCalendarUpdateCall<'a, C, A> {
30148        self._request = new_value;
30149        self
30150    }
30151    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
30152    ///
30153    /// Sets the *customer* path property to the given value.
30154    ///
30155    /// Even though the property as already been set when instantiating this call,
30156    /// we provide this method for API completeness.
30157    pub fn customer(mut self, new_value: &str) -> ResourceCalendarUpdateCall<'a, C, A> {
30158        self._customer = new_value.to_string();
30159        self
30160    }
30161    /// The unique ID of the calendar resource to update.
30162    ///
30163    /// Sets the *calendar resource id* path property to the given value.
30164    ///
30165    /// Even though the property as already been set when instantiating this call,
30166    /// we provide this method for API completeness.
30167    pub fn calendar_resource_id(mut self, new_value: &str) -> ResourceCalendarUpdateCall<'a, C, A> {
30168        self._calendar_resource_id = new_value.to_string();
30169        self
30170    }
30171    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30172    /// while executing the actual API request.
30173    /// 
30174    /// It should be used to handle progress information, and to implement a certain level of resilience.
30175    ///
30176    /// Sets the *delegate* property to the given value.
30177    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceCalendarUpdateCall<'a, C, A> {
30178        self._delegate = Some(new_value);
30179        self
30180    }
30181
30182    /// Set any additional parameter of the query string used in the request.
30183    /// It should be used to set parameters which are not yet available through their own
30184    /// setters.
30185    ///
30186    /// Please note that this method must not be used to set any of the known parameters
30187    /// which have their own setter method. If done anyway, the request will fail.
30188    ///
30189    /// # Additional Parameters
30190    ///
30191    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30192    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30193    /// * *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.
30194    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30195    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30196    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30197    /// * *alt* (query-string) - Data format for the response.
30198    pub fn param<T>(mut self, name: T, value: T) -> ResourceCalendarUpdateCall<'a, C, A>
30199                                                        where T: AsRef<str> {
30200        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
30201        self
30202    }
30203
30204    /// Identifies the authorization scope for the method you are building.
30205    ///
30206    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
30207    /// `Scope::DirectoryResourceCalendar`.
30208    ///
30209    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30210    /// tokens for more than one scope.
30211    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
30212    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
30213    /// function for details).
30214    ///
30215    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30216    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30217    /// sufficient, a read-write scope will do as well.
30218    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceCalendarUpdateCall<'a, C, A>
30219                                                        where T: Into<Option<S>>,
30220                                                              S: AsRef<str> {
30221        match scope.into() {
30222          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
30223          None => None,
30224        };
30225        self
30226    }
30227}
30228
30229
30230/// Deletes a calendar resource.
30231///
30232/// A builder for the *calendars.delete* method supported by a *resource* resource.
30233/// It is not used directly, but through a `ResourceMethods` instance.
30234///
30235/// # Example
30236///
30237/// Instantiate a resource method builder
30238///
30239/// ```test_harness,no_run
30240/// # extern crate hyper;
30241/// # extern crate hyper_rustls;
30242/// # extern crate yup_oauth2 as oauth2;
30243/// # extern crate google_admin1_directory as admin1_directory;
30244/// # #[test] fn egal() {
30245/// # use std::default::Default;
30246/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
30247/// # use admin1_directory::Directory;
30248/// 
30249/// # let secret: ApplicationSecret = Default::default();
30250/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
30251/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
30252/// #                               <MemoryStorage as Default>::default(), None);
30253/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
30254/// // You can configure optional parameters by calling the respective setters at will, and
30255/// // execute the final call using `doit()`.
30256/// // Values shown here are possibly random and not representative !
30257/// let result = hub.resources().calendars_delete("customer", "calendarResourceId")
30258///              .doit();
30259/// # }
30260/// ```
30261pub struct ResourceCalendarDeleteCall<'a, C, A>
30262    where C: 'a, A: 'a {
30263
30264    hub: &'a Directory<C, A>,
30265    _customer: String,
30266    _calendar_resource_id: String,
30267    _delegate: Option<&'a mut dyn Delegate>,
30268    _additional_params: HashMap<String, String>,
30269    _scopes: BTreeMap<String, ()>
30270}
30271
30272impl<'a, C, A> CallBuilder for ResourceCalendarDeleteCall<'a, C, A> {}
30273
30274impl<'a, C, A> ResourceCalendarDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
30275
30276
30277    /// Perform the operation you have build so far.
30278    pub fn doit(mut self) -> Result<hyper::client::Response> {
30279        use std::io::{Read, Seek};
30280        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
30281        let mut dd = DefaultDelegate;
30282        let mut dlg: &mut dyn Delegate = match self._delegate {
30283            Some(d) => d,
30284            None => &mut dd
30285        };
30286        dlg.begin(MethodInfo { id: "directory.resources.calendars.delete",
30287                               http_method: hyper::method::Method::Delete });
30288        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
30289        params.push(("customer", self._customer.to_string()));
30290        params.push(("calendarResourceId", self._calendar_resource_id.to_string()));
30291        for &field in ["customer", "calendarResourceId"].iter() {
30292            if self._additional_params.contains_key(field) {
30293                dlg.finished(false);
30294                return Err(Error::FieldClash(field));
30295            }
30296        }
30297        for (name, value) in self._additional_params.iter() {
30298            params.push((&name, value.clone()));
30299        }
30300
30301
30302        let mut url = self.hub._base_url.clone() + "customer/{customer}/resources/calendars/{calendarResourceId}";
30303        if self._scopes.len() == 0 {
30304            self._scopes.insert(Scope::DirectoryResourceCalendar.as_ref().to_string(), ());
30305        }
30306
30307        for &(find_this, param_name) in [("{customer}", "customer"), ("{calendarResourceId}", "calendarResourceId")].iter() {
30308            let mut replace_with: Option<&str> = None;
30309            for &(name, ref value) in params.iter() {
30310                if name == param_name {
30311                    replace_with = Some(value);
30312                    break;
30313                }
30314            }
30315            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
30316        }
30317        {
30318            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
30319            for param_name in ["calendarResourceId", "customer"].iter() {
30320                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
30321                    indices_for_removal.push(index);
30322                }
30323            }
30324            for &index in indices_for_removal.iter() {
30325                params.remove(index);
30326            }
30327        }
30328
30329        let url = hyper::Url::parse_with_params(&url, params).unwrap();
30330
30331
30332
30333        loop {
30334            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
30335                Ok(token) => token,
30336                Err(err) => {
30337                    match  dlg.token(&*err) {
30338                        Some(token) => token,
30339                        None => {
30340                            dlg.finished(false);
30341                            return Err(Error::MissingToken(err))
30342                        }
30343                    }
30344                }
30345            };
30346            let auth_header = Authorization(Bearer { token: token.access_token });
30347            let mut req_result = {
30348                let mut client = &mut *self.hub.client.borrow_mut();
30349                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
30350                    .header(UserAgent(self.hub._user_agent.clone()))
30351                    .header(auth_header.clone());
30352
30353                dlg.pre_request();
30354                req.send()
30355            };
30356
30357            match req_result {
30358                Err(err) => {
30359                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
30360                        sleep(d);
30361                        continue;
30362                    }
30363                    dlg.finished(false);
30364                    return Err(Error::HttpError(err))
30365                }
30366                Ok(mut res) => {
30367                    if !res.status.is_success() {
30368                        let mut json_err = String::new();
30369                        res.read_to_string(&mut json_err).unwrap();
30370                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
30371                                                              json::from_str(&json_err).ok(),
30372                                                              json::from_str(&json_err).ok()) {
30373                            sleep(d);
30374                            continue;
30375                        }
30376                        dlg.finished(false);
30377                        return match json::from_str::<ErrorResponse>(&json_err){
30378                            Err(_) => Err(Error::Failure(res)),
30379                            Ok(serr) => Err(Error::BadRequest(serr))
30380                        }
30381                    }
30382                    let result_value = res;
30383
30384                    dlg.finished(true);
30385                    return Ok(result_value)
30386                }
30387            }
30388        }
30389    }
30390
30391
30392    /// The unique ID for the customer's G Suite account. As an account administrator, you can also use the my_customer alias to represent your account's customer ID.
30393    ///
30394    /// Sets the *customer* path property to the given value.
30395    ///
30396    /// Even though the property as already been set when instantiating this call,
30397    /// we provide this method for API completeness.
30398    pub fn customer(mut self, new_value: &str) -> ResourceCalendarDeleteCall<'a, C, A> {
30399        self._customer = new_value.to_string();
30400        self
30401    }
30402    /// The unique ID of the calendar resource to delete.
30403    ///
30404    /// Sets the *calendar resource id* path property to the given value.
30405    ///
30406    /// Even though the property as already been set when instantiating this call,
30407    /// we provide this method for API completeness.
30408    pub fn calendar_resource_id(mut self, new_value: &str) -> ResourceCalendarDeleteCall<'a, C, A> {
30409        self._calendar_resource_id = new_value.to_string();
30410        self
30411    }
30412    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30413    /// while executing the actual API request.
30414    /// 
30415    /// It should be used to handle progress information, and to implement a certain level of resilience.
30416    ///
30417    /// Sets the *delegate* property to the given value.
30418    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ResourceCalendarDeleteCall<'a, C, A> {
30419        self._delegate = Some(new_value);
30420        self
30421    }
30422
30423    /// Set any additional parameter of the query string used in the request.
30424    /// It should be used to set parameters which are not yet available through their own
30425    /// setters.
30426    ///
30427    /// Please note that this method must not be used to set any of the known parameters
30428    /// which have their own setter method. If done anyway, the request will fail.
30429    ///
30430    /// # Additional Parameters
30431    ///
30432    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30433    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30434    /// * *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.
30435    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30436    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30437    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30438    /// * *alt* (query-string) - Data format for the response.
30439    pub fn param<T>(mut self, name: T, value: T) -> ResourceCalendarDeleteCall<'a, C, A>
30440                                                        where T: AsRef<str> {
30441        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
30442        self
30443    }
30444
30445    /// Identifies the authorization scope for the method you are building.
30446    ///
30447    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
30448    /// `Scope::DirectoryResourceCalendar`.
30449    ///
30450    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30451    /// tokens for more than one scope.
30452    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
30453    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
30454    /// function for details).
30455    ///
30456    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30457    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30458    /// sufficient, a read-write scope will do as well.
30459    pub fn add_scope<T, S>(mut self, scope: T) -> ResourceCalendarDeleteCall<'a, C, A>
30460                                                        where T: Into<Option<S>>,
30461                                                              S: AsRef<str> {
30462        match scope.into() {
30463          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
30464          None => None,
30465        };
30466        self
30467    }
30468}
30469
30470
30471/// Undelete a deleted user
30472///
30473/// A builder for the *undelete* method supported by a *user* resource.
30474/// It is not used directly, but through a `UserMethods` instance.
30475///
30476/// # Example
30477///
30478/// Instantiate a resource method builder
30479///
30480/// ```test_harness,no_run
30481/// # extern crate hyper;
30482/// # extern crate hyper_rustls;
30483/// # extern crate yup_oauth2 as oauth2;
30484/// # extern crate google_admin1_directory as admin1_directory;
30485/// use admin1_directory::UserUndelete;
30486/// # #[test] fn egal() {
30487/// # use std::default::Default;
30488/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
30489/// # use admin1_directory::Directory;
30490/// 
30491/// # let secret: ApplicationSecret = Default::default();
30492/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
30493/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
30494/// #                               <MemoryStorage as Default>::default(), None);
30495/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
30496/// // As the method needs a request, you would usually fill it with the desired information
30497/// // into the respective structure. Some of the parts shown here might not be applicable !
30498/// // Values shown here are possibly random and not representative !
30499/// let mut req = UserUndelete::default();
30500/// 
30501/// // You can configure optional parameters by calling the respective setters at will, and
30502/// // execute the final call using `doit()`.
30503/// // Values shown here are possibly random and not representative !
30504/// let result = hub.users().undelete(req, "userKey")
30505///              .doit();
30506/// # }
30507/// ```
30508pub struct UserUndeleteCall<'a, C, A>
30509    where C: 'a, A: 'a {
30510
30511    hub: &'a Directory<C, A>,
30512    _request: UserUndelete,
30513    _user_key: String,
30514    _delegate: Option<&'a mut dyn Delegate>,
30515    _additional_params: HashMap<String, String>,
30516    _scopes: BTreeMap<String, ()>
30517}
30518
30519impl<'a, C, A> CallBuilder for UserUndeleteCall<'a, C, A> {}
30520
30521impl<'a, C, A> UserUndeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
30522
30523
30524    /// Perform the operation you have build so far.
30525    pub fn doit(mut self) -> Result<hyper::client::Response> {
30526        use std::io::{Read, Seek};
30527        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
30528        let mut dd = DefaultDelegate;
30529        let mut dlg: &mut dyn Delegate = match self._delegate {
30530            Some(d) => d,
30531            None => &mut dd
30532        };
30533        dlg.begin(MethodInfo { id: "directory.users.undelete",
30534                               http_method: hyper::method::Method::Post });
30535        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
30536        params.push(("userKey", self._user_key.to_string()));
30537        for &field in ["userKey"].iter() {
30538            if self._additional_params.contains_key(field) {
30539                dlg.finished(false);
30540                return Err(Error::FieldClash(field));
30541            }
30542        }
30543        for (name, value) in self._additional_params.iter() {
30544            params.push((&name, value.clone()));
30545        }
30546
30547
30548        let mut url = self.hub._base_url.clone() + "users/{userKey}/undelete";
30549        if self._scopes.len() == 0 {
30550            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
30551        }
30552
30553        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
30554            let mut replace_with: Option<&str> = None;
30555            for &(name, ref value) in params.iter() {
30556                if name == param_name {
30557                    replace_with = Some(value);
30558                    break;
30559                }
30560            }
30561            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
30562        }
30563        {
30564            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
30565            for param_name in ["userKey"].iter() {
30566                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
30567                    indices_for_removal.push(index);
30568                }
30569            }
30570            for &index in indices_for_removal.iter() {
30571                params.remove(index);
30572            }
30573        }
30574
30575        let url = hyper::Url::parse_with_params(&url, params).unwrap();
30576
30577        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
30578        let mut request_value_reader =
30579            {
30580                let mut value = json::value::to_value(&self._request).expect("serde to work");
30581                remove_json_null_values(&mut value);
30582                let mut dst = io::Cursor::new(Vec::with_capacity(128));
30583                json::to_writer(&mut dst, &value).unwrap();
30584                dst
30585            };
30586        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
30587        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
30588
30589
30590        loop {
30591            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
30592                Ok(token) => token,
30593                Err(err) => {
30594                    match  dlg.token(&*err) {
30595                        Some(token) => token,
30596                        None => {
30597                            dlg.finished(false);
30598                            return Err(Error::MissingToken(err))
30599                        }
30600                    }
30601                }
30602            };
30603            let auth_header = Authorization(Bearer { token: token.access_token });
30604            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
30605            let mut req_result = {
30606                let mut client = &mut *self.hub.client.borrow_mut();
30607                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
30608                    .header(UserAgent(self.hub._user_agent.clone()))
30609                    .header(auth_header.clone())
30610                    .header(ContentType(json_mime_type.clone()))
30611                    .header(ContentLength(request_size as u64))
30612                    .body(&mut request_value_reader);
30613
30614                dlg.pre_request();
30615                req.send()
30616            };
30617
30618            match req_result {
30619                Err(err) => {
30620                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
30621                        sleep(d);
30622                        continue;
30623                    }
30624                    dlg.finished(false);
30625                    return Err(Error::HttpError(err))
30626                }
30627                Ok(mut res) => {
30628                    if !res.status.is_success() {
30629                        let mut json_err = String::new();
30630                        res.read_to_string(&mut json_err).unwrap();
30631                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
30632                                                              json::from_str(&json_err).ok(),
30633                                                              json::from_str(&json_err).ok()) {
30634                            sleep(d);
30635                            continue;
30636                        }
30637                        dlg.finished(false);
30638                        return match json::from_str::<ErrorResponse>(&json_err){
30639                            Err(_) => Err(Error::Failure(res)),
30640                            Ok(serr) => Err(Error::BadRequest(serr))
30641                        }
30642                    }
30643                    let result_value = res;
30644
30645                    dlg.finished(true);
30646                    return Ok(result_value)
30647                }
30648            }
30649        }
30650    }
30651
30652
30653    ///
30654    /// Sets the *request* property to the given value.
30655    ///
30656    /// Even though the property as already been set when instantiating this call,
30657    /// we provide this method for API completeness.
30658    pub fn request(mut self, new_value: UserUndelete) -> UserUndeleteCall<'a, C, A> {
30659        self._request = new_value;
30660        self
30661    }
30662    /// The immutable id of the user
30663    ///
30664    /// Sets the *user key* path property to the given value.
30665    ///
30666    /// Even though the property as already been set when instantiating this call,
30667    /// we provide this method for API completeness.
30668    pub fn user_key(mut self, new_value: &str) -> UserUndeleteCall<'a, C, A> {
30669        self._user_key = new_value.to_string();
30670        self
30671    }
30672    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30673    /// while executing the actual API request.
30674    /// 
30675    /// It should be used to handle progress information, and to implement a certain level of resilience.
30676    ///
30677    /// Sets the *delegate* property to the given value.
30678    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserUndeleteCall<'a, C, A> {
30679        self._delegate = Some(new_value);
30680        self
30681    }
30682
30683    /// Set any additional parameter of the query string used in the request.
30684    /// It should be used to set parameters which are not yet available through their own
30685    /// setters.
30686    ///
30687    /// Please note that this method must not be used to set any of the known parameters
30688    /// which have their own setter method. If done anyway, the request will fail.
30689    ///
30690    /// # Additional Parameters
30691    ///
30692    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30693    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30694    /// * *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.
30695    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30696    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30697    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30698    /// * *alt* (query-string) - Data format for the response.
30699    pub fn param<T>(mut self, name: T, value: T) -> UserUndeleteCall<'a, C, A>
30700                                                        where T: AsRef<str> {
30701        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
30702        self
30703    }
30704
30705    /// Identifies the authorization scope for the method you are building.
30706    ///
30707    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
30708    /// `Scope::DirectoryUser`.
30709    ///
30710    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30711    /// tokens for more than one scope.
30712    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
30713    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
30714    /// function for details).
30715    ///
30716    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30717    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30718    /// sufficient, a read-write scope will do as well.
30719    pub fn add_scope<T, S>(mut self, scope: T) -> UserUndeleteCall<'a, C, A>
30720                                                        where T: Into<Option<S>>,
30721                                                              S: AsRef<str> {
30722        match scope.into() {
30723          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
30724          None => None,
30725        };
30726        self
30727    }
30728}
30729
30730
30731/// Remove photos for the user
30732///
30733/// A builder for the *photos.delete* method supported by a *user* resource.
30734/// It is not used directly, but through a `UserMethods` instance.
30735///
30736/// # Example
30737///
30738/// Instantiate a resource method builder
30739///
30740/// ```test_harness,no_run
30741/// # extern crate hyper;
30742/// # extern crate hyper_rustls;
30743/// # extern crate yup_oauth2 as oauth2;
30744/// # extern crate google_admin1_directory as admin1_directory;
30745/// # #[test] fn egal() {
30746/// # use std::default::Default;
30747/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
30748/// # use admin1_directory::Directory;
30749/// 
30750/// # let secret: ApplicationSecret = Default::default();
30751/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
30752/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
30753/// #                               <MemoryStorage as Default>::default(), None);
30754/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
30755/// // You can configure optional parameters by calling the respective setters at will, and
30756/// // execute the final call using `doit()`.
30757/// // Values shown here are possibly random and not representative !
30758/// let result = hub.users().photos_delete("userKey")
30759///              .doit();
30760/// # }
30761/// ```
30762pub struct UserPhotoDeleteCall<'a, C, A>
30763    where C: 'a, A: 'a {
30764
30765    hub: &'a Directory<C, A>,
30766    _user_key: String,
30767    _delegate: Option<&'a mut dyn Delegate>,
30768    _additional_params: HashMap<String, String>,
30769    _scopes: BTreeMap<String, ()>
30770}
30771
30772impl<'a, C, A> CallBuilder for UserPhotoDeleteCall<'a, C, A> {}
30773
30774impl<'a, C, A> UserPhotoDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
30775
30776
30777    /// Perform the operation you have build so far.
30778    pub fn doit(mut self) -> Result<hyper::client::Response> {
30779        use std::io::{Read, Seek};
30780        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
30781        let mut dd = DefaultDelegate;
30782        let mut dlg: &mut dyn Delegate = match self._delegate {
30783            Some(d) => d,
30784            None => &mut dd
30785        };
30786        dlg.begin(MethodInfo { id: "directory.users.photos.delete",
30787                               http_method: hyper::method::Method::Delete });
30788        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
30789        params.push(("userKey", self._user_key.to_string()));
30790        for &field in ["userKey"].iter() {
30791            if self._additional_params.contains_key(field) {
30792                dlg.finished(false);
30793                return Err(Error::FieldClash(field));
30794            }
30795        }
30796        for (name, value) in self._additional_params.iter() {
30797            params.push((&name, value.clone()));
30798        }
30799
30800
30801        let mut url = self.hub._base_url.clone() + "users/{userKey}/photos/thumbnail";
30802        if self._scopes.len() == 0 {
30803            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
30804        }
30805
30806        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
30807            let mut replace_with: Option<&str> = None;
30808            for &(name, ref value) in params.iter() {
30809                if name == param_name {
30810                    replace_with = Some(value);
30811                    break;
30812                }
30813            }
30814            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
30815        }
30816        {
30817            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
30818            for param_name in ["userKey"].iter() {
30819                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
30820                    indices_for_removal.push(index);
30821                }
30822            }
30823            for &index in indices_for_removal.iter() {
30824                params.remove(index);
30825            }
30826        }
30827
30828        let url = hyper::Url::parse_with_params(&url, params).unwrap();
30829
30830
30831
30832        loop {
30833            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
30834                Ok(token) => token,
30835                Err(err) => {
30836                    match  dlg.token(&*err) {
30837                        Some(token) => token,
30838                        None => {
30839                            dlg.finished(false);
30840                            return Err(Error::MissingToken(err))
30841                        }
30842                    }
30843                }
30844            };
30845            let auth_header = Authorization(Bearer { token: token.access_token });
30846            let mut req_result = {
30847                let mut client = &mut *self.hub.client.borrow_mut();
30848                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
30849                    .header(UserAgent(self.hub._user_agent.clone()))
30850                    .header(auth_header.clone());
30851
30852                dlg.pre_request();
30853                req.send()
30854            };
30855
30856            match req_result {
30857                Err(err) => {
30858                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
30859                        sleep(d);
30860                        continue;
30861                    }
30862                    dlg.finished(false);
30863                    return Err(Error::HttpError(err))
30864                }
30865                Ok(mut res) => {
30866                    if !res.status.is_success() {
30867                        let mut json_err = String::new();
30868                        res.read_to_string(&mut json_err).unwrap();
30869                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
30870                                                              json::from_str(&json_err).ok(),
30871                                                              json::from_str(&json_err).ok()) {
30872                            sleep(d);
30873                            continue;
30874                        }
30875                        dlg.finished(false);
30876                        return match json::from_str::<ErrorResponse>(&json_err){
30877                            Err(_) => Err(Error::Failure(res)),
30878                            Ok(serr) => Err(Error::BadRequest(serr))
30879                        }
30880                    }
30881                    let result_value = res;
30882
30883                    dlg.finished(true);
30884                    return Ok(result_value)
30885                }
30886            }
30887        }
30888    }
30889
30890
30891    /// Email or immutable ID of the user
30892    ///
30893    /// Sets the *user key* path property to the given value.
30894    ///
30895    /// Even though the property as already been set when instantiating this call,
30896    /// we provide this method for API completeness.
30897    pub fn user_key(mut self, new_value: &str) -> UserPhotoDeleteCall<'a, C, A> {
30898        self._user_key = new_value.to_string();
30899        self
30900    }
30901    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30902    /// while executing the actual API request.
30903    /// 
30904    /// It should be used to handle progress information, and to implement a certain level of resilience.
30905    ///
30906    /// Sets the *delegate* property to the given value.
30907    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserPhotoDeleteCall<'a, C, A> {
30908        self._delegate = Some(new_value);
30909        self
30910    }
30911
30912    /// Set any additional parameter of the query string used in the request.
30913    /// It should be used to set parameters which are not yet available through their own
30914    /// setters.
30915    ///
30916    /// Please note that this method must not be used to set any of the known parameters
30917    /// which have their own setter method. If done anyway, the request will fail.
30918    ///
30919    /// # Additional Parameters
30920    ///
30921    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30922    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30923    /// * *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.
30924    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30925    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30926    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30927    /// * *alt* (query-string) - Data format for the response.
30928    pub fn param<T>(mut self, name: T, value: T) -> UserPhotoDeleteCall<'a, C, A>
30929                                                        where T: AsRef<str> {
30930        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
30931        self
30932    }
30933
30934    /// Identifies the authorization scope for the method you are building.
30935    ///
30936    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
30937    /// `Scope::DirectoryUser`.
30938    ///
30939    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30940    /// tokens for more than one scope.
30941    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
30942    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
30943    /// function for details).
30944    ///
30945    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30946    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30947    /// sufficient, a read-write scope will do as well.
30948    pub fn add_scope<T, S>(mut self, scope: T) -> UserPhotoDeleteCall<'a, C, A>
30949                                                        where T: Into<Option<S>>,
30950                                                              S: AsRef<str> {
30951        match scope.into() {
30952          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
30953          None => None,
30954        };
30955        self
30956    }
30957}
30958
30959
30960/// Add a photo for the user. This method supports patch semantics.
30961///
30962/// A builder for the *photos.patch* method supported by a *user* resource.
30963/// It is not used directly, but through a `UserMethods` instance.
30964///
30965/// # Example
30966///
30967/// Instantiate a resource method builder
30968///
30969/// ```test_harness,no_run
30970/// # extern crate hyper;
30971/// # extern crate hyper_rustls;
30972/// # extern crate yup_oauth2 as oauth2;
30973/// # extern crate google_admin1_directory as admin1_directory;
30974/// use admin1_directory::UserPhoto;
30975/// # #[test] fn egal() {
30976/// # use std::default::Default;
30977/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
30978/// # use admin1_directory::Directory;
30979/// 
30980/// # let secret: ApplicationSecret = Default::default();
30981/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
30982/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
30983/// #                               <MemoryStorage as Default>::default(), None);
30984/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
30985/// // As the method needs a request, you would usually fill it with the desired information
30986/// // into the respective structure. Some of the parts shown here might not be applicable !
30987/// // Values shown here are possibly random and not representative !
30988/// let mut req = UserPhoto::default();
30989/// 
30990/// // You can configure optional parameters by calling the respective setters at will, and
30991/// // execute the final call using `doit()`.
30992/// // Values shown here are possibly random and not representative !
30993/// let result = hub.users().photos_patch(req, "userKey")
30994///              .doit();
30995/// # }
30996/// ```
30997pub struct UserPhotoPatchCall<'a, C, A>
30998    where C: 'a, A: 'a {
30999
31000    hub: &'a Directory<C, A>,
31001    _request: UserPhoto,
31002    _user_key: String,
31003    _delegate: Option<&'a mut dyn Delegate>,
31004    _additional_params: HashMap<String, String>,
31005    _scopes: BTreeMap<String, ()>
31006}
31007
31008impl<'a, C, A> CallBuilder for UserPhotoPatchCall<'a, C, A> {}
31009
31010impl<'a, C, A> UserPhotoPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
31011
31012
31013    /// Perform the operation you have build so far.
31014    pub fn doit(mut self) -> Result<(hyper::client::Response, UserPhoto)> {
31015        use std::io::{Read, Seek};
31016        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
31017        let mut dd = DefaultDelegate;
31018        let mut dlg: &mut dyn Delegate = match self._delegate {
31019            Some(d) => d,
31020            None => &mut dd
31021        };
31022        dlg.begin(MethodInfo { id: "directory.users.photos.patch",
31023                               http_method: hyper::method::Method::Patch });
31024        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
31025        params.push(("userKey", self._user_key.to_string()));
31026        for &field in ["alt", "userKey"].iter() {
31027            if self._additional_params.contains_key(field) {
31028                dlg.finished(false);
31029                return Err(Error::FieldClash(field));
31030            }
31031        }
31032        for (name, value) in self._additional_params.iter() {
31033            params.push((&name, value.clone()));
31034        }
31035
31036        params.push(("alt", "json".to_string()));
31037
31038        let mut url = self.hub._base_url.clone() + "users/{userKey}/photos/thumbnail";
31039        if self._scopes.len() == 0 {
31040            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
31041        }
31042
31043        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
31044            let mut replace_with: Option<&str> = None;
31045            for &(name, ref value) in params.iter() {
31046                if name == param_name {
31047                    replace_with = Some(value);
31048                    break;
31049                }
31050            }
31051            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
31052        }
31053        {
31054            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
31055            for param_name in ["userKey"].iter() {
31056                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
31057                    indices_for_removal.push(index);
31058                }
31059            }
31060            for &index in indices_for_removal.iter() {
31061                params.remove(index);
31062            }
31063        }
31064
31065        let url = hyper::Url::parse_with_params(&url, params).unwrap();
31066
31067        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
31068        let mut request_value_reader =
31069            {
31070                let mut value = json::value::to_value(&self._request).expect("serde to work");
31071                remove_json_null_values(&mut value);
31072                let mut dst = io::Cursor::new(Vec::with_capacity(128));
31073                json::to_writer(&mut dst, &value).unwrap();
31074                dst
31075            };
31076        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
31077        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31078
31079
31080        loop {
31081            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
31082                Ok(token) => token,
31083                Err(err) => {
31084                    match  dlg.token(&*err) {
31085                        Some(token) => token,
31086                        None => {
31087                            dlg.finished(false);
31088                            return Err(Error::MissingToken(err))
31089                        }
31090                    }
31091                }
31092            };
31093            let auth_header = Authorization(Bearer { token: token.access_token });
31094            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31095            let mut req_result = {
31096                let mut client = &mut *self.hub.client.borrow_mut();
31097                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
31098                    .header(UserAgent(self.hub._user_agent.clone()))
31099                    .header(auth_header.clone())
31100                    .header(ContentType(json_mime_type.clone()))
31101                    .header(ContentLength(request_size as u64))
31102                    .body(&mut request_value_reader);
31103
31104                dlg.pre_request();
31105                req.send()
31106            };
31107
31108            match req_result {
31109                Err(err) => {
31110                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
31111                        sleep(d);
31112                        continue;
31113                    }
31114                    dlg.finished(false);
31115                    return Err(Error::HttpError(err))
31116                }
31117                Ok(mut res) => {
31118                    if !res.status.is_success() {
31119                        let mut json_err = String::new();
31120                        res.read_to_string(&mut json_err).unwrap();
31121                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
31122                                                              json::from_str(&json_err).ok(),
31123                                                              json::from_str(&json_err).ok()) {
31124                            sleep(d);
31125                            continue;
31126                        }
31127                        dlg.finished(false);
31128                        return match json::from_str::<ErrorResponse>(&json_err){
31129                            Err(_) => Err(Error::Failure(res)),
31130                            Ok(serr) => Err(Error::BadRequest(serr))
31131                        }
31132                    }
31133                    let result_value = {
31134                        let mut json_response = String::new();
31135                        res.read_to_string(&mut json_response).unwrap();
31136                        match json::from_str(&json_response) {
31137                            Ok(decoded) => (res, decoded),
31138                            Err(err) => {
31139                                dlg.response_json_decode_error(&json_response, &err);
31140                                return Err(Error::JsonDecodeError(json_response, err));
31141                            }
31142                        }
31143                    };
31144
31145                    dlg.finished(true);
31146                    return Ok(result_value)
31147                }
31148            }
31149        }
31150    }
31151
31152
31153    ///
31154    /// Sets the *request* property to the given value.
31155    ///
31156    /// Even though the property as already been set when instantiating this call,
31157    /// we provide this method for API completeness.
31158    pub fn request(mut self, new_value: UserPhoto) -> UserPhotoPatchCall<'a, C, A> {
31159        self._request = new_value;
31160        self
31161    }
31162    /// Email or immutable ID of the user
31163    ///
31164    /// Sets the *user key* path property to the given value.
31165    ///
31166    /// Even though the property as already been set when instantiating this call,
31167    /// we provide this method for API completeness.
31168    pub fn user_key(mut self, new_value: &str) -> UserPhotoPatchCall<'a, C, A> {
31169        self._user_key = new_value.to_string();
31170        self
31171    }
31172    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31173    /// while executing the actual API request.
31174    /// 
31175    /// It should be used to handle progress information, and to implement a certain level of resilience.
31176    ///
31177    /// Sets the *delegate* property to the given value.
31178    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserPhotoPatchCall<'a, C, A> {
31179        self._delegate = Some(new_value);
31180        self
31181    }
31182
31183    /// Set any additional parameter of the query string used in the request.
31184    /// It should be used to set parameters which are not yet available through their own
31185    /// setters.
31186    ///
31187    /// Please note that this method must not be used to set any of the known parameters
31188    /// which have their own setter method. If done anyway, the request will fail.
31189    ///
31190    /// # Additional Parameters
31191    ///
31192    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31193    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31194    /// * *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.
31195    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31196    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31197    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31198    /// * *alt* (query-string) - Data format for the response.
31199    pub fn param<T>(mut self, name: T, value: T) -> UserPhotoPatchCall<'a, C, A>
31200                                                        where T: AsRef<str> {
31201        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
31202        self
31203    }
31204
31205    /// Identifies the authorization scope for the method you are building.
31206    ///
31207    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
31208    /// `Scope::DirectoryUser`.
31209    ///
31210    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31211    /// tokens for more than one scope.
31212    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
31213    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
31214    /// function for details).
31215    ///
31216    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31217    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31218    /// sufficient, a read-write scope will do as well.
31219    pub fn add_scope<T, S>(mut self, scope: T) -> UserPhotoPatchCall<'a, C, A>
31220                                                        where T: Into<Option<S>>,
31221                                                              S: AsRef<str> {
31222        match scope.into() {
31223          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
31224          None => None,
31225        };
31226        self
31227    }
31228}
31229
31230
31231/// create user.
31232///
31233/// A builder for the *insert* method supported by a *user* resource.
31234/// It is not used directly, but through a `UserMethods` instance.
31235///
31236/// # Example
31237///
31238/// Instantiate a resource method builder
31239///
31240/// ```test_harness,no_run
31241/// # extern crate hyper;
31242/// # extern crate hyper_rustls;
31243/// # extern crate yup_oauth2 as oauth2;
31244/// # extern crate google_admin1_directory as admin1_directory;
31245/// use admin1_directory::User;
31246/// # #[test] fn egal() {
31247/// # use std::default::Default;
31248/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
31249/// # use admin1_directory::Directory;
31250/// 
31251/// # let secret: ApplicationSecret = Default::default();
31252/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
31253/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
31254/// #                               <MemoryStorage as Default>::default(), None);
31255/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
31256/// // As the method needs a request, you would usually fill it with the desired information
31257/// // into the respective structure. Some of the parts shown here might not be applicable !
31258/// // Values shown here are possibly random and not representative !
31259/// let mut req = User::default();
31260/// 
31261/// // You can configure optional parameters by calling the respective setters at will, and
31262/// // execute the final call using `doit()`.
31263/// // Values shown here are possibly random and not representative !
31264/// let result = hub.users().insert(req)
31265///              .doit();
31266/// # }
31267/// ```
31268pub struct UserInsertCall<'a, C, A>
31269    where C: 'a, A: 'a {
31270
31271    hub: &'a Directory<C, A>,
31272    _request: User,
31273    _delegate: Option<&'a mut dyn Delegate>,
31274    _additional_params: HashMap<String, String>,
31275    _scopes: BTreeMap<String, ()>
31276}
31277
31278impl<'a, C, A> CallBuilder for UserInsertCall<'a, C, A> {}
31279
31280impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
31281
31282
31283    /// Perform the operation you have build so far.
31284    pub fn doit(mut self) -> Result<(hyper::client::Response, User)> {
31285        use std::io::{Read, Seek};
31286        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
31287        let mut dd = DefaultDelegate;
31288        let mut dlg: &mut dyn Delegate = match self._delegate {
31289            Some(d) => d,
31290            None => &mut dd
31291        };
31292        dlg.begin(MethodInfo { id: "directory.users.insert",
31293                               http_method: hyper::method::Method::Post });
31294        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
31295        for &field in ["alt"].iter() {
31296            if self._additional_params.contains_key(field) {
31297                dlg.finished(false);
31298                return Err(Error::FieldClash(field));
31299            }
31300        }
31301        for (name, value) in self._additional_params.iter() {
31302            params.push((&name, value.clone()));
31303        }
31304
31305        params.push(("alt", "json".to_string()));
31306
31307        let mut url = self.hub._base_url.clone() + "users";
31308        if self._scopes.len() == 0 {
31309            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
31310        }
31311
31312
31313        let url = hyper::Url::parse_with_params(&url, params).unwrap();
31314
31315        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
31316        let mut request_value_reader =
31317            {
31318                let mut value = json::value::to_value(&self._request).expect("serde to work");
31319                remove_json_null_values(&mut value);
31320                let mut dst = io::Cursor::new(Vec::with_capacity(128));
31321                json::to_writer(&mut dst, &value).unwrap();
31322                dst
31323            };
31324        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
31325        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31326
31327
31328        loop {
31329            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
31330                Ok(token) => token,
31331                Err(err) => {
31332                    match  dlg.token(&*err) {
31333                        Some(token) => token,
31334                        None => {
31335                            dlg.finished(false);
31336                            return Err(Error::MissingToken(err))
31337                        }
31338                    }
31339                }
31340            };
31341            let auth_header = Authorization(Bearer { token: token.access_token });
31342            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31343            let mut req_result = {
31344                let mut client = &mut *self.hub.client.borrow_mut();
31345                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
31346                    .header(UserAgent(self.hub._user_agent.clone()))
31347                    .header(auth_header.clone())
31348                    .header(ContentType(json_mime_type.clone()))
31349                    .header(ContentLength(request_size as u64))
31350                    .body(&mut request_value_reader);
31351
31352                dlg.pre_request();
31353                req.send()
31354            };
31355
31356            match req_result {
31357                Err(err) => {
31358                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
31359                        sleep(d);
31360                        continue;
31361                    }
31362                    dlg.finished(false);
31363                    return Err(Error::HttpError(err))
31364                }
31365                Ok(mut res) => {
31366                    if !res.status.is_success() {
31367                        let mut json_err = String::new();
31368                        res.read_to_string(&mut json_err).unwrap();
31369                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
31370                                                              json::from_str(&json_err).ok(),
31371                                                              json::from_str(&json_err).ok()) {
31372                            sleep(d);
31373                            continue;
31374                        }
31375                        dlg.finished(false);
31376                        return match json::from_str::<ErrorResponse>(&json_err){
31377                            Err(_) => Err(Error::Failure(res)),
31378                            Ok(serr) => Err(Error::BadRequest(serr))
31379                        }
31380                    }
31381                    let result_value = {
31382                        let mut json_response = String::new();
31383                        res.read_to_string(&mut json_response).unwrap();
31384                        match json::from_str(&json_response) {
31385                            Ok(decoded) => (res, decoded),
31386                            Err(err) => {
31387                                dlg.response_json_decode_error(&json_response, &err);
31388                                return Err(Error::JsonDecodeError(json_response, err));
31389                            }
31390                        }
31391                    };
31392
31393                    dlg.finished(true);
31394                    return Ok(result_value)
31395                }
31396            }
31397        }
31398    }
31399
31400
31401    ///
31402    /// Sets the *request* property to the given value.
31403    ///
31404    /// Even though the property as already been set when instantiating this call,
31405    /// we provide this method for API completeness.
31406    pub fn request(mut self, new_value: User) -> UserInsertCall<'a, C, A> {
31407        self._request = new_value;
31408        self
31409    }
31410    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31411    /// while executing the actual API request.
31412    /// 
31413    /// It should be used to handle progress information, and to implement a certain level of resilience.
31414    ///
31415    /// Sets the *delegate* property to the given value.
31416    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserInsertCall<'a, C, A> {
31417        self._delegate = Some(new_value);
31418        self
31419    }
31420
31421    /// Set any additional parameter of the query string used in the request.
31422    /// It should be used to set parameters which are not yet available through their own
31423    /// setters.
31424    ///
31425    /// Please note that this method must not be used to set any of the known parameters
31426    /// which have their own setter method. If done anyway, the request will fail.
31427    ///
31428    /// # Additional Parameters
31429    ///
31430    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31431    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31432    /// * *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.
31433    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31434    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31435    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31436    /// * *alt* (query-string) - Data format for the response.
31437    pub fn param<T>(mut self, name: T, value: T) -> UserInsertCall<'a, C, A>
31438                                                        where T: AsRef<str> {
31439        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
31440        self
31441    }
31442
31443    /// Identifies the authorization scope for the method you are building.
31444    ///
31445    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
31446    /// `Scope::DirectoryUser`.
31447    ///
31448    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31449    /// tokens for more than one scope.
31450    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
31451    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
31452    /// function for details).
31453    ///
31454    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31455    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31456    /// sufficient, a read-write scope will do as well.
31457    pub fn add_scope<T, S>(mut self, scope: T) -> UserInsertCall<'a, C, A>
31458                                                        where T: Into<Option<S>>,
31459                                                              S: AsRef<str> {
31460        match scope.into() {
31461          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
31462          None => None,
31463        };
31464        self
31465    }
31466}
31467
31468
31469/// Watch for changes in user aliases list
31470///
31471/// A builder for the *aliases.watch* method supported by a *user* resource.
31472/// It is not used directly, but through a `UserMethods` instance.
31473///
31474/// # Example
31475///
31476/// Instantiate a resource method builder
31477///
31478/// ```test_harness,no_run
31479/// # extern crate hyper;
31480/// # extern crate hyper_rustls;
31481/// # extern crate yup_oauth2 as oauth2;
31482/// # extern crate google_admin1_directory as admin1_directory;
31483/// use admin1_directory::Channel;
31484/// # #[test] fn egal() {
31485/// # use std::default::Default;
31486/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
31487/// # use admin1_directory::Directory;
31488/// 
31489/// # let secret: ApplicationSecret = Default::default();
31490/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
31491/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
31492/// #                               <MemoryStorage as Default>::default(), None);
31493/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
31494/// // As the method needs a request, you would usually fill it with the desired information
31495/// // into the respective structure. Some of the parts shown here might not be applicable !
31496/// // Values shown here are possibly random and not representative !
31497/// let mut req = Channel::default();
31498/// 
31499/// // You can configure optional parameters by calling the respective setters at will, and
31500/// // execute the final call using `doit()`.
31501/// // Values shown here are possibly random and not representative !
31502/// let result = hub.users().aliases_watch(req, "userKey")
31503///              .event("eos")
31504///              .doit();
31505/// # }
31506/// ```
31507pub struct UserAliaseWatchCall<'a, C, A>
31508    where C: 'a, A: 'a {
31509
31510    hub: &'a Directory<C, A>,
31511    _request: Channel,
31512    _user_key: String,
31513    _event: Option<String>,
31514    _delegate: Option<&'a mut dyn Delegate>,
31515    _additional_params: HashMap<String, String>,
31516    _scopes: BTreeMap<String, ()>
31517}
31518
31519impl<'a, C, A> CallBuilder for UserAliaseWatchCall<'a, C, A> {}
31520
31521impl<'a, C, A> UserAliaseWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
31522
31523
31524    /// Perform the operation you have build so far.
31525    pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> {
31526        use std::io::{Read, Seek};
31527        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
31528        let mut dd = DefaultDelegate;
31529        let mut dlg: &mut dyn Delegate = match self._delegate {
31530            Some(d) => d,
31531            None => &mut dd
31532        };
31533        dlg.begin(MethodInfo { id: "directory.users.aliases.watch",
31534                               http_method: hyper::method::Method::Post });
31535        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
31536        params.push(("userKey", self._user_key.to_string()));
31537        if let Some(value) = self._event {
31538            params.push(("event", value.to_string()));
31539        }
31540        for &field in ["alt", "userKey", "event"].iter() {
31541            if self._additional_params.contains_key(field) {
31542                dlg.finished(false);
31543                return Err(Error::FieldClash(field));
31544            }
31545        }
31546        for (name, value) in self._additional_params.iter() {
31547            params.push((&name, value.clone()));
31548        }
31549
31550        params.push(("alt", "json".to_string()));
31551
31552        let mut url = self.hub._base_url.clone() + "users/{userKey}/aliases/watch";
31553        if self._scopes.len() == 0 {
31554            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
31555        }
31556
31557        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
31558            let mut replace_with: Option<&str> = None;
31559            for &(name, ref value) in params.iter() {
31560                if name == param_name {
31561                    replace_with = Some(value);
31562                    break;
31563                }
31564            }
31565            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
31566        }
31567        {
31568            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
31569            for param_name in ["userKey"].iter() {
31570                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
31571                    indices_for_removal.push(index);
31572                }
31573            }
31574            for &index in indices_for_removal.iter() {
31575                params.remove(index);
31576            }
31577        }
31578
31579        let url = hyper::Url::parse_with_params(&url, params).unwrap();
31580
31581        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
31582        let mut request_value_reader =
31583            {
31584                let mut value = json::value::to_value(&self._request).expect("serde to work");
31585                remove_json_null_values(&mut value);
31586                let mut dst = io::Cursor::new(Vec::with_capacity(128));
31587                json::to_writer(&mut dst, &value).unwrap();
31588                dst
31589            };
31590        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
31591        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31592
31593
31594        loop {
31595            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
31596                Ok(token) => token,
31597                Err(err) => {
31598                    match  dlg.token(&*err) {
31599                        Some(token) => token,
31600                        None => {
31601                            dlg.finished(false);
31602                            return Err(Error::MissingToken(err))
31603                        }
31604                    }
31605                }
31606            };
31607            let auth_header = Authorization(Bearer { token: token.access_token });
31608            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31609            let mut req_result = {
31610                let mut client = &mut *self.hub.client.borrow_mut();
31611                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
31612                    .header(UserAgent(self.hub._user_agent.clone()))
31613                    .header(auth_header.clone())
31614                    .header(ContentType(json_mime_type.clone()))
31615                    .header(ContentLength(request_size as u64))
31616                    .body(&mut request_value_reader);
31617
31618                dlg.pre_request();
31619                req.send()
31620            };
31621
31622            match req_result {
31623                Err(err) => {
31624                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
31625                        sleep(d);
31626                        continue;
31627                    }
31628                    dlg.finished(false);
31629                    return Err(Error::HttpError(err))
31630                }
31631                Ok(mut res) => {
31632                    if !res.status.is_success() {
31633                        let mut json_err = String::new();
31634                        res.read_to_string(&mut json_err).unwrap();
31635                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
31636                                                              json::from_str(&json_err).ok(),
31637                                                              json::from_str(&json_err).ok()) {
31638                            sleep(d);
31639                            continue;
31640                        }
31641                        dlg.finished(false);
31642                        return match json::from_str::<ErrorResponse>(&json_err){
31643                            Err(_) => Err(Error::Failure(res)),
31644                            Ok(serr) => Err(Error::BadRequest(serr))
31645                        }
31646                    }
31647                    let result_value = {
31648                        let mut json_response = String::new();
31649                        res.read_to_string(&mut json_response).unwrap();
31650                        match json::from_str(&json_response) {
31651                            Ok(decoded) => (res, decoded),
31652                            Err(err) => {
31653                                dlg.response_json_decode_error(&json_response, &err);
31654                                return Err(Error::JsonDecodeError(json_response, err));
31655                            }
31656                        }
31657                    };
31658
31659                    dlg.finished(true);
31660                    return Ok(result_value)
31661                }
31662            }
31663        }
31664    }
31665
31666
31667    ///
31668    /// Sets the *request* property to the given value.
31669    ///
31670    /// Even though the property as already been set when instantiating this call,
31671    /// we provide this method for API completeness.
31672    pub fn request(mut self, new_value: Channel) -> UserAliaseWatchCall<'a, C, A> {
31673        self._request = new_value;
31674        self
31675    }
31676    /// Email or immutable ID of the user
31677    ///
31678    /// Sets the *user key* path property to the given value.
31679    ///
31680    /// Even though the property as already been set when instantiating this call,
31681    /// we provide this method for API completeness.
31682    pub fn user_key(mut self, new_value: &str) -> UserAliaseWatchCall<'a, C, A> {
31683        self._user_key = new_value.to_string();
31684        self
31685    }
31686    /// Event on which subscription is intended (if subscribing)
31687    ///
31688    /// Sets the *event* query property to the given value.
31689    pub fn event(mut self, new_value: &str) -> UserAliaseWatchCall<'a, C, A> {
31690        self._event = Some(new_value.to_string());
31691        self
31692    }
31693    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31694    /// while executing the actual API request.
31695    /// 
31696    /// It should be used to handle progress information, and to implement a certain level of resilience.
31697    ///
31698    /// Sets the *delegate* property to the given value.
31699    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserAliaseWatchCall<'a, C, A> {
31700        self._delegate = Some(new_value);
31701        self
31702    }
31703
31704    /// Set any additional parameter of the query string used in the request.
31705    /// It should be used to set parameters which are not yet available through their own
31706    /// setters.
31707    ///
31708    /// Please note that this method must not be used to set any of the known parameters
31709    /// which have their own setter method. If done anyway, the request will fail.
31710    ///
31711    /// # Additional Parameters
31712    ///
31713    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31714    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31715    /// * *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.
31716    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31717    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31718    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31719    /// * *alt* (query-string) - Data format for the response.
31720    pub fn param<T>(mut self, name: T, value: T) -> UserAliaseWatchCall<'a, C, A>
31721                                                        where T: AsRef<str> {
31722        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
31723        self
31724    }
31725
31726    /// Identifies the authorization scope for the method you are building.
31727    ///
31728    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
31729    /// `Scope::DirectoryUser`.
31730    ///
31731    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31732    /// tokens for more than one scope.
31733    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
31734    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
31735    /// function for details).
31736    ///
31737    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31738    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31739    /// sufficient, a read-write scope will do as well.
31740    pub fn add_scope<T, S>(mut self, scope: T) -> UserAliaseWatchCall<'a, C, A>
31741                                                        where T: Into<Option<S>>,
31742                                                              S: AsRef<str> {
31743        match scope.into() {
31744          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
31745          None => None,
31746        };
31747        self
31748    }
31749}
31750
31751
31752/// Add a photo for the user
31753///
31754/// A builder for the *photos.update* method supported by a *user* resource.
31755/// It is not used directly, but through a `UserMethods` instance.
31756///
31757/// # Example
31758///
31759/// Instantiate a resource method builder
31760///
31761/// ```test_harness,no_run
31762/// # extern crate hyper;
31763/// # extern crate hyper_rustls;
31764/// # extern crate yup_oauth2 as oauth2;
31765/// # extern crate google_admin1_directory as admin1_directory;
31766/// use admin1_directory::UserPhoto;
31767/// # #[test] fn egal() {
31768/// # use std::default::Default;
31769/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
31770/// # use admin1_directory::Directory;
31771/// 
31772/// # let secret: ApplicationSecret = Default::default();
31773/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
31774/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
31775/// #                               <MemoryStorage as Default>::default(), None);
31776/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
31777/// // As the method needs a request, you would usually fill it with the desired information
31778/// // into the respective structure. Some of the parts shown here might not be applicable !
31779/// // Values shown here are possibly random and not representative !
31780/// let mut req = UserPhoto::default();
31781/// 
31782/// // You can configure optional parameters by calling the respective setters at will, and
31783/// // execute the final call using `doit()`.
31784/// // Values shown here are possibly random and not representative !
31785/// let result = hub.users().photos_update(req, "userKey")
31786///              .doit();
31787/// # }
31788/// ```
31789pub struct UserPhotoUpdateCall<'a, C, A>
31790    where C: 'a, A: 'a {
31791
31792    hub: &'a Directory<C, A>,
31793    _request: UserPhoto,
31794    _user_key: String,
31795    _delegate: Option<&'a mut dyn Delegate>,
31796    _additional_params: HashMap<String, String>,
31797    _scopes: BTreeMap<String, ()>
31798}
31799
31800impl<'a, C, A> CallBuilder for UserPhotoUpdateCall<'a, C, A> {}
31801
31802impl<'a, C, A> UserPhotoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
31803
31804
31805    /// Perform the operation you have build so far.
31806    pub fn doit(mut self) -> Result<(hyper::client::Response, UserPhoto)> {
31807        use std::io::{Read, Seek};
31808        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
31809        let mut dd = DefaultDelegate;
31810        let mut dlg: &mut dyn Delegate = match self._delegate {
31811            Some(d) => d,
31812            None => &mut dd
31813        };
31814        dlg.begin(MethodInfo { id: "directory.users.photos.update",
31815                               http_method: hyper::method::Method::Put });
31816        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
31817        params.push(("userKey", self._user_key.to_string()));
31818        for &field in ["alt", "userKey"].iter() {
31819            if self._additional_params.contains_key(field) {
31820                dlg.finished(false);
31821                return Err(Error::FieldClash(field));
31822            }
31823        }
31824        for (name, value) in self._additional_params.iter() {
31825            params.push((&name, value.clone()));
31826        }
31827
31828        params.push(("alt", "json".to_string()));
31829
31830        let mut url = self.hub._base_url.clone() + "users/{userKey}/photos/thumbnail";
31831        if self._scopes.len() == 0 {
31832            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
31833        }
31834
31835        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
31836            let mut replace_with: Option<&str> = None;
31837            for &(name, ref value) in params.iter() {
31838                if name == param_name {
31839                    replace_with = Some(value);
31840                    break;
31841                }
31842            }
31843            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
31844        }
31845        {
31846            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
31847            for param_name in ["userKey"].iter() {
31848                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
31849                    indices_for_removal.push(index);
31850                }
31851            }
31852            for &index in indices_for_removal.iter() {
31853                params.remove(index);
31854            }
31855        }
31856
31857        let url = hyper::Url::parse_with_params(&url, params).unwrap();
31858
31859        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
31860        let mut request_value_reader =
31861            {
31862                let mut value = json::value::to_value(&self._request).expect("serde to work");
31863                remove_json_null_values(&mut value);
31864                let mut dst = io::Cursor::new(Vec::with_capacity(128));
31865                json::to_writer(&mut dst, &value).unwrap();
31866                dst
31867            };
31868        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
31869        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31870
31871
31872        loop {
31873            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
31874                Ok(token) => token,
31875                Err(err) => {
31876                    match  dlg.token(&*err) {
31877                        Some(token) => token,
31878                        None => {
31879                            dlg.finished(false);
31880                            return Err(Error::MissingToken(err))
31881                        }
31882                    }
31883                }
31884            };
31885            let auth_header = Authorization(Bearer { token: token.access_token });
31886            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
31887            let mut req_result = {
31888                let mut client = &mut *self.hub.client.borrow_mut();
31889                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
31890                    .header(UserAgent(self.hub._user_agent.clone()))
31891                    .header(auth_header.clone())
31892                    .header(ContentType(json_mime_type.clone()))
31893                    .header(ContentLength(request_size as u64))
31894                    .body(&mut request_value_reader);
31895
31896                dlg.pre_request();
31897                req.send()
31898            };
31899
31900            match req_result {
31901                Err(err) => {
31902                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
31903                        sleep(d);
31904                        continue;
31905                    }
31906                    dlg.finished(false);
31907                    return Err(Error::HttpError(err))
31908                }
31909                Ok(mut res) => {
31910                    if !res.status.is_success() {
31911                        let mut json_err = String::new();
31912                        res.read_to_string(&mut json_err).unwrap();
31913                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
31914                                                              json::from_str(&json_err).ok(),
31915                                                              json::from_str(&json_err).ok()) {
31916                            sleep(d);
31917                            continue;
31918                        }
31919                        dlg.finished(false);
31920                        return match json::from_str::<ErrorResponse>(&json_err){
31921                            Err(_) => Err(Error::Failure(res)),
31922                            Ok(serr) => Err(Error::BadRequest(serr))
31923                        }
31924                    }
31925                    let result_value = {
31926                        let mut json_response = String::new();
31927                        res.read_to_string(&mut json_response).unwrap();
31928                        match json::from_str(&json_response) {
31929                            Ok(decoded) => (res, decoded),
31930                            Err(err) => {
31931                                dlg.response_json_decode_error(&json_response, &err);
31932                                return Err(Error::JsonDecodeError(json_response, err));
31933                            }
31934                        }
31935                    };
31936
31937                    dlg.finished(true);
31938                    return Ok(result_value)
31939                }
31940            }
31941        }
31942    }
31943
31944
31945    ///
31946    /// Sets the *request* property to the given value.
31947    ///
31948    /// Even though the property as already been set when instantiating this call,
31949    /// we provide this method for API completeness.
31950    pub fn request(mut self, new_value: UserPhoto) -> UserPhotoUpdateCall<'a, C, A> {
31951        self._request = new_value;
31952        self
31953    }
31954    /// Email or immutable ID of the user
31955    ///
31956    /// Sets the *user key* path property to the given value.
31957    ///
31958    /// Even though the property as already been set when instantiating this call,
31959    /// we provide this method for API completeness.
31960    pub fn user_key(mut self, new_value: &str) -> UserPhotoUpdateCall<'a, C, A> {
31961        self._user_key = new_value.to_string();
31962        self
31963    }
31964    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31965    /// while executing the actual API request.
31966    /// 
31967    /// It should be used to handle progress information, and to implement a certain level of resilience.
31968    ///
31969    /// Sets the *delegate* property to the given value.
31970    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserPhotoUpdateCall<'a, C, A> {
31971        self._delegate = Some(new_value);
31972        self
31973    }
31974
31975    /// Set any additional parameter of the query string used in the request.
31976    /// It should be used to set parameters which are not yet available through their own
31977    /// setters.
31978    ///
31979    /// Please note that this method must not be used to set any of the known parameters
31980    /// which have their own setter method. If done anyway, the request will fail.
31981    ///
31982    /// # Additional Parameters
31983    ///
31984    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31985    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31986    /// * *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.
31987    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31988    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31989    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31990    /// * *alt* (query-string) - Data format for the response.
31991    pub fn param<T>(mut self, name: T, value: T) -> UserPhotoUpdateCall<'a, C, A>
31992                                                        where T: AsRef<str> {
31993        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
31994        self
31995    }
31996
31997    /// Identifies the authorization scope for the method you are building.
31998    ///
31999    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
32000    /// `Scope::DirectoryUser`.
32001    ///
32002    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32003    /// tokens for more than one scope.
32004    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
32005    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
32006    /// function for details).
32007    ///
32008    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32009    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32010    /// sufficient, a read-write scope will do as well.
32011    pub fn add_scope<T, S>(mut self, scope: T) -> UserPhotoUpdateCall<'a, C, A>
32012                                                        where T: Into<Option<S>>,
32013                                                              S: AsRef<str> {
32014        match scope.into() {
32015          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
32016          None => None,
32017        };
32018        self
32019    }
32020}
32021
32022
32023/// Watch for changes in users list
32024///
32025/// A builder for the *watch* method supported by a *user* resource.
32026/// It is not used directly, but through a `UserMethods` instance.
32027///
32028/// # Example
32029///
32030/// Instantiate a resource method builder
32031///
32032/// ```test_harness,no_run
32033/// # extern crate hyper;
32034/// # extern crate hyper_rustls;
32035/// # extern crate yup_oauth2 as oauth2;
32036/// # extern crate google_admin1_directory as admin1_directory;
32037/// use admin1_directory::Channel;
32038/// # #[test] fn egal() {
32039/// # use std::default::Default;
32040/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
32041/// # use admin1_directory::Directory;
32042/// 
32043/// # let secret: ApplicationSecret = Default::default();
32044/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
32045/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
32046/// #                               <MemoryStorage as Default>::default(), None);
32047/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
32048/// // As the method needs a request, you would usually fill it with the desired information
32049/// // into the respective structure. Some of the parts shown here might not be applicable !
32050/// // Values shown here are possibly random and not representative !
32051/// let mut req = Channel::default();
32052/// 
32053/// // You can configure optional parameters by calling the respective setters at will, and
32054/// // execute the final call using `doit()`.
32055/// // Values shown here are possibly random and not representative !
32056/// let result = hub.users().watch(req)
32057///              .view_type("tempor")
32058///              .sort_order("gubergren")
32059///              .show_deleted("dolore")
32060///              .query("amet.")
32061///              .projection("dolore")
32062///              .page_token("magna")
32063///              .order_by("elitr")
32064///              .max_results(-82)
32065///              .event("ipsum")
32066///              .domain("invidunt")
32067///              .customer("accusam")
32068///              .custom_field_mask("labore")
32069///              .doit();
32070/// # }
32071/// ```
32072pub struct UserWatchCall<'a, C, A>
32073    where C: 'a, A: 'a {
32074
32075    hub: &'a Directory<C, A>,
32076    _request: Channel,
32077    _view_type: Option<String>,
32078    _sort_order: Option<String>,
32079    _show_deleted: Option<String>,
32080    _query: Option<String>,
32081    _projection: Option<String>,
32082    _page_token: Option<String>,
32083    _order_by: Option<String>,
32084    _max_results: Option<i32>,
32085    _event: Option<String>,
32086    _domain: Option<String>,
32087    _customer: Option<String>,
32088    _custom_field_mask: Option<String>,
32089    _delegate: Option<&'a mut dyn Delegate>,
32090    _additional_params: HashMap<String, String>,
32091    _scopes: BTreeMap<String, ()>
32092}
32093
32094impl<'a, C, A> CallBuilder for UserWatchCall<'a, C, A> {}
32095
32096impl<'a, C, A> UserWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
32097
32098
32099    /// Perform the operation you have build so far.
32100    pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> {
32101        use std::io::{Read, Seek};
32102        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
32103        let mut dd = DefaultDelegate;
32104        let mut dlg: &mut dyn Delegate = match self._delegate {
32105            Some(d) => d,
32106            None => &mut dd
32107        };
32108        dlg.begin(MethodInfo { id: "directory.users.watch",
32109                               http_method: hyper::method::Method::Post });
32110        let mut params: Vec<(&str, String)> = Vec::with_capacity(15 + self._additional_params.len());
32111        if let Some(value) = self._view_type {
32112            params.push(("viewType", value.to_string()));
32113        }
32114        if let Some(value) = self._sort_order {
32115            params.push(("sortOrder", value.to_string()));
32116        }
32117        if let Some(value) = self._show_deleted {
32118            params.push(("showDeleted", value.to_string()));
32119        }
32120        if let Some(value) = self._query {
32121            params.push(("query", value.to_string()));
32122        }
32123        if let Some(value) = self._projection {
32124            params.push(("projection", value.to_string()));
32125        }
32126        if let Some(value) = self._page_token {
32127            params.push(("pageToken", value.to_string()));
32128        }
32129        if let Some(value) = self._order_by {
32130            params.push(("orderBy", value.to_string()));
32131        }
32132        if let Some(value) = self._max_results {
32133            params.push(("maxResults", value.to_string()));
32134        }
32135        if let Some(value) = self._event {
32136            params.push(("event", value.to_string()));
32137        }
32138        if let Some(value) = self._domain {
32139            params.push(("domain", value.to_string()));
32140        }
32141        if let Some(value) = self._customer {
32142            params.push(("customer", value.to_string()));
32143        }
32144        if let Some(value) = self._custom_field_mask {
32145            params.push(("customFieldMask", value.to_string()));
32146        }
32147        for &field in ["alt", "viewType", "sortOrder", "showDeleted", "query", "projection", "pageToken", "orderBy", "maxResults", "event", "domain", "customer", "customFieldMask"].iter() {
32148            if self._additional_params.contains_key(field) {
32149                dlg.finished(false);
32150                return Err(Error::FieldClash(field));
32151            }
32152        }
32153        for (name, value) in self._additional_params.iter() {
32154            params.push((&name, value.clone()));
32155        }
32156
32157        params.push(("alt", "json".to_string()));
32158
32159        let mut url = self.hub._base_url.clone() + "users/watch";
32160        if self._scopes.len() == 0 {
32161            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
32162        }
32163
32164
32165        let url = hyper::Url::parse_with_params(&url, params).unwrap();
32166
32167        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
32168        let mut request_value_reader =
32169            {
32170                let mut value = json::value::to_value(&self._request).expect("serde to work");
32171                remove_json_null_values(&mut value);
32172                let mut dst = io::Cursor::new(Vec::with_capacity(128));
32173                json::to_writer(&mut dst, &value).unwrap();
32174                dst
32175            };
32176        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
32177        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
32178
32179
32180        loop {
32181            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
32182                Ok(token) => token,
32183                Err(err) => {
32184                    match  dlg.token(&*err) {
32185                        Some(token) => token,
32186                        None => {
32187                            dlg.finished(false);
32188                            return Err(Error::MissingToken(err))
32189                        }
32190                    }
32191                }
32192            };
32193            let auth_header = Authorization(Bearer { token: token.access_token });
32194            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
32195            let mut req_result = {
32196                let mut client = &mut *self.hub.client.borrow_mut();
32197                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
32198                    .header(UserAgent(self.hub._user_agent.clone()))
32199                    .header(auth_header.clone())
32200                    .header(ContentType(json_mime_type.clone()))
32201                    .header(ContentLength(request_size as u64))
32202                    .body(&mut request_value_reader);
32203
32204                dlg.pre_request();
32205                req.send()
32206            };
32207
32208            match req_result {
32209                Err(err) => {
32210                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
32211                        sleep(d);
32212                        continue;
32213                    }
32214                    dlg.finished(false);
32215                    return Err(Error::HttpError(err))
32216                }
32217                Ok(mut res) => {
32218                    if !res.status.is_success() {
32219                        let mut json_err = String::new();
32220                        res.read_to_string(&mut json_err).unwrap();
32221                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
32222                                                              json::from_str(&json_err).ok(),
32223                                                              json::from_str(&json_err).ok()) {
32224                            sleep(d);
32225                            continue;
32226                        }
32227                        dlg.finished(false);
32228                        return match json::from_str::<ErrorResponse>(&json_err){
32229                            Err(_) => Err(Error::Failure(res)),
32230                            Ok(serr) => Err(Error::BadRequest(serr))
32231                        }
32232                    }
32233                    let result_value = {
32234                        let mut json_response = String::new();
32235                        res.read_to_string(&mut json_response).unwrap();
32236                        match json::from_str(&json_response) {
32237                            Ok(decoded) => (res, decoded),
32238                            Err(err) => {
32239                                dlg.response_json_decode_error(&json_response, &err);
32240                                return Err(Error::JsonDecodeError(json_response, err));
32241                            }
32242                        }
32243                    };
32244
32245                    dlg.finished(true);
32246                    return Ok(result_value)
32247                }
32248            }
32249        }
32250    }
32251
32252
32253    ///
32254    /// Sets the *request* property to the given value.
32255    ///
32256    /// Even though the property as already been set when instantiating this call,
32257    /// we provide this method for API completeness.
32258    pub fn request(mut self, new_value: Channel) -> UserWatchCall<'a, C, A> {
32259        self._request = new_value;
32260        self
32261    }
32262    /// Whether to fetch the ADMIN_VIEW or DOMAIN_PUBLIC view of the user.
32263    ///
32264    /// Sets the *view type* query property to the given value.
32265    pub fn view_type(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32266        self._view_type = Some(new_value.to_string());
32267        self
32268    }
32269    /// Whether to return results in ascending or descending order.
32270    ///
32271    /// Sets the *sort order* query property to the given value.
32272    pub fn sort_order(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32273        self._sort_order = Some(new_value.to_string());
32274        self
32275    }
32276    /// If set to true, retrieves the list of deleted users. (Default: false)
32277    ///
32278    /// Sets the *show deleted* query property to the given value.
32279    pub fn show_deleted(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32280        self._show_deleted = Some(new_value.to_string());
32281        self
32282    }
32283    /// Query string search. Should be of the form "". Complete documentation is at https://developers.google.com/admin-sdk/directory/v1/guides/search-users
32284    ///
32285    /// Sets the *query* query property to the given value.
32286    pub fn query(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32287        self._query = Some(new_value.to_string());
32288        self
32289    }
32290    /// What subset of fields to fetch for this user.
32291    ///
32292    /// Sets the *projection* query property to the given value.
32293    pub fn projection(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32294        self._projection = Some(new_value.to_string());
32295        self
32296    }
32297    /// Token to specify next page in the list
32298    ///
32299    /// Sets the *page token* query property to the given value.
32300    pub fn page_token(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32301        self._page_token = Some(new_value.to_string());
32302        self
32303    }
32304    /// Column to use for sorting results
32305    ///
32306    /// Sets the *order by* query property to the given value.
32307    pub fn order_by(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32308        self._order_by = Some(new_value.to_string());
32309        self
32310    }
32311    /// Maximum number of results to return.
32312    ///
32313    /// Sets the *max results* query property to the given value.
32314    pub fn max_results(mut self, new_value: i32) -> UserWatchCall<'a, C, A> {
32315        self._max_results = Some(new_value);
32316        self
32317    }
32318    /// Event on which subscription is intended (if subscribing)
32319    ///
32320    /// Sets the *event* query property to the given value.
32321    pub fn event(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32322        self._event = Some(new_value.to_string());
32323        self
32324    }
32325    /// 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.
32326    ///
32327    /// Sets the *domain* query property to the given value.
32328    pub fn domain(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32329        self._domain = Some(new_value.to_string());
32330        self
32331    }
32332    /// Immutable ID of the G Suite account. In case of multi-domain, to fetch all users for a customer, fill this field instead of domain.
32333    ///
32334    /// Sets the *customer* query property to the given value.
32335    pub fn customer(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32336        self._customer = Some(new_value.to_string());
32337        self
32338    }
32339    /// Comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom.
32340    ///
32341    /// Sets the *custom field mask* query property to the given value.
32342    pub fn custom_field_mask(mut self, new_value: &str) -> UserWatchCall<'a, C, A> {
32343        self._custom_field_mask = Some(new_value.to_string());
32344        self
32345    }
32346    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32347    /// while executing the actual API request.
32348    /// 
32349    /// It should be used to handle progress information, and to implement a certain level of resilience.
32350    ///
32351    /// Sets the *delegate* property to the given value.
32352    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserWatchCall<'a, C, A> {
32353        self._delegate = Some(new_value);
32354        self
32355    }
32356
32357    /// Set any additional parameter of the query string used in the request.
32358    /// It should be used to set parameters which are not yet available through their own
32359    /// setters.
32360    ///
32361    /// Please note that this method must not be used to set any of the known parameters
32362    /// which have their own setter method. If done anyway, the request will fail.
32363    ///
32364    /// # Additional Parameters
32365    ///
32366    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32367    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32368    /// * *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.
32369    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32370    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32371    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32372    /// * *alt* (query-string) - Data format for the response.
32373    pub fn param<T>(mut self, name: T, value: T) -> UserWatchCall<'a, C, A>
32374                                                        where T: AsRef<str> {
32375        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
32376        self
32377    }
32378
32379    /// Identifies the authorization scope for the method you are building.
32380    ///
32381    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
32382    /// `Scope::DirectoryUser`.
32383    ///
32384    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32385    /// tokens for more than one scope.
32386    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
32387    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
32388    /// function for details).
32389    ///
32390    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32391    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32392    /// sufficient, a read-write scope will do as well.
32393    pub fn add_scope<T, S>(mut self, scope: T) -> UserWatchCall<'a, C, A>
32394                                                        where T: Into<Option<S>>,
32395                                                              S: AsRef<str> {
32396        match scope.into() {
32397          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
32398          None => None,
32399        };
32400        self
32401    }
32402}
32403
32404
32405/// update user
32406///
32407/// A builder for the *update* method supported by a *user* resource.
32408/// It is not used directly, but through a `UserMethods` instance.
32409///
32410/// # Example
32411///
32412/// Instantiate a resource method builder
32413///
32414/// ```test_harness,no_run
32415/// # extern crate hyper;
32416/// # extern crate hyper_rustls;
32417/// # extern crate yup_oauth2 as oauth2;
32418/// # extern crate google_admin1_directory as admin1_directory;
32419/// use admin1_directory::User;
32420/// # #[test] fn egal() {
32421/// # use std::default::Default;
32422/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
32423/// # use admin1_directory::Directory;
32424/// 
32425/// # let secret: ApplicationSecret = Default::default();
32426/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
32427/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
32428/// #                               <MemoryStorage as Default>::default(), None);
32429/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
32430/// // As the method needs a request, you would usually fill it with the desired information
32431/// // into the respective structure. Some of the parts shown here might not be applicable !
32432/// // Values shown here are possibly random and not representative !
32433/// let mut req = User::default();
32434/// 
32435/// // You can configure optional parameters by calling the respective setters at will, and
32436/// // execute the final call using `doit()`.
32437/// // Values shown here are possibly random and not representative !
32438/// let result = hub.users().update(req, "userKey")
32439///              .doit();
32440/// # }
32441/// ```
32442pub struct UserUpdateCall<'a, C, A>
32443    where C: 'a, A: 'a {
32444
32445    hub: &'a Directory<C, A>,
32446    _request: User,
32447    _user_key: String,
32448    _delegate: Option<&'a mut dyn Delegate>,
32449    _additional_params: HashMap<String, String>,
32450    _scopes: BTreeMap<String, ()>
32451}
32452
32453impl<'a, C, A> CallBuilder for UserUpdateCall<'a, C, A> {}
32454
32455impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
32456
32457
32458    /// Perform the operation you have build so far.
32459    pub fn doit(mut self) -> Result<(hyper::client::Response, User)> {
32460        use std::io::{Read, Seek};
32461        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
32462        let mut dd = DefaultDelegate;
32463        let mut dlg: &mut dyn Delegate = match self._delegate {
32464            Some(d) => d,
32465            None => &mut dd
32466        };
32467        dlg.begin(MethodInfo { id: "directory.users.update",
32468                               http_method: hyper::method::Method::Put });
32469        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
32470        params.push(("userKey", self._user_key.to_string()));
32471        for &field in ["alt", "userKey"].iter() {
32472            if self._additional_params.contains_key(field) {
32473                dlg.finished(false);
32474                return Err(Error::FieldClash(field));
32475            }
32476        }
32477        for (name, value) in self._additional_params.iter() {
32478            params.push((&name, value.clone()));
32479        }
32480
32481        params.push(("alt", "json".to_string()));
32482
32483        let mut url = self.hub._base_url.clone() + "users/{userKey}";
32484        if self._scopes.len() == 0 {
32485            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
32486        }
32487
32488        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
32489            let mut replace_with: Option<&str> = None;
32490            for &(name, ref value) in params.iter() {
32491                if name == param_name {
32492                    replace_with = Some(value);
32493                    break;
32494                }
32495            }
32496            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
32497        }
32498        {
32499            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
32500            for param_name in ["userKey"].iter() {
32501                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
32502                    indices_for_removal.push(index);
32503                }
32504            }
32505            for &index in indices_for_removal.iter() {
32506                params.remove(index);
32507            }
32508        }
32509
32510        let url = hyper::Url::parse_with_params(&url, params).unwrap();
32511
32512        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
32513        let mut request_value_reader =
32514            {
32515                let mut value = json::value::to_value(&self._request).expect("serde to work");
32516                remove_json_null_values(&mut value);
32517                let mut dst = io::Cursor::new(Vec::with_capacity(128));
32518                json::to_writer(&mut dst, &value).unwrap();
32519                dst
32520            };
32521        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
32522        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
32523
32524
32525        loop {
32526            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
32527                Ok(token) => token,
32528                Err(err) => {
32529                    match  dlg.token(&*err) {
32530                        Some(token) => token,
32531                        None => {
32532                            dlg.finished(false);
32533                            return Err(Error::MissingToken(err))
32534                        }
32535                    }
32536                }
32537            };
32538            let auth_header = Authorization(Bearer { token: token.access_token });
32539            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
32540            let mut req_result = {
32541                let mut client = &mut *self.hub.client.borrow_mut();
32542                let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
32543                    .header(UserAgent(self.hub._user_agent.clone()))
32544                    .header(auth_header.clone())
32545                    .header(ContentType(json_mime_type.clone()))
32546                    .header(ContentLength(request_size as u64))
32547                    .body(&mut request_value_reader);
32548
32549                dlg.pre_request();
32550                req.send()
32551            };
32552
32553            match req_result {
32554                Err(err) => {
32555                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
32556                        sleep(d);
32557                        continue;
32558                    }
32559                    dlg.finished(false);
32560                    return Err(Error::HttpError(err))
32561                }
32562                Ok(mut res) => {
32563                    if !res.status.is_success() {
32564                        let mut json_err = String::new();
32565                        res.read_to_string(&mut json_err).unwrap();
32566                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
32567                                                              json::from_str(&json_err).ok(),
32568                                                              json::from_str(&json_err).ok()) {
32569                            sleep(d);
32570                            continue;
32571                        }
32572                        dlg.finished(false);
32573                        return match json::from_str::<ErrorResponse>(&json_err){
32574                            Err(_) => Err(Error::Failure(res)),
32575                            Ok(serr) => Err(Error::BadRequest(serr))
32576                        }
32577                    }
32578                    let result_value = {
32579                        let mut json_response = String::new();
32580                        res.read_to_string(&mut json_response).unwrap();
32581                        match json::from_str(&json_response) {
32582                            Ok(decoded) => (res, decoded),
32583                            Err(err) => {
32584                                dlg.response_json_decode_error(&json_response, &err);
32585                                return Err(Error::JsonDecodeError(json_response, err));
32586                            }
32587                        }
32588                    };
32589
32590                    dlg.finished(true);
32591                    return Ok(result_value)
32592                }
32593            }
32594        }
32595    }
32596
32597
32598    ///
32599    /// Sets the *request* property to the given value.
32600    ///
32601    /// Even though the property as already been set when instantiating this call,
32602    /// we provide this method for API completeness.
32603    pub fn request(mut self, new_value: User) -> UserUpdateCall<'a, C, A> {
32604        self._request = new_value;
32605        self
32606    }
32607    /// Email or immutable ID of the user. If ID, it should match with id of user object
32608    ///
32609    /// Sets the *user key* path property to the given value.
32610    ///
32611    /// Even though the property as already been set when instantiating this call,
32612    /// we provide this method for API completeness.
32613    pub fn user_key(mut self, new_value: &str) -> UserUpdateCall<'a, C, A> {
32614        self._user_key = new_value.to_string();
32615        self
32616    }
32617    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32618    /// while executing the actual API request.
32619    /// 
32620    /// It should be used to handle progress information, and to implement a certain level of resilience.
32621    ///
32622    /// Sets the *delegate* property to the given value.
32623    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserUpdateCall<'a, C, A> {
32624        self._delegate = Some(new_value);
32625        self
32626    }
32627
32628    /// Set any additional parameter of the query string used in the request.
32629    /// It should be used to set parameters which are not yet available through their own
32630    /// setters.
32631    ///
32632    /// Please note that this method must not be used to set any of the known parameters
32633    /// which have their own setter method. If done anyway, the request will fail.
32634    ///
32635    /// # Additional Parameters
32636    ///
32637    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32638    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32639    /// * *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.
32640    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32641    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32642    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32643    /// * *alt* (query-string) - Data format for the response.
32644    pub fn param<T>(mut self, name: T, value: T) -> UserUpdateCall<'a, C, A>
32645                                                        where T: AsRef<str> {
32646        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
32647        self
32648    }
32649
32650    /// Identifies the authorization scope for the method you are building.
32651    ///
32652    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
32653    /// `Scope::DirectoryUser`.
32654    ///
32655    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32656    /// tokens for more than one scope.
32657    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
32658    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
32659    /// function for details).
32660    ///
32661    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32662    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32663    /// sufficient, a read-write scope will do as well.
32664    pub fn add_scope<T, S>(mut self, scope: T) -> UserUpdateCall<'a, C, A>
32665                                                        where T: Into<Option<S>>,
32666                                                              S: AsRef<str> {
32667        match scope.into() {
32668          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
32669          None => None,
32670        };
32671        self
32672    }
32673}
32674
32675
32676/// Retrieve photo of a user
32677///
32678/// A builder for the *photos.get* method supported by a *user* resource.
32679/// It is not used directly, but through a `UserMethods` instance.
32680///
32681/// # Example
32682///
32683/// Instantiate a resource method builder
32684///
32685/// ```test_harness,no_run
32686/// # extern crate hyper;
32687/// # extern crate hyper_rustls;
32688/// # extern crate yup_oauth2 as oauth2;
32689/// # extern crate google_admin1_directory as admin1_directory;
32690/// # #[test] fn egal() {
32691/// # use std::default::Default;
32692/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
32693/// # use admin1_directory::Directory;
32694/// 
32695/// # let secret: ApplicationSecret = Default::default();
32696/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
32697/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
32698/// #                               <MemoryStorage as Default>::default(), None);
32699/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
32700/// // You can configure optional parameters by calling the respective setters at will, and
32701/// // execute the final call using `doit()`.
32702/// // Values shown here are possibly random and not representative !
32703/// let result = hub.users().photos_get("userKey")
32704///              .doit();
32705/// # }
32706/// ```
32707pub struct UserPhotoGetCall<'a, C, A>
32708    where C: 'a, A: 'a {
32709
32710    hub: &'a Directory<C, A>,
32711    _user_key: String,
32712    _delegate: Option<&'a mut dyn Delegate>,
32713    _additional_params: HashMap<String, String>,
32714    _scopes: BTreeMap<String, ()>
32715}
32716
32717impl<'a, C, A> CallBuilder for UserPhotoGetCall<'a, C, A> {}
32718
32719impl<'a, C, A> UserPhotoGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
32720
32721
32722    /// Perform the operation you have build so far.
32723    pub fn doit(mut self) -> Result<(hyper::client::Response, UserPhoto)> {
32724        use std::io::{Read, Seek};
32725        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
32726        let mut dd = DefaultDelegate;
32727        let mut dlg: &mut dyn Delegate = match self._delegate {
32728            Some(d) => d,
32729            None => &mut dd
32730        };
32731        dlg.begin(MethodInfo { id: "directory.users.photos.get",
32732                               http_method: hyper::method::Method::Get });
32733        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
32734        params.push(("userKey", self._user_key.to_string()));
32735        for &field in ["alt", "userKey"].iter() {
32736            if self._additional_params.contains_key(field) {
32737                dlg.finished(false);
32738                return Err(Error::FieldClash(field));
32739            }
32740        }
32741        for (name, value) in self._additional_params.iter() {
32742            params.push((&name, value.clone()));
32743        }
32744
32745        params.push(("alt", "json".to_string()));
32746
32747        let mut url = self.hub._base_url.clone() + "users/{userKey}/photos/thumbnail";
32748        if self._scopes.len() == 0 {
32749            self._scopes.insert(Scope::DirectoryUserReadonly.as_ref().to_string(), ());
32750        }
32751
32752        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
32753            let mut replace_with: Option<&str> = None;
32754            for &(name, ref value) in params.iter() {
32755                if name == param_name {
32756                    replace_with = Some(value);
32757                    break;
32758                }
32759            }
32760            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
32761        }
32762        {
32763            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
32764            for param_name in ["userKey"].iter() {
32765                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
32766                    indices_for_removal.push(index);
32767                }
32768            }
32769            for &index in indices_for_removal.iter() {
32770                params.remove(index);
32771            }
32772        }
32773
32774        let url = hyper::Url::parse_with_params(&url, params).unwrap();
32775
32776
32777
32778        loop {
32779            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
32780                Ok(token) => token,
32781                Err(err) => {
32782                    match  dlg.token(&*err) {
32783                        Some(token) => token,
32784                        None => {
32785                            dlg.finished(false);
32786                            return Err(Error::MissingToken(err))
32787                        }
32788                    }
32789                }
32790            };
32791            let auth_header = Authorization(Bearer { token: token.access_token });
32792            let mut req_result = {
32793                let mut client = &mut *self.hub.client.borrow_mut();
32794                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
32795                    .header(UserAgent(self.hub._user_agent.clone()))
32796                    .header(auth_header.clone());
32797
32798                dlg.pre_request();
32799                req.send()
32800            };
32801
32802            match req_result {
32803                Err(err) => {
32804                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
32805                        sleep(d);
32806                        continue;
32807                    }
32808                    dlg.finished(false);
32809                    return Err(Error::HttpError(err))
32810                }
32811                Ok(mut res) => {
32812                    if !res.status.is_success() {
32813                        let mut json_err = String::new();
32814                        res.read_to_string(&mut json_err).unwrap();
32815                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
32816                                                              json::from_str(&json_err).ok(),
32817                                                              json::from_str(&json_err).ok()) {
32818                            sleep(d);
32819                            continue;
32820                        }
32821                        dlg.finished(false);
32822                        return match json::from_str::<ErrorResponse>(&json_err){
32823                            Err(_) => Err(Error::Failure(res)),
32824                            Ok(serr) => Err(Error::BadRequest(serr))
32825                        }
32826                    }
32827                    let result_value = {
32828                        let mut json_response = String::new();
32829                        res.read_to_string(&mut json_response).unwrap();
32830                        match json::from_str(&json_response) {
32831                            Ok(decoded) => (res, decoded),
32832                            Err(err) => {
32833                                dlg.response_json_decode_error(&json_response, &err);
32834                                return Err(Error::JsonDecodeError(json_response, err));
32835                            }
32836                        }
32837                    };
32838
32839                    dlg.finished(true);
32840                    return Ok(result_value)
32841                }
32842            }
32843        }
32844    }
32845
32846
32847    /// Email or immutable ID of the user
32848    ///
32849    /// Sets the *user key* path property to the given value.
32850    ///
32851    /// Even though the property as already been set when instantiating this call,
32852    /// we provide this method for API completeness.
32853    pub fn user_key(mut self, new_value: &str) -> UserPhotoGetCall<'a, C, A> {
32854        self._user_key = new_value.to_string();
32855        self
32856    }
32857    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32858    /// while executing the actual API request.
32859    /// 
32860    /// It should be used to handle progress information, and to implement a certain level of resilience.
32861    ///
32862    /// Sets the *delegate* property to the given value.
32863    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserPhotoGetCall<'a, C, A> {
32864        self._delegate = Some(new_value);
32865        self
32866    }
32867
32868    /// Set any additional parameter of the query string used in the request.
32869    /// It should be used to set parameters which are not yet available through their own
32870    /// setters.
32871    ///
32872    /// Please note that this method must not be used to set any of the known parameters
32873    /// which have their own setter method. If done anyway, the request will fail.
32874    ///
32875    /// # Additional Parameters
32876    ///
32877    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32878    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32879    /// * *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.
32880    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32881    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32882    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32883    /// * *alt* (query-string) - Data format for the response.
32884    pub fn param<T>(mut self, name: T, value: T) -> UserPhotoGetCall<'a, C, A>
32885                                                        where T: AsRef<str> {
32886        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
32887        self
32888    }
32889
32890    /// Identifies the authorization scope for the method you are building.
32891    ///
32892    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
32893    /// `Scope::DirectoryUserReadonly`.
32894    ///
32895    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32896    /// tokens for more than one scope.
32897    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
32898    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
32899    /// function for details).
32900    ///
32901    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32902    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32903    /// sufficient, a read-write scope will do as well.
32904    pub fn add_scope<T, S>(mut self, scope: T) -> UserPhotoGetCall<'a, C, A>
32905                                                        where T: Into<Option<S>>,
32906                                                              S: AsRef<str> {
32907        match scope.into() {
32908          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
32909          None => None,
32910        };
32911        self
32912    }
32913}
32914
32915
32916/// Retrieve either deleted users or all users in a domain (paginated)
32917///
32918/// A builder for the *list* method supported by a *user* resource.
32919/// It is not used directly, but through a `UserMethods` instance.
32920///
32921/// # Example
32922///
32923/// Instantiate a resource method builder
32924///
32925/// ```test_harness,no_run
32926/// # extern crate hyper;
32927/// # extern crate hyper_rustls;
32928/// # extern crate yup_oauth2 as oauth2;
32929/// # extern crate google_admin1_directory as admin1_directory;
32930/// # #[test] fn egal() {
32931/// # use std::default::Default;
32932/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
32933/// # use admin1_directory::Directory;
32934/// 
32935/// # let secret: ApplicationSecret = Default::default();
32936/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
32937/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
32938/// #                               <MemoryStorage as Default>::default(), None);
32939/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
32940/// // You can configure optional parameters by calling the respective setters at will, and
32941/// // execute the final call using `doit()`.
32942/// // Values shown here are possibly random and not representative !
32943/// let result = hub.users().list()
32944///              .view_type("sed")
32945///              .sort_order("diam")
32946///              .show_deleted("magna")
32947///              .query("dolor")
32948///              .projection("Lorem")
32949///              .page_token("dolor")
32950///              .order_by("vero")
32951///              .max_results(-91)
32952///              .event("takimata")
32953///              .domain("dolores")
32954///              .customer("consetetur")
32955///              .custom_field_mask("erat")
32956///              .doit();
32957/// # }
32958/// ```
32959pub struct UserListCall<'a, C, A>
32960    where C: 'a, A: 'a {
32961
32962    hub: &'a Directory<C, A>,
32963    _view_type: Option<String>,
32964    _sort_order: Option<String>,
32965    _show_deleted: Option<String>,
32966    _query: Option<String>,
32967    _projection: Option<String>,
32968    _page_token: Option<String>,
32969    _order_by: Option<String>,
32970    _max_results: Option<i32>,
32971    _event: Option<String>,
32972    _domain: Option<String>,
32973    _customer: Option<String>,
32974    _custom_field_mask: Option<String>,
32975    _delegate: Option<&'a mut dyn Delegate>,
32976    _additional_params: HashMap<String, String>,
32977    _scopes: BTreeMap<String, ()>
32978}
32979
32980impl<'a, C, A> CallBuilder for UserListCall<'a, C, A> {}
32981
32982impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
32983
32984
32985    /// Perform the operation you have build so far.
32986    pub fn doit(mut self) -> Result<(hyper::client::Response, Users)> {
32987        use std::io::{Read, Seek};
32988        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
32989        let mut dd = DefaultDelegate;
32990        let mut dlg: &mut dyn Delegate = match self._delegate {
32991            Some(d) => d,
32992            None => &mut dd
32993        };
32994        dlg.begin(MethodInfo { id: "directory.users.list",
32995                               http_method: hyper::method::Method::Get });
32996        let mut params: Vec<(&str, String)> = Vec::with_capacity(14 + self._additional_params.len());
32997        if let Some(value) = self._view_type {
32998            params.push(("viewType", value.to_string()));
32999        }
33000        if let Some(value) = self._sort_order {
33001            params.push(("sortOrder", value.to_string()));
33002        }
33003        if let Some(value) = self._show_deleted {
33004            params.push(("showDeleted", value.to_string()));
33005        }
33006        if let Some(value) = self._query {
33007            params.push(("query", value.to_string()));
33008        }
33009        if let Some(value) = self._projection {
33010            params.push(("projection", value.to_string()));
33011        }
33012        if let Some(value) = self._page_token {
33013            params.push(("pageToken", value.to_string()));
33014        }
33015        if let Some(value) = self._order_by {
33016            params.push(("orderBy", value.to_string()));
33017        }
33018        if let Some(value) = self._max_results {
33019            params.push(("maxResults", value.to_string()));
33020        }
33021        if let Some(value) = self._event {
33022            params.push(("event", value.to_string()));
33023        }
33024        if let Some(value) = self._domain {
33025            params.push(("domain", value.to_string()));
33026        }
33027        if let Some(value) = self._customer {
33028            params.push(("customer", value.to_string()));
33029        }
33030        if let Some(value) = self._custom_field_mask {
33031            params.push(("customFieldMask", value.to_string()));
33032        }
33033        for &field in ["alt", "viewType", "sortOrder", "showDeleted", "query", "projection", "pageToken", "orderBy", "maxResults", "event", "domain", "customer", "customFieldMask"].iter() {
33034            if self._additional_params.contains_key(field) {
33035                dlg.finished(false);
33036                return Err(Error::FieldClash(field));
33037            }
33038        }
33039        for (name, value) in self._additional_params.iter() {
33040            params.push((&name, value.clone()));
33041        }
33042
33043        params.push(("alt", "json".to_string()));
33044
33045        let mut url = self.hub._base_url.clone() + "users";
33046        if self._scopes.len() == 0 {
33047            self._scopes.insert(Scope::DirectoryUserReadonly.as_ref().to_string(), ());
33048        }
33049
33050
33051        let url = hyper::Url::parse_with_params(&url, params).unwrap();
33052
33053
33054
33055        loop {
33056            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
33057                Ok(token) => token,
33058                Err(err) => {
33059                    match  dlg.token(&*err) {
33060                        Some(token) => token,
33061                        None => {
33062                            dlg.finished(false);
33063                            return Err(Error::MissingToken(err))
33064                        }
33065                    }
33066                }
33067            };
33068            let auth_header = Authorization(Bearer { token: token.access_token });
33069            let mut req_result = {
33070                let mut client = &mut *self.hub.client.borrow_mut();
33071                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
33072                    .header(UserAgent(self.hub._user_agent.clone()))
33073                    .header(auth_header.clone());
33074
33075                dlg.pre_request();
33076                req.send()
33077            };
33078
33079            match req_result {
33080                Err(err) => {
33081                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
33082                        sleep(d);
33083                        continue;
33084                    }
33085                    dlg.finished(false);
33086                    return Err(Error::HttpError(err))
33087                }
33088                Ok(mut res) => {
33089                    if !res.status.is_success() {
33090                        let mut json_err = String::new();
33091                        res.read_to_string(&mut json_err).unwrap();
33092                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
33093                                                              json::from_str(&json_err).ok(),
33094                                                              json::from_str(&json_err).ok()) {
33095                            sleep(d);
33096                            continue;
33097                        }
33098                        dlg.finished(false);
33099                        return match json::from_str::<ErrorResponse>(&json_err){
33100                            Err(_) => Err(Error::Failure(res)),
33101                            Ok(serr) => Err(Error::BadRequest(serr))
33102                        }
33103                    }
33104                    let result_value = {
33105                        let mut json_response = String::new();
33106                        res.read_to_string(&mut json_response).unwrap();
33107                        match json::from_str(&json_response) {
33108                            Ok(decoded) => (res, decoded),
33109                            Err(err) => {
33110                                dlg.response_json_decode_error(&json_response, &err);
33111                                return Err(Error::JsonDecodeError(json_response, err));
33112                            }
33113                        }
33114                    };
33115
33116                    dlg.finished(true);
33117                    return Ok(result_value)
33118                }
33119            }
33120        }
33121    }
33122
33123
33124    /// Whether to fetch the ADMIN_VIEW or DOMAIN_PUBLIC view of the user.
33125    ///
33126    /// Sets the *view type* query property to the given value.
33127    pub fn view_type(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33128        self._view_type = Some(new_value.to_string());
33129        self
33130    }
33131    /// Whether to return results in ascending or descending order.
33132    ///
33133    /// Sets the *sort order* query property to the given value.
33134    pub fn sort_order(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33135        self._sort_order = Some(new_value.to_string());
33136        self
33137    }
33138    /// If set to true, retrieves the list of deleted users. (Default: false)
33139    ///
33140    /// Sets the *show deleted* query property to the given value.
33141    pub fn show_deleted(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33142        self._show_deleted = Some(new_value.to_string());
33143        self
33144    }
33145    /// Query string search. Should be of the form "". Complete documentation is at https://developers.google.com/admin-sdk/directory/v1/guides/search-users
33146    ///
33147    /// Sets the *query* query property to the given value.
33148    pub fn query(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33149        self._query = Some(new_value.to_string());
33150        self
33151    }
33152    /// What subset of fields to fetch for this user.
33153    ///
33154    /// Sets the *projection* query property to the given value.
33155    pub fn projection(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33156        self._projection = Some(new_value.to_string());
33157        self
33158    }
33159    /// Token to specify next page in the list
33160    ///
33161    /// Sets the *page token* query property to the given value.
33162    pub fn page_token(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33163        self._page_token = Some(new_value.to_string());
33164        self
33165    }
33166    /// Column to use for sorting results
33167    ///
33168    /// Sets the *order by* query property to the given value.
33169    pub fn order_by(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33170        self._order_by = Some(new_value.to_string());
33171        self
33172    }
33173    /// Maximum number of results to return.
33174    ///
33175    /// Sets the *max results* query property to the given value.
33176    pub fn max_results(mut self, new_value: i32) -> UserListCall<'a, C, A> {
33177        self._max_results = Some(new_value);
33178        self
33179    }
33180    /// Event on which subscription is intended (if subscribing)
33181    ///
33182    /// Sets the *event* query property to the given value.
33183    pub fn event(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33184        self._event = Some(new_value.to_string());
33185        self
33186    }
33187    /// 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.
33188    ///
33189    /// Sets the *domain* query property to the given value.
33190    pub fn domain(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33191        self._domain = Some(new_value.to_string());
33192        self
33193    }
33194    /// Immutable ID of the G Suite account. In case of multi-domain, to fetch all users for a customer, fill this field instead of domain.
33195    ///
33196    /// Sets the *customer* query property to the given value.
33197    pub fn customer(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33198        self._customer = Some(new_value.to_string());
33199        self
33200    }
33201    /// Comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom.
33202    ///
33203    /// Sets the *custom field mask* query property to the given value.
33204    pub fn custom_field_mask(mut self, new_value: &str) -> UserListCall<'a, C, A> {
33205        self._custom_field_mask = Some(new_value.to_string());
33206        self
33207    }
33208    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33209    /// while executing the actual API request.
33210    /// 
33211    /// It should be used to handle progress information, and to implement a certain level of resilience.
33212    ///
33213    /// Sets the *delegate* property to the given value.
33214    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserListCall<'a, C, A> {
33215        self._delegate = Some(new_value);
33216        self
33217    }
33218
33219    /// Set any additional parameter of the query string used in the request.
33220    /// It should be used to set parameters which are not yet available through their own
33221    /// setters.
33222    ///
33223    /// Please note that this method must not be used to set any of the known parameters
33224    /// which have their own setter method. If done anyway, the request will fail.
33225    ///
33226    /// # Additional Parameters
33227    ///
33228    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33229    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33230    /// * *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.
33231    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33232    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33233    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33234    /// * *alt* (query-string) - Data format for the response.
33235    pub fn param<T>(mut self, name: T, value: T) -> UserListCall<'a, C, A>
33236                                                        where T: AsRef<str> {
33237        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
33238        self
33239    }
33240
33241    /// Identifies the authorization scope for the method you are building.
33242    ///
33243    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
33244    /// `Scope::DirectoryUserReadonly`.
33245    ///
33246    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33247    /// tokens for more than one scope.
33248    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
33249    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
33250    /// function for details).
33251    ///
33252    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33253    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33254    /// sufficient, a read-write scope will do as well.
33255    pub fn add_scope<T, S>(mut self, scope: T) -> UserListCall<'a, C, A>
33256                                                        where T: Into<Option<S>>,
33257                                                              S: AsRef<str> {
33258        match scope.into() {
33259          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
33260          None => None,
33261        };
33262        self
33263    }
33264}
33265
33266
33267/// retrieve user
33268///
33269/// A builder for the *get* method supported by a *user* resource.
33270/// It is not used directly, but through a `UserMethods` instance.
33271///
33272/// # Example
33273///
33274/// Instantiate a resource method builder
33275///
33276/// ```test_harness,no_run
33277/// # extern crate hyper;
33278/// # extern crate hyper_rustls;
33279/// # extern crate yup_oauth2 as oauth2;
33280/// # extern crate google_admin1_directory as admin1_directory;
33281/// # #[test] fn egal() {
33282/// # use std::default::Default;
33283/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
33284/// # use admin1_directory::Directory;
33285/// 
33286/// # let secret: ApplicationSecret = Default::default();
33287/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
33288/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
33289/// #                               <MemoryStorage as Default>::default(), None);
33290/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
33291/// // You can configure optional parameters by calling the respective setters at will, and
33292/// // execute the final call using `doit()`.
33293/// // Values shown here are possibly random and not representative !
33294/// let result = hub.users().get("userKey")
33295///              .view_type("dolores")
33296///              .projection("dolores")
33297///              .custom_field_mask("et")
33298///              .doit();
33299/// # }
33300/// ```
33301pub struct UserGetCall<'a, C, A>
33302    where C: 'a, A: 'a {
33303
33304    hub: &'a Directory<C, A>,
33305    _user_key: String,
33306    _view_type: Option<String>,
33307    _projection: Option<String>,
33308    _custom_field_mask: Option<String>,
33309    _delegate: Option<&'a mut dyn Delegate>,
33310    _additional_params: HashMap<String, String>,
33311    _scopes: BTreeMap<String, ()>
33312}
33313
33314impl<'a, C, A> CallBuilder for UserGetCall<'a, C, A> {}
33315
33316impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
33317
33318
33319    /// Perform the operation you have build so far.
33320    pub fn doit(mut self) -> Result<(hyper::client::Response, User)> {
33321        use std::io::{Read, Seek};
33322        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
33323        let mut dd = DefaultDelegate;
33324        let mut dlg: &mut dyn Delegate = match self._delegate {
33325            Some(d) => d,
33326            None => &mut dd
33327        };
33328        dlg.begin(MethodInfo { id: "directory.users.get",
33329                               http_method: hyper::method::Method::Get });
33330        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
33331        params.push(("userKey", self._user_key.to_string()));
33332        if let Some(value) = self._view_type {
33333            params.push(("viewType", value.to_string()));
33334        }
33335        if let Some(value) = self._projection {
33336            params.push(("projection", value.to_string()));
33337        }
33338        if let Some(value) = self._custom_field_mask {
33339            params.push(("customFieldMask", value.to_string()));
33340        }
33341        for &field in ["alt", "userKey", "viewType", "projection", "customFieldMask"].iter() {
33342            if self._additional_params.contains_key(field) {
33343                dlg.finished(false);
33344                return Err(Error::FieldClash(field));
33345            }
33346        }
33347        for (name, value) in self._additional_params.iter() {
33348            params.push((&name, value.clone()));
33349        }
33350
33351        params.push(("alt", "json".to_string()));
33352
33353        let mut url = self.hub._base_url.clone() + "users/{userKey}";
33354        if self._scopes.len() == 0 {
33355            self._scopes.insert(Scope::DirectoryUserReadonly.as_ref().to_string(), ());
33356        }
33357
33358        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
33359            let mut replace_with: Option<&str> = None;
33360            for &(name, ref value) in params.iter() {
33361                if name == param_name {
33362                    replace_with = Some(value);
33363                    break;
33364                }
33365            }
33366            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
33367        }
33368        {
33369            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
33370            for param_name in ["userKey"].iter() {
33371                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
33372                    indices_for_removal.push(index);
33373                }
33374            }
33375            for &index in indices_for_removal.iter() {
33376                params.remove(index);
33377            }
33378        }
33379
33380        let url = hyper::Url::parse_with_params(&url, params).unwrap();
33381
33382
33383
33384        loop {
33385            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
33386                Ok(token) => token,
33387                Err(err) => {
33388                    match  dlg.token(&*err) {
33389                        Some(token) => token,
33390                        None => {
33391                            dlg.finished(false);
33392                            return Err(Error::MissingToken(err))
33393                        }
33394                    }
33395                }
33396            };
33397            let auth_header = Authorization(Bearer { token: token.access_token });
33398            let mut req_result = {
33399                let mut client = &mut *self.hub.client.borrow_mut();
33400                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
33401                    .header(UserAgent(self.hub._user_agent.clone()))
33402                    .header(auth_header.clone());
33403
33404                dlg.pre_request();
33405                req.send()
33406            };
33407
33408            match req_result {
33409                Err(err) => {
33410                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
33411                        sleep(d);
33412                        continue;
33413                    }
33414                    dlg.finished(false);
33415                    return Err(Error::HttpError(err))
33416                }
33417                Ok(mut res) => {
33418                    if !res.status.is_success() {
33419                        let mut json_err = String::new();
33420                        res.read_to_string(&mut json_err).unwrap();
33421                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
33422                                                              json::from_str(&json_err).ok(),
33423                                                              json::from_str(&json_err).ok()) {
33424                            sleep(d);
33425                            continue;
33426                        }
33427                        dlg.finished(false);
33428                        return match json::from_str::<ErrorResponse>(&json_err){
33429                            Err(_) => Err(Error::Failure(res)),
33430                            Ok(serr) => Err(Error::BadRequest(serr))
33431                        }
33432                    }
33433                    let result_value = {
33434                        let mut json_response = String::new();
33435                        res.read_to_string(&mut json_response).unwrap();
33436                        match json::from_str(&json_response) {
33437                            Ok(decoded) => (res, decoded),
33438                            Err(err) => {
33439                                dlg.response_json_decode_error(&json_response, &err);
33440                                return Err(Error::JsonDecodeError(json_response, err));
33441                            }
33442                        }
33443                    };
33444
33445                    dlg.finished(true);
33446                    return Ok(result_value)
33447                }
33448            }
33449        }
33450    }
33451
33452
33453    /// Email or immutable ID of the user
33454    ///
33455    /// Sets the *user key* path property to the given value.
33456    ///
33457    /// Even though the property as already been set when instantiating this call,
33458    /// we provide this method for API completeness.
33459    pub fn user_key(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
33460        self._user_key = new_value.to_string();
33461        self
33462    }
33463    /// Whether to fetch the ADMIN_VIEW or DOMAIN_PUBLIC view of the user.
33464    ///
33465    /// Sets the *view type* query property to the given value.
33466    pub fn view_type(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
33467        self._view_type = Some(new_value.to_string());
33468        self
33469    }
33470    /// What subset of fields to fetch for this user.
33471    ///
33472    /// Sets the *projection* query property to the given value.
33473    pub fn projection(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
33474        self._projection = Some(new_value.to_string());
33475        self
33476    }
33477    /// Comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom.
33478    ///
33479    /// Sets the *custom field mask* query property to the given value.
33480    pub fn custom_field_mask(mut self, new_value: &str) -> UserGetCall<'a, C, A> {
33481        self._custom_field_mask = Some(new_value.to_string());
33482        self
33483    }
33484    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33485    /// while executing the actual API request.
33486    /// 
33487    /// It should be used to handle progress information, and to implement a certain level of resilience.
33488    ///
33489    /// Sets the *delegate* property to the given value.
33490    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserGetCall<'a, C, A> {
33491        self._delegate = Some(new_value);
33492        self
33493    }
33494
33495    /// Set any additional parameter of the query string used in the request.
33496    /// It should be used to set parameters which are not yet available through their own
33497    /// setters.
33498    ///
33499    /// Please note that this method must not be used to set any of the known parameters
33500    /// which have their own setter method. If done anyway, the request will fail.
33501    ///
33502    /// # Additional Parameters
33503    ///
33504    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33505    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33506    /// * *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.
33507    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33508    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33509    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33510    /// * *alt* (query-string) - Data format for the response.
33511    pub fn param<T>(mut self, name: T, value: T) -> UserGetCall<'a, C, A>
33512                                                        where T: AsRef<str> {
33513        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
33514        self
33515    }
33516
33517    /// Identifies the authorization scope for the method you are building.
33518    ///
33519    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
33520    /// `Scope::DirectoryUserReadonly`.
33521    ///
33522    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33523    /// tokens for more than one scope.
33524    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
33525    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
33526    /// function for details).
33527    ///
33528    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33529    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33530    /// sufficient, a read-write scope will do as well.
33531    pub fn add_scope<T, S>(mut self, scope: T) -> UserGetCall<'a, C, A>
33532                                                        where T: Into<Option<S>>,
33533                                                              S: AsRef<str> {
33534        match scope.into() {
33535          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
33536          None => None,
33537        };
33538        self
33539    }
33540}
33541
33542
33543/// Add a alias for the user
33544///
33545/// A builder for the *aliases.insert* method supported by a *user* resource.
33546/// It is not used directly, but through a `UserMethods` instance.
33547///
33548/// # Example
33549///
33550/// Instantiate a resource method builder
33551///
33552/// ```test_harness,no_run
33553/// # extern crate hyper;
33554/// # extern crate hyper_rustls;
33555/// # extern crate yup_oauth2 as oauth2;
33556/// # extern crate google_admin1_directory as admin1_directory;
33557/// use admin1_directory::Alias;
33558/// # #[test] fn egal() {
33559/// # use std::default::Default;
33560/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
33561/// # use admin1_directory::Directory;
33562/// 
33563/// # let secret: ApplicationSecret = Default::default();
33564/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
33565/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
33566/// #                               <MemoryStorage as Default>::default(), None);
33567/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
33568/// // As the method needs a request, you would usually fill it with the desired information
33569/// // into the respective structure. Some of the parts shown here might not be applicable !
33570/// // Values shown here are possibly random and not representative !
33571/// let mut req = Alias::default();
33572/// 
33573/// // You can configure optional parameters by calling the respective setters at will, and
33574/// // execute the final call using `doit()`.
33575/// // Values shown here are possibly random and not representative !
33576/// let result = hub.users().aliases_insert(req, "userKey")
33577///              .doit();
33578/// # }
33579/// ```
33580pub struct UserAliaseInsertCall<'a, C, A>
33581    where C: 'a, A: 'a {
33582
33583    hub: &'a Directory<C, A>,
33584    _request: Alias,
33585    _user_key: String,
33586    _delegate: Option<&'a mut dyn Delegate>,
33587    _additional_params: HashMap<String, String>,
33588    _scopes: BTreeMap<String, ()>
33589}
33590
33591impl<'a, C, A> CallBuilder for UserAliaseInsertCall<'a, C, A> {}
33592
33593impl<'a, C, A> UserAliaseInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
33594
33595
33596    /// Perform the operation you have build so far.
33597    pub fn doit(mut self) -> Result<(hyper::client::Response, Alias)> {
33598        use std::io::{Read, Seek};
33599        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
33600        let mut dd = DefaultDelegate;
33601        let mut dlg: &mut dyn Delegate = match self._delegate {
33602            Some(d) => d,
33603            None => &mut dd
33604        };
33605        dlg.begin(MethodInfo { id: "directory.users.aliases.insert",
33606                               http_method: hyper::method::Method::Post });
33607        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
33608        params.push(("userKey", self._user_key.to_string()));
33609        for &field in ["alt", "userKey"].iter() {
33610            if self._additional_params.contains_key(field) {
33611                dlg.finished(false);
33612                return Err(Error::FieldClash(field));
33613            }
33614        }
33615        for (name, value) in self._additional_params.iter() {
33616            params.push((&name, value.clone()));
33617        }
33618
33619        params.push(("alt", "json".to_string()));
33620
33621        let mut url = self.hub._base_url.clone() + "users/{userKey}/aliases";
33622        if self._scopes.len() == 0 {
33623            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
33624        }
33625
33626        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
33627            let mut replace_with: Option<&str> = None;
33628            for &(name, ref value) in params.iter() {
33629                if name == param_name {
33630                    replace_with = Some(value);
33631                    break;
33632                }
33633            }
33634            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
33635        }
33636        {
33637            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
33638            for param_name in ["userKey"].iter() {
33639                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
33640                    indices_for_removal.push(index);
33641                }
33642            }
33643            for &index in indices_for_removal.iter() {
33644                params.remove(index);
33645            }
33646        }
33647
33648        let url = hyper::Url::parse_with_params(&url, params).unwrap();
33649
33650        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
33651        let mut request_value_reader =
33652            {
33653                let mut value = json::value::to_value(&self._request).expect("serde to work");
33654                remove_json_null_values(&mut value);
33655                let mut dst = io::Cursor::new(Vec::with_capacity(128));
33656                json::to_writer(&mut dst, &value).unwrap();
33657                dst
33658            };
33659        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
33660        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
33661
33662
33663        loop {
33664            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
33665                Ok(token) => token,
33666                Err(err) => {
33667                    match  dlg.token(&*err) {
33668                        Some(token) => token,
33669                        None => {
33670                            dlg.finished(false);
33671                            return Err(Error::MissingToken(err))
33672                        }
33673                    }
33674                }
33675            };
33676            let auth_header = Authorization(Bearer { token: token.access_token });
33677            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
33678            let mut req_result = {
33679                let mut client = &mut *self.hub.client.borrow_mut();
33680                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
33681                    .header(UserAgent(self.hub._user_agent.clone()))
33682                    .header(auth_header.clone())
33683                    .header(ContentType(json_mime_type.clone()))
33684                    .header(ContentLength(request_size as u64))
33685                    .body(&mut request_value_reader);
33686
33687                dlg.pre_request();
33688                req.send()
33689            };
33690
33691            match req_result {
33692                Err(err) => {
33693                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
33694                        sleep(d);
33695                        continue;
33696                    }
33697                    dlg.finished(false);
33698                    return Err(Error::HttpError(err))
33699                }
33700                Ok(mut res) => {
33701                    if !res.status.is_success() {
33702                        let mut json_err = String::new();
33703                        res.read_to_string(&mut json_err).unwrap();
33704                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
33705                                                              json::from_str(&json_err).ok(),
33706                                                              json::from_str(&json_err).ok()) {
33707                            sleep(d);
33708                            continue;
33709                        }
33710                        dlg.finished(false);
33711                        return match json::from_str::<ErrorResponse>(&json_err){
33712                            Err(_) => Err(Error::Failure(res)),
33713                            Ok(serr) => Err(Error::BadRequest(serr))
33714                        }
33715                    }
33716                    let result_value = {
33717                        let mut json_response = String::new();
33718                        res.read_to_string(&mut json_response).unwrap();
33719                        match json::from_str(&json_response) {
33720                            Ok(decoded) => (res, decoded),
33721                            Err(err) => {
33722                                dlg.response_json_decode_error(&json_response, &err);
33723                                return Err(Error::JsonDecodeError(json_response, err));
33724                            }
33725                        }
33726                    };
33727
33728                    dlg.finished(true);
33729                    return Ok(result_value)
33730                }
33731            }
33732        }
33733    }
33734
33735
33736    ///
33737    /// Sets the *request* property to the given value.
33738    ///
33739    /// Even though the property as already been set when instantiating this call,
33740    /// we provide this method for API completeness.
33741    pub fn request(mut self, new_value: Alias) -> UserAliaseInsertCall<'a, C, A> {
33742        self._request = new_value;
33743        self
33744    }
33745    /// Email or immutable ID of the user
33746    ///
33747    /// Sets the *user key* path property to the given value.
33748    ///
33749    /// Even though the property as already been set when instantiating this call,
33750    /// we provide this method for API completeness.
33751    pub fn user_key(mut self, new_value: &str) -> UserAliaseInsertCall<'a, C, A> {
33752        self._user_key = new_value.to_string();
33753        self
33754    }
33755    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33756    /// while executing the actual API request.
33757    /// 
33758    /// It should be used to handle progress information, and to implement a certain level of resilience.
33759    ///
33760    /// Sets the *delegate* property to the given value.
33761    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserAliaseInsertCall<'a, C, A> {
33762        self._delegate = Some(new_value);
33763        self
33764    }
33765
33766    /// Set any additional parameter of the query string used in the request.
33767    /// It should be used to set parameters which are not yet available through their own
33768    /// setters.
33769    ///
33770    /// Please note that this method must not be used to set any of the known parameters
33771    /// which have their own setter method. If done anyway, the request will fail.
33772    ///
33773    /// # Additional Parameters
33774    ///
33775    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33776    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33777    /// * *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.
33778    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33779    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33780    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33781    /// * *alt* (query-string) - Data format for the response.
33782    pub fn param<T>(mut self, name: T, value: T) -> UserAliaseInsertCall<'a, C, A>
33783                                                        where T: AsRef<str> {
33784        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
33785        self
33786    }
33787
33788    /// Identifies the authorization scope for the method you are building.
33789    ///
33790    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
33791    /// `Scope::DirectoryUser`.
33792    ///
33793    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33794    /// tokens for more than one scope.
33795    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
33796    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
33797    /// function for details).
33798    ///
33799    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33800    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33801    /// sufficient, a read-write scope will do as well.
33802    pub fn add_scope<T, S>(mut self, scope: T) -> UserAliaseInsertCall<'a, C, A>
33803                                                        where T: Into<Option<S>>,
33804                                                              S: AsRef<str> {
33805        match scope.into() {
33806          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
33807          None => None,
33808        };
33809        self
33810    }
33811}
33812
33813
33814/// List all aliases for a user
33815///
33816/// A builder for the *aliases.list* method supported by a *user* resource.
33817/// It is not used directly, but through a `UserMethods` instance.
33818///
33819/// # Example
33820///
33821/// Instantiate a resource method builder
33822///
33823/// ```test_harness,no_run
33824/// # extern crate hyper;
33825/// # extern crate hyper_rustls;
33826/// # extern crate yup_oauth2 as oauth2;
33827/// # extern crate google_admin1_directory as admin1_directory;
33828/// # #[test] fn egal() {
33829/// # use std::default::Default;
33830/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
33831/// # use admin1_directory::Directory;
33832/// 
33833/// # let secret: ApplicationSecret = Default::default();
33834/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
33835/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
33836/// #                               <MemoryStorage as Default>::default(), None);
33837/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
33838/// // You can configure optional parameters by calling the respective setters at will, and
33839/// // execute the final call using `doit()`.
33840/// // Values shown here are possibly random and not representative !
33841/// let result = hub.users().aliases_list("userKey")
33842///              .event("aliquyam")
33843///              .doit();
33844/// # }
33845/// ```
33846pub struct UserAliaseListCall<'a, C, A>
33847    where C: 'a, A: 'a {
33848
33849    hub: &'a Directory<C, A>,
33850    _user_key: String,
33851    _event: Option<String>,
33852    _delegate: Option<&'a mut dyn Delegate>,
33853    _additional_params: HashMap<String, String>,
33854    _scopes: BTreeMap<String, ()>
33855}
33856
33857impl<'a, C, A> CallBuilder for UserAliaseListCall<'a, C, A> {}
33858
33859impl<'a, C, A> UserAliaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
33860
33861
33862    /// Perform the operation you have build so far.
33863    pub fn doit(mut self) -> Result<(hyper::client::Response, Aliases)> {
33864        use std::io::{Read, Seek};
33865        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
33866        let mut dd = DefaultDelegate;
33867        let mut dlg: &mut dyn Delegate = match self._delegate {
33868            Some(d) => d,
33869            None => &mut dd
33870        };
33871        dlg.begin(MethodInfo { id: "directory.users.aliases.list",
33872                               http_method: hyper::method::Method::Get });
33873        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
33874        params.push(("userKey", self._user_key.to_string()));
33875        if let Some(value) = self._event {
33876            params.push(("event", value.to_string()));
33877        }
33878        for &field in ["alt", "userKey", "event"].iter() {
33879            if self._additional_params.contains_key(field) {
33880                dlg.finished(false);
33881                return Err(Error::FieldClash(field));
33882            }
33883        }
33884        for (name, value) in self._additional_params.iter() {
33885            params.push((&name, value.clone()));
33886        }
33887
33888        params.push(("alt", "json".to_string()));
33889
33890        let mut url = self.hub._base_url.clone() + "users/{userKey}/aliases";
33891        if self._scopes.len() == 0 {
33892            self._scopes.insert(Scope::DirectoryUserAliaReadonly.as_ref().to_string(), ());
33893        }
33894
33895        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
33896            let mut replace_with: Option<&str> = None;
33897            for &(name, ref value) in params.iter() {
33898                if name == param_name {
33899                    replace_with = Some(value);
33900                    break;
33901                }
33902            }
33903            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
33904        }
33905        {
33906            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
33907            for param_name in ["userKey"].iter() {
33908                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
33909                    indices_for_removal.push(index);
33910                }
33911            }
33912            for &index in indices_for_removal.iter() {
33913                params.remove(index);
33914            }
33915        }
33916
33917        let url = hyper::Url::parse_with_params(&url, params).unwrap();
33918
33919
33920
33921        loop {
33922            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
33923                Ok(token) => token,
33924                Err(err) => {
33925                    match  dlg.token(&*err) {
33926                        Some(token) => token,
33927                        None => {
33928                            dlg.finished(false);
33929                            return Err(Error::MissingToken(err))
33930                        }
33931                    }
33932                }
33933            };
33934            let auth_header = Authorization(Bearer { token: token.access_token });
33935            let mut req_result = {
33936                let mut client = &mut *self.hub.client.borrow_mut();
33937                let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
33938                    .header(UserAgent(self.hub._user_agent.clone()))
33939                    .header(auth_header.clone());
33940
33941                dlg.pre_request();
33942                req.send()
33943            };
33944
33945            match req_result {
33946                Err(err) => {
33947                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
33948                        sleep(d);
33949                        continue;
33950                    }
33951                    dlg.finished(false);
33952                    return Err(Error::HttpError(err))
33953                }
33954                Ok(mut res) => {
33955                    if !res.status.is_success() {
33956                        let mut json_err = String::new();
33957                        res.read_to_string(&mut json_err).unwrap();
33958                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
33959                                                              json::from_str(&json_err).ok(),
33960                                                              json::from_str(&json_err).ok()) {
33961                            sleep(d);
33962                            continue;
33963                        }
33964                        dlg.finished(false);
33965                        return match json::from_str::<ErrorResponse>(&json_err){
33966                            Err(_) => Err(Error::Failure(res)),
33967                            Ok(serr) => Err(Error::BadRequest(serr))
33968                        }
33969                    }
33970                    let result_value = {
33971                        let mut json_response = String::new();
33972                        res.read_to_string(&mut json_response).unwrap();
33973                        match json::from_str(&json_response) {
33974                            Ok(decoded) => (res, decoded),
33975                            Err(err) => {
33976                                dlg.response_json_decode_error(&json_response, &err);
33977                                return Err(Error::JsonDecodeError(json_response, err));
33978                            }
33979                        }
33980                    };
33981
33982                    dlg.finished(true);
33983                    return Ok(result_value)
33984                }
33985            }
33986        }
33987    }
33988
33989
33990    /// Email or immutable ID of the user
33991    ///
33992    /// Sets the *user key* path property to the given value.
33993    ///
33994    /// Even though the property as already been set when instantiating this call,
33995    /// we provide this method for API completeness.
33996    pub fn user_key(mut self, new_value: &str) -> UserAliaseListCall<'a, C, A> {
33997        self._user_key = new_value.to_string();
33998        self
33999    }
34000    /// Event on which subscription is intended (if subscribing)
34001    ///
34002    /// Sets the *event* query property to the given value.
34003    pub fn event(mut self, new_value: &str) -> UserAliaseListCall<'a, C, A> {
34004        self._event = Some(new_value.to_string());
34005        self
34006    }
34007    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34008    /// while executing the actual API request.
34009    /// 
34010    /// It should be used to handle progress information, and to implement a certain level of resilience.
34011    ///
34012    /// Sets the *delegate* property to the given value.
34013    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserAliaseListCall<'a, C, A> {
34014        self._delegate = Some(new_value);
34015        self
34016    }
34017
34018    /// Set any additional parameter of the query string used in the request.
34019    /// It should be used to set parameters which are not yet available through their own
34020    /// setters.
34021    ///
34022    /// Please note that this method must not be used to set any of the known parameters
34023    /// which have their own setter method. If done anyway, the request will fail.
34024    ///
34025    /// # Additional Parameters
34026    ///
34027    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34028    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34029    /// * *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.
34030    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34031    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34032    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34033    /// * *alt* (query-string) - Data format for the response.
34034    pub fn param<T>(mut self, name: T, value: T) -> UserAliaseListCall<'a, C, A>
34035                                                        where T: AsRef<str> {
34036        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
34037        self
34038    }
34039
34040    /// Identifies the authorization scope for the method you are building.
34041    ///
34042    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
34043    /// `Scope::DirectoryUserAliaReadonly`.
34044    ///
34045    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34046    /// tokens for more than one scope.
34047    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
34048    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
34049    /// function for details).
34050    ///
34051    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34052    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34053    /// sufficient, a read-write scope will do as well.
34054    pub fn add_scope<T, S>(mut self, scope: T) -> UserAliaseListCall<'a, C, A>
34055                                                        where T: Into<Option<S>>,
34056                                                              S: AsRef<str> {
34057        match scope.into() {
34058          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
34059          None => None,
34060        };
34061        self
34062    }
34063}
34064
34065
34066/// change admin status of a user
34067///
34068/// A builder for the *makeAdmin* method supported by a *user* resource.
34069/// It is not used directly, but through a `UserMethods` instance.
34070///
34071/// # Example
34072///
34073/// Instantiate a resource method builder
34074///
34075/// ```test_harness,no_run
34076/// # extern crate hyper;
34077/// # extern crate hyper_rustls;
34078/// # extern crate yup_oauth2 as oauth2;
34079/// # extern crate google_admin1_directory as admin1_directory;
34080/// use admin1_directory::UserMakeAdmin;
34081/// # #[test] fn egal() {
34082/// # use std::default::Default;
34083/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
34084/// # use admin1_directory::Directory;
34085/// 
34086/// # let secret: ApplicationSecret = Default::default();
34087/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
34088/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
34089/// #                               <MemoryStorage as Default>::default(), None);
34090/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
34091/// // As the method needs a request, you would usually fill it with the desired information
34092/// // into the respective structure. Some of the parts shown here might not be applicable !
34093/// // Values shown here are possibly random and not representative !
34094/// let mut req = UserMakeAdmin::default();
34095/// 
34096/// // You can configure optional parameters by calling the respective setters at will, and
34097/// // execute the final call using `doit()`.
34098/// // Values shown here are possibly random and not representative !
34099/// let result = hub.users().make_admin(req, "userKey")
34100///              .doit();
34101/// # }
34102/// ```
34103pub struct UserMakeAdminCall<'a, C, A>
34104    where C: 'a, A: 'a {
34105
34106    hub: &'a Directory<C, A>,
34107    _request: UserMakeAdmin,
34108    _user_key: String,
34109    _delegate: Option<&'a mut dyn Delegate>,
34110    _additional_params: HashMap<String, String>,
34111    _scopes: BTreeMap<String, ()>
34112}
34113
34114impl<'a, C, A> CallBuilder for UserMakeAdminCall<'a, C, A> {}
34115
34116impl<'a, C, A> UserMakeAdminCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
34117
34118
34119    /// Perform the operation you have build so far.
34120    pub fn doit(mut self) -> Result<hyper::client::Response> {
34121        use std::io::{Read, Seek};
34122        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
34123        let mut dd = DefaultDelegate;
34124        let mut dlg: &mut dyn Delegate = match self._delegate {
34125            Some(d) => d,
34126            None => &mut dd
34127        };
34128        dlg.begin(MethodInfo { id: "directory.users.makeAdmin",
34129                               http_method: hyper::method::Method::Post });
34130        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
34131        params.push(("userKey", self._user_key.to_string()));
34132        for &field in ["userKey"].iter() {
34133            if self._additional_params.contains_key(field) {
34134                dlg.finished(false);
34135                return Err(Error::FieldClash(field));
34136            }
34137        }
34138        for (name, value) in self._additional_params.iter() {
34139            params.push((&name, value.clone()));
34140        }
34141
34142
34143        let mut url = self.hub._base_url.clone() + "users/{userKey}/makeAdmin";
34144        if self._scopes.len() == 0 {
34145            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
34146        }
34147
34148        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
34149            let mut replace_with: Option<&str> = None;
34150            for &(name, ref value) in params.iter() {
34151                if name == param_name {
34152                    replace_with = Some(value);
34153                    break;
34154                }
34155            }
34156            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
34157        }
34158        {
34159            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
34160            for param_name in ["userKey"].iter() {
34161                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
34162                    indices_for_removal.push(index);
34163                }
34164            }
34165            for &index in indices_for_removal.iter() {
34166                params.remove(index);
34167            }
34168        }
34169
34170        let url = hyper::Url::parse_with_params(&url, params).unwrap();
34171
34172        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
34173        let mut request_value_reader =
34174            {
34175                let mut value = json::value::to_value(&self._request).expect("serde to work");
34176                remove_json_null_values(&mut value);
34177                let mut dst = io::Cursor::new(Vec::with_capacity(128));
34178                json::to_writer(&mut dst, &value).unwrap();
34179                dst
34180            };
34181        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
34182        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
34183
34184
34185        loop {
34186            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
34187                Ok(token) => token,
34188                Err(err) => {
34189                    match  dlg.token(&*err) {
34190                        Some(token) => token,
34191                        None => {
34192                            dlg.finished(false);
34193                            return Err(Error::MissingToken(err))
34194                        }
34195                    }
34196                }
34197            };
34198            let auth_header = Authorization(Bearer { token: token.access_token });
34199            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
34200            let mut req_result = {
34201                let mut client = &mut *self.hub.client.borrow_mut();
34202                let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
34203                    .header(UserAgent(self.hub._user_agent.clone()))
34204                    .header(auth_header.clone())
34205                    .header(ContentType(json_mime_type.clone()))
34206                    .header(ContentLength(request_size as u64))
34207                    .body(&mut request_value_reader);
34208
34209                dlg.pre_request();
34210                req.send()
34211            };
34212
34213            match req_result {
34214                Err(err) => {
34215                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
34216                        sleep(d);
34217                        continue;
34218                    }
34219                    dlg.finished(false);
34220                    return Err(Error::HttpError(err))
34221                }
34222                Ok(mut res) => {
34223                    if !res.status.is_success() {
34224                        let mut json_err = String::new();
34225                        res.read_to_string(&mut json_err).unwrap();
34226                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
34227                                                              json::from_str(&json_err).ok(),
34228                                                              json::from_str(&json_err).ok()) {
34229                            sleep(d);
34230                            continue;
34231                        }
34232                        dlg.finished(false);
34233                        return match json::from_str::<ErrorResponse>(&json_err){
34234                            Err(_) => Err(Error::Failure(res)),
34235                            Ok(serr) => Err(Error::BadRequest(serr))
34236                        }
34237                    }
34238                    let result_value = res;
34239
34240                    dlg.finished(true);
34241                    return Ok(result_value)
34242                }
34243            }
34244        }
34245    }
34246
34247
34248    ///
34249    /// Sets the *request* property to the given value.
34250    ///
34251    /// Even though the property as already been set when instantiating this call,
34252    /// we provide this method for API completeness.
34253    pub fn request(mut self, new_value: UserMakeAdmin) -> UserMakeAdminCall<'a, C, A> {
34254        self._request = new_value;
34255        self
34256    }
34257    /// Email or immutable ID of the user as admin
34258    ///
34259    /// Sets the *user key* path property to the given value.
34260    ///
34261    /// Even though the property as already been set when instantiating this call,
34262    /// we provide this method for API completeness.
34263    pub fn user_key(mut self, new_value: &str) -> UserMakeAdminCall<'a, C, A> {
34264        self._user_key = new_value.to_string();
34265        self
34266    }
34267    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34268    /// while executing the actual API request.
34269    /// 
34270    /// It should be used to handle progress information, and to implement a certain level of resilience.
34271    ///
34272    /// Sets the *delegate* property to the given value.
34273    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserMakeAdminCall<'a, C, A> {
34274        self._delegate = Some(new_value);
34275        self
34276    }
34277
34278    /// Set any additional parameter of the query string used in the request.
34279    /// It should be used to set parameters which are not yet available through their own
34280    /// setters.
34281    ///
34282    /// Please note that this method must not be used to set any of the known parameters
34283    /// which have their own setter method. If done anyway, the request will fail.
34284    ///
34285    /// # Additional Parameters
34286    ///
34287    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34288    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34289    /// * *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.
34290    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34291    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34292    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34293    /// * *alt* (query-string) - Data format for the response.
34294    pub fn param<T>(mut self, name: T, value: T) -> UserMakeAdminCall<'a, C, A>
34295                                                        where T: AsRef<str> {
34296        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
34297        self
34298    }
34299
34300    /// Identifies the authorization scope for the method you are building.
34301    ///
34302    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
34303    /// `Scope::DirectoryUser`.
34304    ///
34305    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34306    /// tokens for more than one scope.
34307    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
34308    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
34309    /// function for details).
34310    ///
34311    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34312    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34313    /// sufficient, a read-write scope will do as well.
34314    pub fn add_scope<T, S>(mut self, scope: T) -> UserMakeAdminCall<'a, C, A>
34315                                                        where T: Into<Option<S>>,
34316                                                              S: AsRef<str> {
34317        match scope.into() {
34318          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
34319          None => None,
34320        };
34321        self
34322    }
34323}
34324
34325
34326/// update user. This method supports patch semantics.
34327///
34328/// A builder for the *patch* method supported by a *user* resource.
34329/// It is not used directly, but through a `UserMethods` instance.
34330///
34331/// # Example
34332///
34333/// Instantiate a resource method builder
34334///
34335/// ```test_harness,no_run
34336/// # extern crate hyper;
34337/// # extern crate hyper_rustls;
34338/// # extern crate yup_oauth2 as oauth2;
34339/// # extern crate google_admin1_directory as admin1_directory;
34340/// use admin1_directory::User;
34341/// # #[test] fn egal() {
34342/// # use std::default::Default;
34343/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
34344/// # use admin1_directory::Directory;
34345/// 
34346/// # let secret: ApplicationSecret = Default::default();
34347/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
34348/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
34349/// #                               <MemoryStorage as Default>::default(), None);
34350/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
34351/// // As the method needs a request, you would usually fill it with the desired information
34352/// // into the respective structure. Some of the parts shown here might not be applicable !
34353/// // Values shown here are possibly random and not representative !
34354/// let mut req = User::default();
34355/// 
34356/// // You can configure optional parameters by calling the respective setters at will, and
34357/// // execute the final call using `doit()`.
34358/// // Values shown here are possibly random and not representative !
34359/// let result = hub.users().patch(req, "userKey")
34360///              .doit();
34361/// # }
34362/// ```
34363pub struct UserPatchCall<'a, C, A>
34364    where C: 'a, A: 'a {
34365
34366    hub: &'a Directory<C, A>,
34367    _request: User,
34368    _user_key: String,
34369    _delegate: Option<&'a mut dyn Delegate>,
34370    _additional_params: HashMap<String, String>,
34371    _scopes: BTreeMap<String, ()>
34372}
34373
34374impl<'a, C, A> CallBuilder for UserPatchCall<'a, C, A> {}
34375
34376impl<'a, C, A> UserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
34377
34378
34379    /// Perform the operation you have build so far.
34380    pub fn doit(mut self) -> Result<(hyper::client::Response, User)> {
34381        use std::io::{Read, Seek};
34382        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
34383        let mut dd = DefaultDelegate;
34384        let mut dlg: &mut dyn Delegate = match self._delegate {
34385            Some(d) => d,
34386            None => &mut dd
34387        };
34388        dlg.begin(MethodInfo { id: "directory.users.patch",
34389                               http_method: hyper::method::Method::Patch });
34390        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
34391        params.push(("userKey", self._user_key.to_string()));
34392        for &field in ["alt", "userKey"].iter() {
34393            if self._additional_params.contains_key(field) {
34394                dlg.finished(false);
34395                return Err(Error::FieldClash(field));
34396            }
34397        }
34398        for (name, value) in self._additional_params.iter() {
34399            params.push((&name, value.clone()));
34400        }
34401
34402        params.push(("alt", "json".to_string()));
34403
34404        let mut url = self.hub._base_url.clone() + "users/{userKey}";
34405        if self._scopes.len() == 0 {
34406            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
34407        }
34408
34409        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
34410            let mut replace_with: Option<&str> = None;
34411            for &(name, ref value) in params.iter() {
34412                if name == param_name {
34413                    replace_with = Some(value);
34414                    break;
34415                }
34416            }
34417            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
34418        }
34419        {
34420            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
34421            for param_name in ["userKey"].iter() {
34422                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
34423                    indices_for_removal.push(index);
34424                }
34425            }
34426            for &index in indices_for_removal.iter() {
34427                params.remove(index);
34428            }
34429        }
34430
34431        let url = hyper::Url::parse_with_params(&url, params).unwrap();
34432
34433        let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
34434        let mut request_value_reader =
34435            {
34436                let mut value = json::value::to_value(&self._request).expect("serde to work");
34437                remove_json_null_values(&mut value);
34438                let mut dst = io::Cursor::new(Vec::with_capacity(128));
34439                json::to_writer(&mut dst, &value).unwrap();
34440                dst
34441            };
34442        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
34443        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
34444
34445
34446        loop {
34447            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
34448                Ok(token) => token,
34449                Err(err) => {
34450                    match  dlg.token(&*err) {
34451                        Some(token) => token,
34452                        None => {
34453                            dlg.finished(false);
34454                            return Err(Error::MissingToken(err))
34455                        }
34456                    }
34457                }
34458            };
34459            let auth_header = Authorization(Bearer { token: token.access_token });
34460            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
34461            let mut req_result = {
34462                let mut client = &mut *self.hub.client.borrow_mut();
34463                let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone())
34464                    .header(UserAgent(self.hub._user_agent.clone()))
34465                    .header(auth_header.clone())
34466                    .header(ContentType(json_mime_type.clone()))
34467                    .header(ContentLength(request_size as u64))
34468                    .body(&mut request_value_reader);
34469
34470                dlg.pre_request();
34471                req.send()
34472            };
34473
34474            match req_result {
34475                Err(err) => {
34476                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
34477                        sleep(d);
34478                        continue;
34479                    }
34480                    dlg.finished(false);
34481                    return Err(Error::HttpError(err))
34482                }
34483                Ok(mut res) => {
34484                    if !res.status.is_success() {
34485                        let mut json_err = String::new();
34486                        res.read_to_string(&mut json_err).unwrap();
34487                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
34488                                                              json::from_str(&json_err).ok(),
34489                                                              json::from_str(&json_err).ok()) {
34490                            sleep(d);
34491                            continue;
34492                        }
34493                        dlg.finished(false);
34494                        return match json::from_str::<ErrorResponse>(&json_err){
34495                            Err(_) => Err(Error::Failure(res)),
34496                            Ok(serr) => Err(Error::BadRequest(serr))
34497                        }
34498                    }
34499                    let result_value = {
34500                        let mut json_response = String::new();
34501                        res.read_to_string(&mut json_response).unwrap();
34502                        match json::from_str(&json_response) {
34503                            Ok(decoded) => (res, decoded),
34504                            Err(err) => {
34505                                dlg.response_json_decode_error(&json_response, &err);
34506                                return Err(Error::JsonDecodeError(json_response, err));
34507                            }
34508                        }
34509                    };
34510
34511                    dlg.finished(true);
34512                    return Ok(result_value)
34513                }
34514            }
34515        }
34516    }
34517
34518
34519    ///
34520    /// Sets the *request* property to the given value.
34521    ///
34522    /// Even though the property as already been set when instantiating this call,
34523    /// we provide this method for API completeness.
34524    pub fn request(mut self, new_value: User) -> UserPatchCall<'a, C, A> {
34525        self._request = new_value;
34526        self
34527    }
34528    /// Email or immutable ID of the user. If ID, it should match with id of user object
34529    ///
34530    /// Sets the *user key* path property to the given value.
34531    ///
34532    /// Even though the property as already been set when instantiating this call,
34533    /// we provide this method for API completeness.
34534    pub fn user_key(mut self, new_value: &str) -> UserPatchCall<'a, C, A> {
34535        self._user_key = new_value.to_string();
34536        self
34537    }
34538    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34539    /// while executing the actual API request.
34540    /// 
34541    /// It should be used to handle progress information, and to implement a certain level of resilience.
34542    ///
34543    /// Sets the *delegate* property to the given value.
34544    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserPatchCall<'a, C, A> {
34545        self._delegate = Some(new_value);
34546        self
34547    }
34548
34549    /// Set any additional parameter of the query string used in the request.
34550    /// It should be used to set parameters which are not yet available through their own
34551    /// setters.
34552    ///
34553    /// Please note that this method must not be used to set any of the known parameters
34554    /// which have their own setter method. If done anyway, the request will fail.
34555    ///
34556    /// # Additional Parameters
34557    ///
34558    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34559    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34560    /// * *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.
34561    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34562    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34563    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34564    /// * *alt* (query-string) - Data format for the response.
34565    pub fn param<T>(mut self, name: T, value: T) -> UserPatchCall<'a, C, A>
34566                                                        where T: AsRef<str> {
34567        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
34568        self
34569    }
34570
34571    /// Identifies the authorization scope for the method you are building.
34572    ///
34573    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
34574    /// `Scope::DirectoryUser`.
34575    ///
34576    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34577    /// tokens for more than one scope.
34578    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
34579    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
34580    /// function for details).
34581    ///
34582    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34583    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34584    /// sufficient, a read-write scope will do as well.
34585    pub fn add_scope<T, S>(mut self, scope: T) -> UserPatchCall<'a, C, A>
34586                                                        where T: Into<Option<S>>,
34587                                                              S: AsRef<str> {
34588        match scope.into() {
34589          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
34590          None => None,
34591        };
34592        self
34593    }
34594}
34595
34596
34597/// Remove a alias for the user
34598///
34599/// A builder for the *aliases.delete* method supported by a *user* resource.
34600/// It is not used directly, but through a `UserMethods` instance.
34601///
34602/// # Example
34603///
34604/// Instantiate a resource method builder
34605///
34606/// ```test_harness,no_run
34607/// # extern crate hyper;
34608/// # extern crate hyper_rustls;
34609/// # extern crate yup_oauth2 as oauth2;
34610/// # extern crate google_admin1_directory as admin1_directory;
34611/// # #[test] fn egal() {
34612/// # use std::default::Default;
34613/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
34614/// # use admin1_directory::Directory;
34615/// 
34616/// # let secret: ApplicationSecret = Default::default();
34617/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
34618/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
34619/// #                               <MemoryStorage as Default>::default(), None);
34620/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
34621/// // You can configure optional parameters by calling the respective setters at will, and
34622/// // execute the final call using `doit()`.
34623/// // Values shown here are possibly random and not representative !
34624/// let result = hub.users().aliases_delete("userKey", "alias")
34625///              .doit();
34626/// # }
34627/// ```
34628pub struct UserAliaseDeleteCall<'a, C, A>
34629    where C: 'a, A: 'a {
34630
34631    hub: &'a Directory<C, A>,
34632    _user_key: String,
34633    _alias: String,
34634    _delegate: Option<&'a mut dyn Delegate>,
34635    _additional_params: HashMap<String, String>,
34636    _scopes: BTreeMap<String, ()>
34637}
34638
34639impl<'a, C, A> CallBuilder for UserAliaseDeleteCall<'a, C, A> {}
34640
34641impl<'a, C, A> UserAliaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
34642
34643
34644    /// Perform the operation you have build so far.
34645    pub fn doit(mut self) -> Result<hyper::client::Response> {
34646        use std::io::{Read, Seek};
34647        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
34648        let mut dd = DefaultDelegate;
34649        let mut dlg: &mut dyn Delegate = match self._delegate {
34650            Some(d) => d,
34651            None => &mut dd
34652        };
34653        dlg.begin(MethodInfo { id: "directory.users.aliases.delete",
34654                               http_method: hyper::method::Method::Delete });
34655        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
34656        params.push(("userKey", self._user_key.to_string()));
34657        params.push(("alias", self._alias.to_string()));
34658        for &field in ["userKey", "alias"].iter() {
34659            if self._additional_params.contains_key(field) {
34660                dlg.finished(false);
34661                return Err(Error::FieldClash(field));
34662            }
34663        }
34664        for (name, value) in self._additional_params.iter() {
34665            params.push((&name, value.clone()));
34666        }
34667
34668
34669        let mut url = self.hub._base_url.clone() + "users/{userKey}/aliases/{alias}";
34670        if self._scopes.len() == 0 {
34671            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
34672        }
34673
34674        for &(find_this, param_name) in [("{userKey}", "userKey"), ("{alias}", "alias")].iter() {
34675            let mut replace_with: Option<&str> = None;
34676            for &(name, ref value) in params.iter() {
34677                if name == param_name {
34678                    replace_with = Some(value);
34679                    break;
34680                }
34681            }
34682            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
34683        }
34684        {
34685            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
34686            for param_name in ["alias", "userKey"].iter() {
34687                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
34688                    indices_for_removal.push(index);
34689                }
34690            }
34691            for &index in indices_for_removal.iter() {
34692                params.remove(index);
34693            }
34694        }
34695
34696        let url = hyper::Url::parse_with_params(&url, params).unwrap();
34697
34698
34699
34700        loop {
34701            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
34702                Ok(token) => token,
34703                Err(err) => {
34704                    match  dlg.token(&*err) {
34705                        Some(token) => token,
34706                        None => {
34707                            dlg.finished(false);
34708                            return Err(Error::MissingToken(err))
34709                        }
34710                    }
34711                }
34712            };
34713            let auth_header = Authorization(Bearer { token: token.access_token });
34714            let mut req_result = {
34715                let mut client = &mut *self.hub.client.borrow_mut();
34716                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
34717                    .header(UserAgent(self.hub._user_agent.clone()))
34718                    .header(auth_header.clone());
34719
34720                dlg.pre_request();
34721                req.send()
34722            };
34723
34724            match req_result {
34725                Err(err) => {
34726                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
34727                        sleep(d);
34728                        continue;
34729                    }
34730                    dlg.finished(false);
34731                    return Err(Error::HttpError(err))
34732                }
34733                Ok(mut res) => {
34734                    if !res.status.is_success() {
34735                        let mut json_err = String::new();
34736                        res.read_to_string(&mut json_err).unwrap();
34737                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
34738                                                              json::from_str(&json_err).ok(),
34739                                                              json::from_str(&json_err).ok()) {
34740                            sleep(d);
34741                            continue;
34742                        }
34743                        dlg.finished(false);
34744                        return match json::from_str::<ErrorResponse>(&json_err){
34745                            Err(_) => Err(Error::Failure(res)),
34746                            Ok(serr) => Err(Error::BadRequest(serr))
34747                        }
34748                    }
34749                    let result_value = res;
34750
34751                    dlg.finished(true);
34752                    return Ok(result_value)
34753                }
34754            }
34755        }
34756    }
34757
34758
34759    /// Email or immutable ID of the user
34760    ///
34761    /// Sets the *user key* path property to the given value.
34762    ///
34763    /// Even though the property as already been set when instantiating this call,
34764    /// we provide this method for API completeness.
34765    pub fn user_key(mut self, new_value: &str) -> UserAliaseDeleteCall<'a, C, A> {
34766        self._user_key = new_value.to_string();
34767        self
34768    }
34769    /// The alias to be removed
34770    ///
34771    /// Sets the *alias* path property to the given value.
34772    ///
34773    /// Even though the property as already been set when instantiating this call,
34774    /// we provide this method for API completeness.
34775    pub fn alias(mut self, new_value: &str) -> UserAliaseDeleteCall<'a, C, A> {
34776        self._alias = new_value.to_string();
34777        self
34778    }
34779    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34780    /// while executing the actual API request.
34781    /// 
34782    /// It should be used to handle progress information, and to implement a certain level of resilience.
34783    ///
34784    /// Sets the *delegate* property to the given value.
34785    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserAliaseDeleteCall<'a, C, A> {
34786        self._delegate = Some(new_value);
34787        self
34788    }
34789
34790    /// Set any additional parameter of the query string used in the request.
34791    /// It should be used to set parameters which are not yet available through their own
34792    /// setters.
34793    ///
34794    /// Please note that this method must not be used to set any of the known parameters
34795    /// which have their own setter method. If done anyway, the request will fail.
34796    ///
34797    /// # Additional Parameters
34798    ///
34799    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34800    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34801    /// * *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.
34802    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34803    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34804    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34805    /// * *alt* (query-string) - Data format for the response.
34806    pub fn param<T>(mut self, name: T, value: T) -> UserAliaseDeleteCall<'a, C, A>
34807                                                        where T: AsRef<str> {
34808        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
34809        self
34810    }
34811
34812    /// Identifies the authorization scope for the method you are building.
34813    ///
34814    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
34815    /// `Scope::DirectoryUser`.
34816    ///
34817    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34818    /// tokens for more than one scope.
34819    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
34820    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
34821    /// function for details).
34822    ///
34823    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34824    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34825    /// sufficient, a read-write scope will do as well.
34826    pub fn add_scope<T, S>(mut self, scope: T) -> UserAliaseDeleteCall<'a, C, A>
34827                                                        where T: Into<Option<S>>,
34828                                                              S: AsRef<str> {
34829        match scope.into() {
34830          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
34831          None => None,
34832        };
34833        self
34834    }
34835}
34836
34837
34838/// Delete user
34839///
34840/// A builder for the *delete* method supported by a *user* resource.
34841/// It is not used directly, but through a `UserMethods` instance.
34842///
34843/// # Example
34844///
34845/// Instantiate a resource method builder
34846///
34847/// ```test_harness,no_run
34848/// # extern crate hyper;
34849/// # extern crate hyper_rustls;
34850/// # extern crate yup_oauth2 as oauth2;
34851/// # extern crate google_admin1_directory as admin1_directory;
34852/// # #[test] fn egal() {
34853/// # use std::default::Default;
34854/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
34855/// # use admin1_directory::Directory;
34856/// 
34857/// # let secret: ApplicationSecret = Default::default();
34858/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
34859/// #                               hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
34860/// #                               <MemoryStorage as Default>::default(), None);
34861/// # let mut hub = Directory::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
34862/// // You can configure optional parameters by calling the respective setters at will, and
34863/// // execute the final call using `doit()`.
34864/// // Values shown here are possibly random and not representative !
34865/// let result = hub.users().delete("userKey")
34866///              .doit();
34867/// # }
34868/// ```
34869pub struct UserDeleteCall<'a, C, A>
34870    where C: 'a, A: 'a {
34871
34872    hub: &'a Directory<C, A>,
34873    _user_key: String,
34874    _delegate: Option<&'a mut dyn Delegate>,
34875    _additional_params: HashMap<String, String>,
34876    _scopes: BTreeMap<String, ()>
34877}
34878
34879impl<'a, C, A> CallBuilder for UserDeleteCall<'a, C, A> {}
34880
34881impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
34882
34883
34884    /// Perform the operation you have build so far.
34885    pub fn doit(mut self) -> Result<hyper::client::Response> {
34886        use std::io::{Read, Seek};
34887        use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
34888        let mut dd = DefaultDelegate;
34889        let mut dlg: &mut dyn Delegate = match self._delegate {
34890            Some(d) => d,
34891            None => &mut dd
34892        };
34893        dlg.begin(MethodInfo { id: "directory.users.delete",
34894                               http_method: hyper::method::Method::Delete });
34895        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
34896        params.push(("userKey", self._user_key.to_string()));
34897        for &field in ["userKey"].iter() {
34898            if self._additional_params.contains_key(field) {
34899                dlg.finished(false);
34900                return Err(Error::FieldClash(field));
34901            }
34902        }
34903        for (name, value) in self._additional_params.iter() {
34904            params.push((&name, value.clone()));
34905        }
34906
34907
34908        let mut url = self.hub._base_url.clone() + "users/{userKey}";
34909        if self._scopes.len() == 0 {
34910            self._scopes.insert(Scope::DirectoryUser.as_ref().to_string(), ());
34911        }
34912
34913        for &(find_this, param_name) in [("{userKey}", "userKey")].iter() {
34914            let mut replace_with: Option<&str> = None;
34915            for &(name, ref value) in params.iter() {
34916                if name == param_name {
34917                    replace_with = Some(value);
34918                    break;
34919                }
34920            }
34921            url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
34922        }
34923        {
34924            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
34925            for param_name in ["userKey"].iter() {
34926                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
34927                    indices_for_removal.push(index);
34928                }
34929            }
34930            for &index in indices_for_removal.iter() {
34931                params.remove(index);
34932            }
34933        }
34934
34935        let url = hyper::Url::parse_with_params(&url, params).unwrap();
34936
34937
34938
34939        loop {
34940            let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
34941                Ok(token) => token,
34942                Err(err) => {
34943                    match  dlg.token(&*err) {
34944                        Some(token) => token,
34945                        None => {
34946                            dlg.finished(false);
34947                            return Err(Error::MissingToken(err))
34948                        }
34949                    }
34950                }
34951            };
34952            let auth_header = Authorization(Bearer { token: token.access_token });
34953            let mut req_result = {
34954                let mut client = &mut *self.hub.client.borrow_mut();
34955                let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
34956                    .header(UserAgent(self.hub._user_agent.clone()))
34957                    .header(auth_header.clone());
34958
34959                dlg.pre_request();
34960                req.send()
34961            };
34962
34963            match req_result {
34964                Err(err) => {
34965                    if let oauth2::Retry::After(d) = dlg.http_error(&err) {
34966                        sleep(d);
34967                        continue;
34968                    }
34969                    dlg.finished(false);
34970                    return Err(Error::HttpError(err))
34971                }
34972                Ok(mut res) => {
34973                    if !res.status.is_success() {
34974                        let mut json_err = String::new();
34975                        res.read_to_string(&mut json_err).unwrap();
34976                        if let oauth2::Retry::After(d) = dlg.http_failure(&res,
34977                                                              json::from_str(&json_err).ok(),
34978                                                              json::from_str(&json_err).ok()) {
34979                            sleep(d);
34980                            continue;
34981                        }
34982                        dlg.finished(false);
34983                        return match json::from_str::<ErrorResponse>(&json_err){
34984                            Err(_) => Err(Error::Failure(res)),
34985                            Ok(serr) => Err(Error::BadRequest(serr))
34986                        }
34987                    }
34988                    let result_value = res;
34989
34990                    dlg.finished(true);
34991                    return Ok(result_value)
34992                }
34993            }
34994        }
34995    }
34996
34997
34998    /// Email or immutable ID of the user
34999    ///
35000    /// Sets the *user key* path property to the given value.
35001    ///
35002    /// Even though the property as already been set when instantiating this call,
35003    /// we provide this method for API completeness.
35004    pub fn user_key(mut self, new_value: &str) -> UserDeleteCall<'a, C, A> {
35005        self._user_key = new_value.to_string();
35006        self
35007    }
35008    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35009    /// while executing the actual API request.
35010    /// 
35011    /// It should be used to handle progress information, and to implement a certain level of resilience.
35012    ///
35013    /// Sets the *delegate* property to the given value.
35014    pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> UserDeleteCall<'a, C, A> {
35015        self._delegate = Some(new_value);
35016        self
35017    }
35018
35019    /// Set any additional parameter of the query string used in the request.
35020    /// It should be used to set parameters which are not yet available through their own
35021    /// setters.
35022    ///
35023    /// Please note that this method must not be used to set any of the known parameters
35024    /// which have their own setter method. If done anyway, the request will fail.
35025    ///
35026    /// # Additional Parameters
35027    ///
35028    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35029    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35030    /// * *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.
35031    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35032    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35033    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35034    /// * *alt* (query-string) - Data format for the response.
35035    pub fn param<T>(mut self, name: T, value: T) -> UserDeleteCall<'a, C, A>
35036                                                        where T: AsRef<str> {
35037        self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
35038        self
35039    }
35040
35041    /// Identifies the authorization scope for the method you are building.
35042    ///
35043    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
35044    /// `Scope::DirectoryUser`.
35045    ///
35046    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35047    /// tokens for more than one scope.
35048    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
35049    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
35050    /// function for details).
35051    ///
35052    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35053    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35054    /// sufficient, a read-write scope will do as well.
35055    pub fn add_scope<T, S>(mut self, scope: T) -> UserDeleteCall<'a, C, A>
35056                                                        where T: Into<Option<S>>,
35057                                                              S: AsRef<str> {
35058        match scope.into() {
35059          Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
35060          None => None,
35061        };
35062        self
35063    }
35064}
35065
35066